• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ os_strdup函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中os_strdup函数的典型用法代码示例。如果您正苦于以下问题:C++ os_strdup函数的具体用法?C++ os_strdup怎么用?C++ os_strdup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了os_strdup函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: DB_Search


//.........这里部分代码省略.........
        fprintf(fp, "%c%c%c%s !%ld %s\n",
                '!',
                p >= 1 ? '!' : '+',
                p == 2 ? '!' : (p > 2) ? '?' : '+',
                c_sum,
                (long int)lf->time,
                f_name);
        fflush(fp);

        switch (DecodeSum(&newsum, c_sum)) {
        case -1:
            merror("%s: ERROR: Couldn't decode syscheck sum from log.", ARGV0);
            lf->data = NULL;
            return 0;

        case 0:
            switch (DecodeSum(&oldsum, saved_sum)) {
            case -1:
                merror("%s: ERROR: Couldn't decode syscheck sum from database.", ARGV0);
                lf->data = NULL;
                return 0;

            case 0:
                FillEvent(lf, f_name, &newsum);

                /* Generate size message */
                if (!oldsum.size || !newsum.size || strcmp(oldsum.size, newsum.size) == 0) {
                    sdb.size[0] = '\0';
                } else {
                    snprintf(sdb.size, OS_FLSIZE,
                             "Size changed from '%s' to '%s'\n",
                             oldsum.size, newsum.size);

                    os_strdup(oldsum.size, lf->size_before);
                }

                /* Permission message */
                if (oldsum.perm == newsum.perm) {
                    sdb.perm[0] = '\0';
                } else if (oldsum.perm > 0 && newsum.perm > 0) {

                    snprintf(sdb.perm, OS_FLSIZE, "Permissions changed from "
                             "'%c%c%c%c%c%c%c%c%c' "
                             "to '%c%c%c%c%c%c%c%c%c'\n",
                             (oldsum.perm & S_IRUSR) ? 'r' : '-',
                             (oldsum.perm & S_IWUSR) ? 'w' : '-',

                             (oldsum.perm & S_ISUID) ? 's' :
                             (oldsum.perm & S_IXUSR) ? 'x' : '-',

                             (oldsum.perm & S_IRGRP) ? 'r' : '-',
                             (oldsum.perm & S_IWGRP) ? 'w' : '-',

                             (oldsum.perm & S_ISGID) ? 's' :
                             (oldsum.perm & S_IXGRP) ? 'x' : '-',

                             (oldsum.perm & S_IROTH) ? 'r' : '-',
                             (oldsum.perm & S_IWOTH) ? 'w' : '-',

                             (oldsum.perm & S_ISVTX) ? 't' :
                             (oldsum.perm & S_IXOTH) ? 'x' : '-',



                             (newsum.perm & S_IRUSR) ? 'r' : '-',
                             (newsum.perm & S_IWUSR) ? 'w' : '-',
开发者ID:Cryptophobia,项目名称:ossec-wazuh,代码行数:67,代码来源:syscheck.c


示例2: wpa_init_conf

static void wpa_init_conf(struct eapol_test_data *e,
			  struct wpa_supplicant *wpa_s, const char *authsrv,
			  int port, const char *secret,
			  const char *cli_addr)
{
	struct hostapd_radius_server *as;
	int res;

	wpa_s->bssid[5] = 1;
	os_memcpy(wpa_s->own_addr, e->own_addr, ETH_ALEN);
	e->own_ip_addr.s_addr = htonl((127 << 24) | 1);
	os_strlcpy(wpa_s->ifname, "test", sizeof(wpa_s->ifname));

	e->radius_conf = os_zalloc(sizeof(struct hostapd_radius_servers));
	assert(e->radius_conf != NULL);
	e->radius_conf->num_auth_servers = 1;
	as = os_zalloc(sizeof(struct hostapd_radius_server));
	assert(as != NULL);
#if defined(CONFIG_NATIVE_WINDOWS) || defined(CONFIG_ANSI_C_EXTRA)
	{
		int a[4];
		u8 *pos;
		sscanf(authsrv, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]);
		pos = (u8 *) &as->addr.u.v4;
		*pos++ = a[0];
		*pos++ = a[1];
		*pos++ = a[2];
		*pos++ = a[3];
	}
#else /* CONFIG_NATIVE_WINDOWS or CONFIG_ANSI_C_EXTRA */
	if (inet_aton(authsrv, &as->addr.u.v4) < 0) {
		wpa_printf(MSG_ERROR, "Invalid IP address '%s'",
			   authsrv);
		assert(0);
	}
#endif /* CONFIG_NATIVE_WINDOWS or CONFIG_ANSI_C_EXTRA */
	as->addr.af = AF_INET;
	as->port = port;
	as->shared_secret = (u8 *) os_strdup(secret);
	as->shared_secret_len = os_strlen(secret);
	e->radius_conf->auth_server = as;
	e->radius_conf->auth_servers = as;
	e->radius_conf->msg_dumps = 1;
	if (cli_addr) {
		if (hostapd_parse_ip_addr(cli_addr,
					  &e->radius_conf->client_addr) == 0)
			e->radius_conf->force_client_addr = 1;
		else {
			wpa_printf(MSG_ERROR, "Invalid IP address '%s'",
				   cli_addr);
			assert(0);
		}
	}

	e->radius = radius_client_init(wpa_s, e->radius_conf);
	assert(e->radius != NULL);

	res = radius_client_register(e->radius, RADIUS_AUTH,
				     ieee802_1x_receive_auth, e);
	assert(res == 0);
}
开发者ID:Hansenq,项目名称:wifi-goes-to-town,代码行数:61,代码来源:eapol_test.c


示例3: wpa_supplicant_conf_ap

static int wpa_supplicant_conf_ap(struct wpa_supplicant *wpa_s,
				  struct wpa_ssid *ssid,
				  struct hostapd_config *conf)
{
	struct hostapd_bss_config *bss = conf->bss[0];

	conf->driver = wpa_s->driver;

	os_strlcpy(bss->iface, wpa_s->ifname, sizeof(bss->iface));

	conf->hw_mode = ieee80211_freq_to_chan(ssid->frequency,
					       &conf->channel);
	if (conf->hw_mode == NUM_HOSTAPD_MODES) {
		wpa_printf(MSG_ERROR, "Unsupported AP mode frequency: %d MHz",
			   ssid->frequency);
		return -1;
	}

	wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf);

	if (ieee80211_is_dfs(ssid->frequency) && wpa_s->conf->country[0]) {
		conf->ieee80211h = 1;
		conf->ieee80211d = 1;
		conf->country[0] = wpa_s->conf->country[0];
		conf->country[1] = wpa_s->conf->country[1];
	}

#ifdef CONFIG_P2P
	if (conf->hw_mode == HOSTAPD_MODE_IEEE80211G &&
	    (ssid->mode == WPAS_MODE_P2P_GO ||
	     ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)) {
		/* Remove 802.11b rates from supported and basic rate sets */
		int *list = os_malloc(4 * sizeof(int));
		if (list) {
			list[0] = 60;
			list[1] = 120;
			list[2] = 240;
			list[3] = -1;
		}
		conf->basic_rates = list;

		list = os_malloc(9 * sizeof(int));
		if (list) {
			list[0] = 60;
			list[1] = 90;
			list[2] = 120;
			list[3] = 180;
			list[4] = 240;
			list[5] = 360;
			list[6] = 480;
			list[7] = 540;
			list[8] = -1;
		}
		conf->supported_rates = list;
	}

	bss->isolate = !wpa_s->conf->p2p_intra_bss;
	bss->force_per_enrollee_psk = wpa_s->global->p2p_per_sta_psk;

	if (ssid->p2p_group) {
		os_memcpy(bss->ip_addr_go, wpa_s->parent->conf->ip_addr_go, 4);
		os_memcpy(bss->ip_addr_mask, wpa_s->parent->conf->ip_addr_mask,
			  4);
		os_memcpy(bss->ip_addr_start,
			  wpa_s->parent->conf->ip_addr_start, 4);
		os_memcpy(bss->ip_addr_end, wpa_s->parent->conf->ip_addr_end,
			  4);
	}
#endif /* CONFIG_P2P */

	if (ssid->ssid_len == 0) {
		wpa_printf(MSG_ERROR, "No SSID configured for AP mode");
		return -1;
	}
	os_memcpy(bss->ssid.ssid, ssid->ssid, ssid->ssid_len);
	bss->ssid.ssid_len = ssid->ssid_len;
	bss->ssid.ssid_set = 1;

	bss->ignore_broadcast_ssid = ssid->ignore_broadcast_ssid;

	if (ssid->auth_alg)
		bss->auth_algs = ssid->auth_alg;

	if (wpa_key_mgmt_wpa_psk(ssid->key_mgmt))
		bss->wpa = ssid->proto;
	bss->wpa_key_mgmt = ssid->key_mgmt;
	bss->wpa_pairwise = ssid->pairwise_cipher;
	if (ssid->psk_set) {
		bin_clear_free(bss->ssid.wpa_psk, sizeof(*bss->ssid.wpa_psk));
		bss->ssid.wpa_psk = os_zalloc(sizeof(struct hostapd_wpa_psk));
		if (bss->ssid.wpa_psk == NULL)
			return -1;
		os_memcpy(bss->ssid.wpa_psk->psk, ssid->psk, PMK_LEN);
		bss->ssid.wpa_psk->group = 1;
	} else if (ssid->passphrase) {
		bss->ssid.wpa_passphrase = os_strdup(ssid->passphrase);
	} else if (ssid->wep_key_len[0] || ssid->wep_key_len[1] ||
		   ssid->wep_key_len[2] || ssid->wep_key_len[3]) {
		struct hostapd_wep_keys *wep = &bss->ssid.wep;
		int i;
//.........这里部分代码省略.........
开发者ID:priyaanna,项目名称:wpa_supplicant_8,代码行数:101,代码来源:ap.c


示例4: InitializeJVM

/*--------------------------------------------------------------------------*/
BOOL InitializeJVM(void)
{
    BOOL bOK = FALSE;
    char *sciPath = NULL;

    sciPath = getSCI();

    if (!startJVM(sciPath))
    {
#ifdef _MSC_VER
        MessageBox(NULL, gettext("\nScilab cannot open JVM library.\n"), gettext("Error"), MB_ICONEXCLAMATION | MB_OK);
#else
        fprintf(stderr, _("\nScilab cannot open JVM library.\n"));
#endif
    }
    else
    {
        DoLoadLibrarypathInEtc(sciPath);
        DoLoadClasspathInEtc(sciPath);

        if (!createMainScilabObject())
        {
            char *errorMsg = os_strdup(gettext("\nScilab cannot create Scilab Java Main-Class (we have not been able to find the main Scilab class. Check if the Scilab and thirdparty packages are available).\n"));

            if (IsFromJava())
            {
                char *errorMsg2 = gettext("If Scilab is used from Java, make sure that your IDE (ex: Netbeans, etc) is not adding extra dependencies which could not be found at runtime.\n");
                char *tempMsg = (char*)MALLOC(sizeof(char) * (strlen(errorMsg) + strlen(errorMsg2) + 1));
                if (tempMsg)
                {
                    strcpy(tempMsg, errorMsg);
                    strcat(tempMsg, errorMsg2);
                    FREE(errorMsg);
                    errorMsg = tempMsg;
                }
            }
#ifdef _MSC_VER
            MessageBox(NULL, errorMsg, gettext("Error"), MB_ICONEXCLAMATION | MB_OK);
#else
            fprintf(stderr, "%s", errorMsg);
#endif
            if (errorMsg)
            {
                FREE(errorMsg);
                errorMsg = NULL;
            }
        }
        else
        {
            bOK = TRUE;
        }
    }

    if (sciPath)
    {
        FREE(sciPath);
        sciPath = NULL;
    }

    if (!bOK)
    {
        exit(1);
    }

    return TRUE;
}
开发者ID:leowzukw,项目名称:scilab-mirror,代码行数:67,代码来源:InitializeJVM.c


示例5: wpa_get_wowlan_triggers

struct wowlan_triggers *
wpa_get_wowlan_triggers(const char *wowlan_triggers,
			const struct wpa_driver_capa *capa)
{
	struct wowlan_triggers *triggers;
	char *start, *end, *buf;
	int last;

	if (!wowlan_triggers)
		return NULL;

	buf = os_strdup(wowlan_triggers);
	if (buf == NULL)
		return NULL;

	triggers = os_zalloc(sizeof(*triggers));
	if (triggers == NULL)
		goto out;

#define CHECK_TRIGGER(trigger) \
	wpa_check_wowlan_trigger(start, #trigger,			\
				  capa->wowlan_triggers.trigger,	\
				  &triggers->trigger)

	start = buf;
	while (*start != '\0') {
		while (isblank(*start))
			start++;
		if (*start == '\0')
			break;
		end = start;
		while (!isblank(*end) && *end != '\0')
			end++;
		last = *end == '\0';
		*end = '\0';

		if (!CHECK_TRIGGER(any) &&
		    !CHECK_TRIGGER(disconnect) &&
		    !CHECK_TRIGGER(magic_pkt) &&
		    !CHECK_TRIGGER(gtk_rekey_failure) &&
		    !CHECK_TRIGGER(eap_identity_req) &&
		    !CHECK_TRIGGER(four_way_handshake) &&
		    !CHECK_TRIGGER(rfkill_release)) {
			wpa_printf(MSG_DEBUG,
				   "Unknown/unsupported wowlan trigger '%s'",
				   start);
			os_free(triggers);
			triggers = NULL;
			goto out;
		}

		if (last)
			break;
		start = end + 1;
	}
#undef CHECK_TRIGGER

out:
	os_free(buf);
	return triggers;
}
开发者ID:2asoft,项目名称:freebsd,代码行数:61,代码来源:driver_common.c


示例6: while


//.........这里部分代码省略.........

            m = strstr(p, ":");
            if (!m)
            {
                continue;
            }

            z = strlen(p) - strlen(m);
            os_realloc(alertid, (z + 1)*sizeof(char *), alertid);
            strncpy(alertid, p, z);
            alertid[z] = '\0';

            /* Searching for email flag */
            p = strchr(p, ' ');
            if(!p)
            {
                continue;
            }

            p++;


            /* Checking for the flags */
            if((flag & CRALERT_MAIL_SET) &&
                    (strncmp(ALERT_MAIL, p, ALERT_MAIL_SZ) != 0))
            {
                continue;
            }

            p = strchr(p, '-');
            if(p)
            {
                p++;
                os_strdup(p, group);

                /* Cleaning new line from group */
                os_clearnl(group, p);
                if(group != NULL && strstr(group, "syscheck") != NULL)
                {
                    issyscheck = 1;
                }
            }


            /* Searching for active-response flag */
            _r = 1;
            continue;
        }

        if(_r < 1)
            continue;


        /*** Extract information from the event ***/

        /* r1 means: 2006 Apr 13 16:15:17 /var/log/auth.log */
        if(_r == 1)
        {
            /* Clear new line */
            os_clearnl(str, p);

            p = strchr(str, ':');
            if(p)
            {
                p = strchr(p, ' ');
                if(p)
开发者ID:IronSpirit,项目名称:ossec-hids,代码行数:67,代码来源:read-alert.c


示例7: wpa_supplicant_conf_ap

static int wpa_supplicant_conf_ap(struct wpa_supplicant *wpa_s,
				  struct wpa_ssid *ssid,
				  struct hostapd_config *conf)
{
	struct hostapd_bss_config *bss = &conf->bss[0];
	int pairwise;

	conf->driver = wpa_s->driver;

	os_strlcpy(bss->iface, wpa_s->ifname, sizeof(bss->iface));

	if (ssid->frequency == 0) {
		/* default channel 11 */
		conf->hw_mode = HOSTAPD_MODE_IEEE80211G;
		conf->channel = 11;
	} else if (ssid->frequency >= 2412 && ssid->frequency <= 2472) {
		conf->hw_mode = HOSTAPD_MODE_IEEE80211G;
		conf->channel = (ssid->frequency - 2407) / 5;
	} else if ((ssid->frequency >= 5180 && ssid->frequency <= 5240) ||
		   (ssid->frequency >= 5745 && ssid->frequency <= 5825)) {
		conf->hw_mode = HOSTAPD_MODE_IEEE80211A;
		conf->channel = (ssid->frequency - 5000) / 5;
	} else {
		wpa_printf(MSG_ERROR, "Unsupported AP mode frequency: %d MHz",
			   ssid->frequency);
		return -1;
	}

	/* TODO: enable HT40 if driver supports it;
	 * drop to 11b if driver does not support 11g */

#ifdef CONFIG_IEEE80211N
	/*
	 * Enable HT20 if the driver supports it, by setting conf->ieee80211n.
	 * Using default config settings for: conf->ht_op_mode_fixed,
	 * conf->ht_capab, conf->secondary_channel, conf->require_ht
	 */
	if (wpa_s->hw.modes) {
		struct hostapd_hw_modes *mode = NULL;
		int i;
		for (i = 0; i < wpa_s->hw.num_modes; i++) {
			if (wpa_s->hw.modes[i].mode == conf->hw_mode) {
				mode = &wpa_s->hw.modes[i];
				break;
			}
		}
		if (mode && mode->ht_capab)
			conf->ieee80211n = 1;
	}
#endif /* CONFIG_IEEE80211N */

#ifdef CONFIG_P2P
	if (conf->hw_mode == HOSTAPD_MODE_IEEE80211G) {
		/* Remove 802.11b rates from supported and basic rate sets */
		int *list = os_malloc(4 * sizeof(int));
		if (list) {
			list[0] = 60;
			list[1] = 120;
			list[2] = 240;
			list[3] = -1;
		}
		conf->basic_rates = list;

		list = os_malloc(9 * sizeof(int));
		if (list) {
			list[0] = 60;
			list[1] = 90;
			list[2] = 120;
			list[3] = 180;
			list[4] = 240;
			list[5] = 360;
			list[6] = 480;
			list[7] = 540;
			list[8] = -1;
		}
		conf->supported_rates = list;
	}

	bss->isolate = !wpa_s->conf->p2p_intra_bss;
#endif /* CONFIG_P2P */

	if (ssid->ssid_len == 0) {
		wpa_printf(MSG_ERROR, "No SSID configured for AP mode");
		return -1;
	}
	os_memcpy(bss->ssid.ssid, ssid->ssid, ssid->ssid_len);
	bss->ssid.ssid[ssid->ssid_len] = '\0';
	bss->ssid.ssid_len = ssid->ssid_len;
	bss->ssid.ssid_set = 1;

	if (ssid->auth_alg)
		bss->auth_algs = ssid->auth_alg;

	if (wpa_key_mgmt_wpa_psk(ssid->key_mgmt))
		bss->wpa = ssid->proto;
	bss->wpa_key_mgmt = ssid->key_mgmt;
	bss->wpa_pairwise = ssid->pairwise_cipher;
	if (ssid->passphrase) {
		bss->ssid.wpa_passphrase = os_strdup(ssid->passphrase);
	} else if (ssid->psk_set) {
//.........这里部分代码省略.........
开发者ID:avchinch,项目名称:hostap-1,代码行数:101,代码来源:ap.c


示例8: os_strdup

/*-------------------------------------------------------------------------------------*/
char *strsub(const char* input_string, const char* string_to_search, const char* replacement_string)
{
    const char *occurrence_str = NULL;
    char* result_str = NULL;
    char *replacedString = NULL;
    int count = 0, len = 0;

    if (input_string == NULL)
    {
        return NULL;
    }

    if (string_to_search == NULL || replacement_string == NULL)
    {
        return os_strdup(input_string);
    }

    occurrence_str = strstr (input_string, string_to_search);
    if (occurrence_str == NULL)
    {
        return os_strdup(input_string);
    }

    if (strlen (replacement_string) > strlen (string_to_search))
    {
        count = 0;
        len = (int)strlen (string_to_search);
        if (len)
        {
            occurrence_str = input_string;
            while (occurrence_str != NULL && *occurrence_str != '\0')
            {
                occurrence_str = strstr (occurrence_str, string_to_search);
                if (occurrence_str != NULL)
                {
                    occurrence_str += len;
                    count++;
                }
            }
        }
        len = count * ((int)strlen(replacement_string) - (int)strlen(string_to_search)) + (int)strlen(input_string);
    }
    else
    {
        len = (int)strlen(input_string);
    }

    replacedString = (char*)MALLOC (sizeof(char) * (len + 1));
    if (replacedString == NULL)
    {
        return NULL;
    }

    occurrence_str = input_string;
    result_str = replacedString;
    len = (int)strlen (string_to_search);
    while (*occurrence_str != '\0')
    {
        if (*occurrence_str == string_to_search[0] && strncmp (occurrence_str, string_to_search, len) == 0)
        {
            const char *N = NULL;
            N = replacement_string;
            while (*N != '\0')
            {
                *result_str++ = *N++;
            }
            occurrence_str += len;
        }
        else
        {
            *result_str++ = *occurrence_str++;
        }
    }
    *result_str = '\0';

    return replacedString;
}/*-------------------------------------------------------------------------------------*/
开发者ID:leowzukw,项目名称:scilab-mirror,代码行数:78,代码来源:strsubst.c


示例9: eap_peer_select_phase2_methods

/**
 * eap_peer_select_phase2_methods - Select phase 2 EAP method
 * @config: Pointer to the network configuration
 * @prefix: 'phase2' configuration prefix, e.g., "auth="
 * @types: Buffer for returning allocated list of allowed EAP methods
 * @num_types: Buffer for returning number of allocated EAP methods
 * Returns: 0 on success, -1 on failure
 *
 * This function is used to parse EAP method list and select allowed methods
 * for Phase2 authentication.
 */
int eap_peer_select_phase2_methods(struct eap_peer_config *config,
				   const char *prefix,
				   struct eap_method_type **types,
				   size_t *num_types)
{
	char *start, *pos, *buf;
	struct eap_method_type *methods = NULL, *_methods;
	u8 method;
	size_t num_methods = 0, prefix_len;

	if (config == NULL || config->phase2 == NULL)
		goto get_defaults;

	start = buf = os_strdup(config->phase2);
	if (buf == NULL)
		return -1;

	prefix_len = os_strlen(prefix);

	while (start && *start != '\0') {
		int vendor;
		pos = os_strstr(start, prefix);
		if (pos == NULL)
			break;
		if (start != pos && *(pos - 1) != ' ') {
			start = pos + prefix_len;
			continue;
		}

		start = pos + prefix_len;
		pos = os_strchr(start, ' ');
		if (pos)
			*pos++ = '\0';
		method = eap_get_phase2_type(start, &vendor);
		if (vendor == EAP_VENDOR_IETF && method == EAP_TYPE_NONE) {
			wpa_printf(MSG_ERROR, "TLS: Unsupported Phase2 EAP "
				   "method '%s'", start);
		} else {
			num_methods++;
			_methods = os_realloc(methods,
					      num_methods * sizeof(*methods));
			if (_methods == NULL) {
				os_free(methods);
				os_free(buf);
				return -1;
			}
			methods = _methods;
			methods[num_methods - 1].vendor = vendor;
			methods[num_methods - 1].method = method;
		}

		start = pos;
	}

	os_free(buf);

get_defaults:
	if (methods == NULL)
		methods = eap_get_phase2_types(config, &num_methods);

	if (methods == NULL) {
		wpa_printf(MSG_ERROR, "TLS: No Phase2 EAP methods available");
		return -1;
	}
	wpa_hexdump(MSG_DEBUG, "TLS: Phase2 EAP types",
		    (u8 *) methods,
		    num_methods * sizeof(struct eap_method_type));

	*types = methods;
	*num_types = num_methods;

	return 0;
}
开发者ID:Austrie,项目名称:android_external_hostapd,代码行数:84,代码来源:eap_tls_common.c


示例10: FW_Log

/* FW_Log: v0.1, 2005/12/30 */
int FW_Log(Eventinfo *lf)
{
    /* If we don't have the srcip or the
     * action, there is no point in going
     * forward over here
     */
    if(!lf->action || !lf->srcip || !lf->dstip || !lf->srcport ||
       !lf->dstport || !lf->protocol)
    {
        return(0);
    }


    /* Setting the actions */
    switch(*lf->action)
    {
        /* discard, drop, deny, */
        case 'd':
        case 'D':
        /* reject, */
        case 'r':
        case 'R':
        /* block */
        case 'b':
        case 'B':
            os_free(lf->action);
            os_strdup("DROP", lf->action);
            break;
        /* Closed */
        case 'c':
        case 'C':
        /* Teardown */
        case 't':
        case 'T':
            os_free(lf->action);
            os_strdup("CLOSED", lf->action);
            break;
        /* allow, accept, */
        case 'a':
        case 'A':
        /* pass/permitted */
        case 'p':
        case 'P':
        /* open */
        case 'o':
        case 'O':
            os_free(lf->action);
            os_strdup("ALLOW", lf->action);
            break;
        default:
            if(OSMatch_Execute(lf->action,strlen(lf->action),&FWDROPpm))
            {
                os_free(lf->action);
                os_strdup("DROP", lf->action);
            }
            if(OSMatch_Execute(lf->action,strlen(lf->action),&FWALLOWpm))
            {
                os_free(lf->action);
                os_strdup("ALLOW", lf->action);
            }
            else
            {
                os_free(lf->action);
                os_strdup("UNKNOWN", lf->action);
            }
            break;
    }


    /* log to file */
    fprintf(_fflog,
            "%d %s %02d %s %s%s%s %s %s %s:%s->%s:%s\n",
            lf->year,
            lf->mon,
            lf->day,
            lf->hour,
            lf->hostname != lf->location?lf->hostname:"",
            lf->hostname != lf->location?"->":"",
            lf->location,
            lf->action,
            lf->protocol,
            lf->srcip,
            lf->srcport,
            lf->dstip,
            lf->dstport);

    fflush(_fflog);

    return(1);
}
开发者ID:RobertoD91,项目名称:ossec,代码行数:91,代码来源:log.c


示例11: SAJ_FUNCTION

/*
 * Class:     org_opensplice_dds_dcps_FooTypeSupportImpl
 * Method:    jniRegisterType
 * Signature: (Ljava/lang/Object;LDDS/DomainParticipant;Ljava/lang/String;)I
 */
JNIEXPORT jint JNICALL
SAJ_FUNCTION(jniRegisterType) (
    JNIEnv *env,
    jclass object,
    jobject TypeSupport,
    jobject participant,
    jstring type_alias,
    jstring org_pName,
    jstring tgt_pName)
{
    const char *typeAlias;
    const char *typeName;
    const os_char* tmp;
    os_char* orgPName;
    os_char* tgtPName;
    jint result;
    jclass typeSupportClass;
    jfieldID copyCache_fid;
    c_metaObject typeMeta;
    saj_copyCache copyCache;

    /* Convert type_alias */
    if (type_alias != NULL) {
        typeAlias = (*env)->GetStringUTFChars (env, type_alias, 0);
    }  else {
        typeAlias = NULL;
    }
    if (org_pName != NULL) {
        tmp = (*env)->GetStringUTFChars (env, org_pName, 0);
        if(0 == strcmp(tmp, "null"))
        {
            orgPName = NULL;
        } else
        {
            orgPName = os_strdup(tmp);
        }
        (*env)->ReleaseStringUTFChars (env, org_pName, tmp);
    }  else {
        orgPName = NULL;
    }
    if (tgt_pName != NULL) {
        tmp = (*env)->GetStringUTFChars (env, tgt_pName, 0);
        if(0 == strcmp(tmp, "null"))
        {
            tgtPName = NULL;
        } else
        {
            tgtPName = os_strdup(tmp);
        }
        (*env)->ReleaseStringUTFChars (env, tgt_pName, tmp);
    }  else {
        tgtPName = NULL;
    }

    /* Call GAPI register type function */
    result = gapi_fooTypeSupport_register_type (
            	(gapi_fooTypeSupport)saj_read_gapi_address (env, TypeSupport),
            	(gapi_domainParticipant)saj_read_gapi_address (env, participant),
            	(gapi_string)typeAlias);
    if (result == GAPI_RETCODE_OK) {
    	typeName = gapi_typeSupport_get_type_name ((gapi_typeSupport)saj_read_gapi_address (env, TypeSupport));
    	typeMeta = (c_metaObject)gapi_domainParticipant_get_type_metadescription (
	    (gapi_domainParticipant)saj_read_gapi_address (env, participant), typeName);

    	if (typeMeta) {
    	    copyCache = saj_copyCacheNew (env, typeMeta, orgPName, tgtPName);
    	    if (copyCache) {
    	        typeSupportClass = (*env)->GetObjectClass (env, TypeSupport);
    		copyCache_fid = (*env)->GetFieldID (env, typeSupportClass, "copyCache", "J");
    		(*env)->SetLongField (env, TypeSupport, copyCache_fid, (jlong)(PA_ADDRCAST)copyCache);
    	    } else {
    	        result = GAPI_RETCODE_ERROR;
    	    }
    	} else {
    	    result = GAPI_RETCODE_ERROR;
    	}
    }
    /* Release used strings */
    if (typeAlias != NULL) {
        (*env)->ReleaseStringUTFChars (env, type_alias, typeAlias);
    }
    if(tgtPName)
    {
        os_free(tgtPName);
    }
    if(orgPName)
    {
        os_free(orgPName);
    }

    return (jint)result;
}
开发者ID:xrl,项目名称:opensplice_dds,代码行数:97,代码来源:saj_fooTypeSupport.c


示例12: os_rel2abs_path

char * os_rel2abs_path(const char *rel_path)
{
	return os_strdup(rel_path);
	//return NULL; /* strdup(rel_path) can be used here */
}
开发者ID:LucidOne,项目名称:Rovio,代码行数:5,代码来源:os_ecos.c


示例13: FillEvent

void FillEvent(Eventinfo *lf, const char *f_name, const SyscheckSum *sum) {
    os_strdup(f_name, lf->filename);
    os_strdup(sum->size, lf->size_after);
    lf->perm_after = sum->perm;
    os_strdup(sum->uid, lf->owner_after);
    os_strdup(sum->gid, lf->gowner_after);
    os_strdup(sum->md5, lf->md5_after);
    os_strdup(sum->sha1, lf->sha1_after);

    if (sum->uname)
        os_strdup(sum->uname, lf->uname_after);

    if (sum->gname)
        os_strdup(sum->gname, lf->gname_after);

    lf->mtime_after = sum->mtime;
    lf->inode_after = sum->inode;

    /* Fields */
    os_strdup(f_name, lf->fields[SCK_FILE]);
    os_strdup(sum->size, lf->fields[SCK_SIZE]);
    os_calloc(7, sizeof(char), lf->fields[SCK_PERM]);
    snprintf(lf->fields[SCK_PERM], 7, "%06o", sum->perm);
    os_strdup(sum->uid, lf->fields[SCK_UID]);
    os_strdup(sum->gid, lf->fields[SCK_GID]);
    os_strdup(sum->md5, lf->fields[SCK_MD5]);
    os_strdup(sum->sha1, lf->fields[SCK_SHA1]);

    if (sum->uname)
        os_strdup(sum->uname, lf->fields[SCK_UNAME]);

    if (sum->gname)
        os_strdup(sum->gname, lf->fields[SCK_GNAME]);

    if (sum->inode) {
        os_calloc(20, sizeof(char), lf->fields[SCK_INODE]);
        snprintf(lf->fields[SCK_INODE], 20, "%ld", sum->inode);
    }
}
开发者ID:Cryptophobia,项目名称:ossec-wazuh,代码行数:39,代码来源:syscheck.c


示例14: ut_dirOutNew

os_int32
ut_dirOutNew(
    const os_char *name)
{
    os_int32 result;
    os_result status;
    char dirName[OS_PATH_MAX];
    struct os_stat statBuf;
    os_uint32 i;

    memset(dirName, 0, OS_PATH_MAX);

    if (name) {
        result = 1;

        for (i = 0; i < strlen(name) && result; i++) {
            if ((name[i] == OS_FILESEPCHAR) && (i != 0)) {
                status = os_stat(dirName, &statBuf);

                if (status != os_resultSuccess) {
                    os_mkdir(dirName, S_IRWXU | S_IRWXG | S_IRWXO);
                    status = os_stat(dirName, &statBuf);
                }
                if (!OS_ISDIR (statBuf.stat_mode)) {
#ifdef WIN32
                    if ((strlen(dirName) == 2) && (dirName[1] == ':')) {
                        /*This is a device like for instance: 'C:'*/
                    } else {
                        printf("'%s' is not a directory\n", dirName);
                        result = 0;
                        ut_outputdir = NULL;
                    }
#else
                    printf("'%s' is not a directory\n", dirName);
                    result = 0;
                    ut_outputdir = NULL;
#endif
                }
            }
            dirName[i] = name[i];
        }
        if (result) {
            if (dirName[i-1] != OS_FILESEPCHAR) {
                status = os_stat(dirName, &statBuf);

                if (status != os_resultSuccess) {
                    os_mkdir(dirName, S_IRWXU | S_IRWXG | S_IRWXO);
                    status = os_stat(dirName, &statBuf);
                }
                ut_outputdir = os_strdup(name);

                if (!OS_ISDIR(statBuf.stat_mode)) {
#ifdef WIN32
                    if ((strlen(dirName) == 2) && (dirName[1] == ':')) {
                        /*This is a device like for instance: 'C:'. Check if it exists...*/
                        dirName[2] = OS_FILESEPCHAR;
                        status = os_stat(dirName, &statBuf);

                        if (status == os_resultFail) {
                            printf("'%s' is not available", dirName);
                            result = 0;
                            ut_outputdir = NULL;
                        }
                    } else {
                        printf("'%s' is not a directory.\n", ut_outputdir);
                        result = 0;
                        ut_outputdir = NULL;
                    }
#else
                    printf("'%s' is not a directory\n", dirName);
                    result = 0;
                    ut_outputdir = NULL;
#endif
                }
            } else {
                ut_outputdir = (os_char *)os_malloc(strlen(name)+1);
                snprintf(ut_outputdir, strlen(name), "%s", name);
            }
        }
    } else {
        result = 0;
        ut_outputdir = NULL;
    }

    if (result) {
        status = os_access(ut_outputdir, 2); /* Check whether dir is writable */

        if (status != os_resultSuccess) {
#ifdef WIN32
            if ((strlen(dirName) == 2) && (dirName[1] == ':')) {
                /*This is a device like for instance: 'C:'. Check if it exists...*/
                dirName[2] = OS_FILESEPCHAR;
                status = os_stat(dirName, &statBuf);

                if (status == os_resultFail) {
                    printf("'%s' cannot be found", dirName);
                    result = 0;
                    ut_outputdir = NULL;
                }
            } else {
//.........这里部分代码省略.........
开发者ID:fville,项目名称:opensplice,代码行数:101,代码来源:ut_tmplExp.c


示例15: eapol_auth_conf_clone

static int eapol_auth_conf_clone(struct eapol_auth_config *dst,
				 struct eapol_auth_config *src)
{
	dst->ctx = src->ctx;
	dst->eap_reauth_period = src->eap_reauth_period;
	dst->wpa = src->wpa;
	dst->individual_wep_key_len = src->individual_wep_key_len;
	dst->eap_server = src->eap_server;
	dst->ssl_ctx = src->ssl_ctx;
	dst->msg_ctx = src->msg_ctx;
	dst->eap_sim_db_priv = src->eap_sim_db_priv;
	os_free(dst->eap_req_id_text);
	dst->pwd_group = src->pwd_group;
	dst->pbc_in_m1 = src->pbc_in_m1;
	dst->server_id = src->server_id;
	dst->server_id_len = src->server_id_len;
	if (src->eap_req_id_text) {
		dst->eap_req_id_text = os_malloc(src->eap_req_id_text_len);
		if (dst->eap_req_id_text == NULL)
			return -1;
		os_memcpy(dst->eap_req_id_text, src->eap_req_id_text,
			  src->eap_req_id_text_len);
		dst->eap_req_id_text_len = src->eap_req_id_text_len;
	} else {
		dst->eap_req_id_text = NULL;
		dst->eap_req_id_text_len = 0;
	}
	if (src->pac_opaque_encr_key) {
		dst->pac_opaque_encr_key = os_malloc(16);
		if (dst->pac_opaque_encr_key == NULL)
			goto fail;
		os_memcpy(dst->pac_opaque_encr_key, src->pac_opaque_encr_key,
			  16);
	} else
		dst->pac_opaque_encr_key = NULL;
	if (src->eap_fast_a_id) {
		dst->eap_fast_a_id = os_malloc(src->eap_fast_a_id_len);
		if (dst->eap_fast_a_id == NULL)
			goto fail;
		os_memcpy(dst->eap_fast_a_id, src->eap_fast_a_id,
			  src->eap_fast_a_id_len);
		dst->eap_fast_a_id_len = src->eap_fast_a_id_len;
	} else
		dst->eap_fast_a_id = NULL;
	if (src->eap_fast_a_id_info) {
		dst->eap_fast_a_id_info = os_strdup(src->eap_fast_a_id_info);
		if (dst->eap_fast_a_id_info == NULL)
			goto fail;
	} else
		dst->eap_fast_a_id_info = NULL;
	dst->eap_fast_prov = src->eap_fast_prov;
	dst->pac_key_lifetime = src->pac_key_lifetime;
	dst->pac_key_refresh_time = src->pac_key_refresh_time;
	dst->eap_sim_aka_result_ind = src->eap_sim_aka_result_ind;
	dst->tnc = src->tnc;
	dst->wps = src->wps;
	dst->fragment_size = src->fragment_size;

	os_free(dst->erp_domain);
	if (src->erp_domain) {
		dst->erp_domain = os_strdup(src->erp_domain);
		if (dst->erp_domain == NULL)
			goto fail;
	} else {
		dst->erp_domain = NULL;
	}
	dst->erp_send_reauth_start = src->erp_send_reauth_start;
	dst->erp = src->erp;

	return 0;

fail:
	eapol_auth_conf_free(dst);
	return -1;
}
开发者ID:NAM-IL,项目名称:HostAP_2_4,代码行数:75,代码来源:eapol_auth_sm.c


示例16: OS_CleanMSG

/* OS_CleanMSG v0.3: 2006/03/04
 * Format a received message in the
 * Eventinfo structure.
 */
int OS_CleanMSG(char *msg, Eventinfo *lf)
{
    int loglen;
    char *pieces;
    struct tm *p;

    /* The message is formated in the following way:
     * id:location:message.
     */


    /*  Ignoring the id of the message in here */
    msg+=2;



    /* Setting pieces as the message */
    pieces = strchr(msg, ':');
    if(!pieces)
    {
        merror(FORMAT_ERROR, ARGV0);
        return(-1);
    }

    *pieces = '\0';
    pieces++;


    os_strdup(msg, lf->location);


    /* Getting the log length */
    loglen = strlen(pieces) + 1;


    /* Assigning the values in the strucuture (lf->full_log) */
    os_malloc((2*loglen) +1, lf->full_log);


    /* Setting the whole message at full_log */
    strncpy(lf->full_log, pieces, loglen);


    /* Log is the one used for parsing in the decoders and rules */
    lf->log = lf->full_log+loglen;
    strncpy(lf->log, pieces, loglen);

    /* check if month contains an umlaut and repair
     * umlaute are non-ASCII and use 2 slots in the char array
     * repair to only one slot so we can detect the correct date format in the next step
     * ex: Mär 02 17:30:52
     */
    if (pieces[1] == (char) 195) {
        if (pieces[2] == (char) 164) {
            pieces[0] = '\0';
            pieces[1] = 'M';
            pieces[2] = 'a';
            pieces++;
        }
    }

    /* Checking for the syslog date format.
     * ( ex: Dec 29 10:00:01
     *   or  2007-06-14T15:48:55-04:00 for syslog-ng isodate
     *   or  2009-05-22T09:36:46.214994-07:00 for rsyslog )
     */
    if(
        (
        (loglen > 17) &&
        (pieces[3] == ' ') &&
        (pieces[6] == ' ') &&
        (pieces[9] == ':') &&
        (pieces[12] == ':') &&
        (pieces[15] == ' ') && (lf->log+=16)
        )
        ||
        (
        (loglen > 33) &&
        (pieces[4] == '-') &&
        (pieces[7] == '-') &&
        (pieces[10] == 'T') &&
        (pieces[13] == ':') &&
        (pieces[16] == ':') &&

        (
         ((pieces[22] == ':') &&
          (pieces[25] == ' ') && (lf->log+=26)) ||

         ((pieces[19] == '.') &&
          (pieces[29] == ':') && (lf->log+=32))
        )

        )
      )
    {
        /* Checking for an extra space in here */
//.........这里部分代码省略.........
开发者ID:Ar0xA,项目名称:ossec-hids,代码行数:101,代码来源:cleanevent.c


示例17: eapol_auth_alloc

struct eapol_state_machine *
eapol_auth_alloc(struct eapol_authenticator *eapol, const u8 *addr,
		 int flags, const struct wpabuf *assoc_wps_ie,
		 const struct wpabuf *assoc_p2p_ie, void *sta_ctx,
		 const char *identity, const char *radius_cui)
{
	struct eapol_state_machine *sm;
	struct eap_config eap_conf;

	if (eapol == NULL)
		return NULL;

	sm = os_zalloc(sizeof(*sm));
	if (sm == NULL) {
		wpa_printf(MSG_DEBUG, "IEEE 802.1X state machine allocation "
			   "failed");
		return NULL;
	}
	sm->radius_identifier = -1;
	os_memcpy(sm->addr, addr, ETH_ALEN);
	sm->flags = flags;

	sm->eapol = eapol;
	sm->sta = sta_ctx;

	/* Set default values for state machine constants */
	sm->auth_pae_state = AUTH_PAE_INITIALIZE;
	sm->quietPeriod = AUTH_PAE_DEFAULT_quietPeriod;
	sm->reAuthMax = AUTH_PAE_DEFAULT_reAuthMax;

	sm->be_auth_state = BE_AUTH_INITIALIZE;
	sm->serverTimeout = BE_AUTH_DEFAULT_serverTimeout;

	sm->reauth_timer_state = REAUTH_TIMER_INITIALIZE;
	sm->reAuthPeriod = eapol->conf.eap_reauth_period;
	sm->reAuthEnabled = eapol->conf.eap_reauth_period > 0 ? TRUE : FALSE;

	sm->auth_key_tx_state = AUTH_KEY_TX_NO_KEY_TRANSMIT;

	sm->key_rx_state = KEY_RX_NO_KEY_RECEIVE;

	sm->ctrl_dir_state = CTRL_DIR_IN_OR_BOTH;

	sm->portControl = Auto;

	if (!eapol->conf.wpa &&
	    (eapol->default_wep_key || eapol->conf.individual_wep_key_len > 0))
		sm->keyTxEnabled = TRUE;
	else
		sm->keyTxEnabled = FALSE;
	if (eapol->conf.wpa)
		sm->portValid = FALSE;
	else
		sm->portValid = TRUE;

	os_memset(&eap_conf, 0, sizeof(eap_conf));
	eap_conf.eap_server = eapol->conf.eap_server;
	eap_conf.ssl_ctx = eapol->conf.ssl_ctx;
	eap_conf.msg_ctx = eapol->conf.msg_ctx;
	eap_conf.eap_sim_db_priv = eapol->conf.eap_sim_db_priv;
	eap_conf.pac_opaque_encr_key = eapol->conf.pac_opaque_encr_key;
	eap_conf.eap_fast_a_id = eapol->conf.eap_fast_a_id;
	eap_conf.eap_fast_a_id_len = eapol->conf.eap_fast_a_id_len;
	eap_conf.eap_fast_a_id_info = eapol->conf.eap_fast_a_id_info;
	eap_conf.eap_fast_prov = eapol->conf.eap_fast_prov;
	eap_conf.pac_key_lifetime = eapol->conf.pac_key_lifetime;
	eap_conf.pac_key_refresh_time = eapol->conf.pac_key_refresh_time;
	eap_conf.eap_sim_aka_result_ind = eapol->conf.eap_sim_aka_result_ind;
	eap_conf.tnc = eapol->conf.tnc;
	eap_conf.wps = eapol->conf.wps;
	eap_conf.assoc_wps_ie = assoc_wps_ie;
	eap_conf.assoc_p2p_ie = assoc_p2p_ie;
	eap_conf.peer_addr = addr;
	eap_conf.fragment_size = eapol->conf.fragment_size;
	eap_conf.pwd_group = eapol->conf.pwd_group;
	eap_conf.pbc_in_m1 = eapol->conf.pbc_in_m1;
	eap_conf.server_id = eapol->conf.server_id;
	eap_conf.server_id_len = eapol->conf.server_id_len;
	eap_conf.erp = eapol->conf.erp;
	sm->eap = eap_server_sm_init(sm, &eapol_cb, &eap_conf);
	if (sm->eap == NULL) {
		eapol_auth_free(sm);
		return NULL;
	}
	sm->eap_if = eap_get_interface(sm->eap);

	eapol_auth_initialize(sm);

	if (identity) {
		sm->identity = (u8 *) os_strdup(identity);
		if (sm->identity)
			sm->identity_len = os_strlen(identity);
	}
	if (radius_cui)
		sm->radius_cui = wpabuf_alloc_copy(radius_cui,
						   os_strlen(radius_cui));

	sm->acct_multi_session_id_lo = eapol->acct_multi_session_id_lo++;
	if (eapol->acct_multi_session_id_lo == 0)
		eapol->acct_multi_session_id_hi++;
//.........这里部分代码省略.........
开发者ID:NAM-IL,项目名称:HostAP_2_4,代码行数:101,代码来源:eapol_auth_sm.c


示例18: wpa_config_read

struct wpa_config * wpa_conf 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ os_strncmp函数代码示例发布时间:2022-05-30
下一篇:
C++ os_strcpy函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap