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

C++ os_strncmp函数代码示例

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

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



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

示例1: httpdProcessRequest

//This is called when the headers have been received and the connection is ready to send
//the result headers and data.
//We need to find the CGI function to call, call it, and dependent on what it returns either
//find the next cgi function, wait till the cgi data is sent or close up the connection.
static void ICACHE_FLASH_ATTR httpdProcessRequest(HttpdConnData *conn) {
	int r;
	int i=0;
	if (conn->url==NULL) {
		os_printf("WtF? url = NULL\n");
		return; //Shouldn't happen
	}
	//See if we can find a CGI that's happy to handle the request.
	while (1) {
		//Look up URL in the built-in URL table.
		while (builtInUrls[i].url!=NULL) {
			int match=0;
			//See if there's a literal match
			if (os_strcmp(builtInUrls[i].url, conn->url)==0) match=1;
			//See if there's a wildcard match
			if (builtInUrls[i].url[os_strlen(builtInUrls[i].url)-1]=='*' &&
					os_strncmp(builtInUrls[i].url, conn->url, os_strlen(builtInUrls[i].url)-1)==0) match=1;
			if (match) {
				os_printf("Is url index %d\n", i);
				conn->cgiData=NULL;
				conn->cgi=builtInUrls[i].cgiCb;
				conn->cgiArg=builtInUrls[i].cgiArg;
				break;
			}
			i++;
		}
		if (builtInUrls[i].url==NULL) {
			//Drat, we're at the end of the URL table. This usually shouldn't happen. Well, just
			//generate a built-in 404 to handle this.
			os_printf("%s not found. 404!\n", conn->url);
			httpdSend(conn, httpNotFoundHeader, -1);
			xmitSendBuff(conn);
			conn->cgi=NULL; //mark for destruction
			return;
		}
		
		//Okay, we have a CGI function that matches the URL. See if it wants to handle the
		//particular URL we're supposed to handle.
		r=conn->cgi(conn);
		if (r==HTTPD_CGI_MORE) {
			//Yep, it's happy to do so and has more data to send.
			xmitSendBuff(conn);
			return;
		} else if (r==HTTPD_CGI_DONE) {
			//Yep, it's happy to do so and already is done sending data.
			xmitSendBuff(conn);
			conn->cgi=NULL; //mark conn for destruction
			return;
		} else if (r==HTTPD_CGI_NOTFOUND || r==HTTPD_CGI_AUTHENTICATED) {
			//URL doesn't want to handle the request: either the data isn't found or there's no
			//need to generate a login screen.
			i++; //look at next url the next iteration of the loop.
		}
	}
}
开发者ID:surovtsev,项目名称:ESP8266_Relay_Board_FlowController,代码行数:59,代码来源:httpd.c


示例2: start_resolve_dh_server

LOCAL void ICACHE_FLASH_ATTR start_resolve_dh_server() {
	static ip_addr_t ip;
	const char *server = dhrequest_current_server();
	char host[os_strlen(server) + 1];
	const char *fr = server;
	while(*fr != ':') {
		fr++;
		if(*fr == 0) {
			fr = 0;
			break;
		}
	}
	if(fr) {
		fr++;
		if(*fr != '/')
			fr = 0;
	}
	if (fr) {
		while (*fr == '/')
			fr++;
		int i = 0;
		while (*fr != '/' && *fr != ':' && *fr != 0)
			host[i++] = *fr++;
		// read port if present
		int port = 0;
		if(*fr == ':') {
			unsigned char d;
			fr++;
			while ( (d = *fr - 0x30) < 10) {
				fr++;
				port = port*10 + d;
				if(port > 0xFFFF)
					break;
			}
		}
		if(port && port < 0xFFFF)
			mDHConnector.proto.tcp->remote_port = port;
		else if (os_strncmp(dhrequest_current_server(), "https", 5) == 0)
			mDHConnector.proto.tcp->remote_port = 443; // HTTPS default port
		else
			mDHConnector.proto.tcp->remote_port = 80; //HTTP default port
		host[i] = 0;
		dhdebug("Resolving %s", host);
		err_t r = espconn_gethostbyname(&mDHConnector, host, &ip, resolve_cb);
		if(r == ESPCONN_OK) {
			resolve_cb(host, &ip, NULL);
		} else if(r != ESPCONN_INPROGRESS) {
			dhesperrors_espconn_result("Resolving failed:", r);
			arm_repeat_timer(RETRY_CONNECTION_INTERVAL_MS);
		}
	} else {
		dhdebug("Can not find scheme in server url");
	}
}
开发者ID:AntonioSolanoTarroc,项目名称:esp8266-firmware,代码行数:54,代码来源:dhconnector.c


示例3: os_strstr

char * os_strstr(const char *haystack, const char *needle)
{
	size_t len = os_strlen(needle);
	while (*haystack) {
		if (os_strncmp(haystack, needle, len) == 0)
			return (char *) haystack;
		haystack++;
	}

	return NULL;
}
开发者ID:ECYBTech,项目名称:chanos,代码行数:11,代码来源:os_internal.c


示例4: eap_sim_db_open_socket

static int eap_sim_db_open_socket(struct eap_sim_db_data *data)
{
	struct sockaddr_un addr;
	static int counter = 0;

	if (os_strncmp(data->fname, "unix:", 5) != 0)
		return -1;

	data->sock = socket(PF_UNIX, SOCK_DGRAM, 0);
	if (data->sock < 0) {
		wpa_printf(MSG_INFO, "socket(eap_sim_db): %s", strerror(errno));
		return -1;
	}

	os_memset(&addr, 0, sizeof(addr));
	addr.sun_family = AF_UNIX;
	os_snprintf(addr.sun_path, sizeof(addr.sun_path),
		    "/tmp/eap_sim_db_%d-%d", getpid(), counter++);
	os_free(data->local_sock);
	data->local_sock = os_strdup(addr.sun_path);
	if (data->local_sock == NULL) {
		close(data->sock);
		data->sock = -1;
		return -1;
	}
	if (bind(data->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
		wpa_printf(MSG_INFO, "bind(eap_sim_db): %s", strerror(errno));
		close(data->sock);
		data->sock = -1;
		return -1;
	}

	os_memset(&addr, 0, sizeof(addr));
	addr.sun_family = AF_UNIX;
	os_strlcpy(addr.sun_path, data->fname + 5, sizeof(addr.sun_path));
	if (connect(data->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
		wpa_printf(MSG_INFO, "connect(eap_sim_db): %s",
			   strerror(errno));
		wpa_hexdump_ascii(MSG_INFO, "HLR/AuC GW socket",
				  (u8 *) addr.sun_path,
				  os_strlen(addr.sun_path));
		close(data->sock);
		data->sock = -1;
		unlink(data->local_sock);
		os_free(data->local_sock);
		data->local_sock = NULL;
		return -1;
	}

	eloop_register_read_sock(data->sock, eap_sim_db_receive, data, NULL);

	return 0;
}
开发者ID:9A9A,项目名称:wpa_supplicant-fork,代码行数:53,代码来源:eap_sim_db.c


示例5: tcpserver_recv_callback

static void ICACHE_FLASH_ATTR
tcpserver_recv_callback(void *arg, char *pdata, uint16_t length)
{
    if(os_strncmp(OTA_UPGRADE_COMMAND, pdata, length) == 0)
    {
        remot_info *phost_info = NULL;

        os_printf("Upgrade command received.\r\n");
        espconn_get_connection_info(&tcp_server, &phost_info, 0);
        ota_upgrade(phost_info);
    }
}
开发者ID:thuSkywalker,项目名称:esp8266-ptpd,代码行数:12,代码来源:tcp_server.c


示例6: wpa_supplicant_ctrl_iface_blacklist

static int wpa_supplicant_ctrl_iface_blacklist(
		struct wpa_supplicant *wpa_s, char *cmd, char *buf, size_t buflen)
{
	struct wpa_ssid *ssid;
	u8 bssid[ETH_ALEN];
	struct wpa_blacklist *e;
	char *pos, *end;
	int ret;

	/* cmd: "BLACKLIST [<BSSID>]" */
	if (*cmd == '\0') {
		pos = buf;
		end = buf + buflen;

		e = wpa_s->blacklist;
		while (e) {
			ret = os_snprintf(pos, end-pos,
					  "%02x:%02x:%02x:%02x:%02x:%02x\n",
					  e->bssid[0],
					  e->bssid[1],
					  e->bssid[2],
					  e->bssid[3],
					  e->bssid[4],
					  e->bssid[5]);
			if (ret < 0 || ret >= end - pos)
				return pos - buf;
			pos += ret;
			e = e->next;
		}
		return pos - buf;
	}
	wpa_printf(MSG_DEBUG, "CTRL_IFACE: bssid='%s'", cmd);

	++cmd;
	if (os_strncmp(cmd, "clear", 5) == 0) {
		wpa_blacklist_clear(wpa_s);
		return 0;
	}

	if (hwaddr_aton(cmd, bssid)) {
		wpa_printf(MSG_DEBUG ,"CTRL_IFACE: invalid BSSID '%s'", cmd);
		return -1;
	}

	/*
	 * Add the BSSID twice, so its count will be 2, causing it to be
	 * skipped when processing scan results.
	 */
	ret = wpa_blacklist_add(wpa_s, bssid);
	if (ret != 0)
		return ret;
	return wpa_blacklist_add(wpa_s, bssid);
}
开发者ID:mrtos,项目名称:Logitech-Revue,代码行数:53,代码来源:ctrl_iface.c


示例7: user_udp_recv

LOCAL void ICACHE_FLASH_ATTR
user_udp_recv(void *arg, char *pusrdata, unsigned short length)
{
	char DeviceBuffer[40] = { 0 };
	char Device_mac_buffer[60] = { 0 };
	char hwaddr[6];

	struct ip_info ipconfig;

	if (wifi_get_opmode() != STATION_MODE) {
		wifi_get_ip_info(SOFTAP_IF, &ipconfig);
		wifi_get_macaddr(SOFTAP_IF, hwaddr);

		if (!ip_addr_netcmp
		    ((struct ip_addr *)ptrespconn.proto.udp->remote_ip,
		     &ipconfig.ip, &ipconfig.netmask)) {
			//udp packet is received from ESP8266 station
			wifi_get_ip_info(STATION_IF, &ipconfig);
			wifi_get_macaddr(STATION_IF, hwaddr);
		} else {
			//udp packet is received from ESP8266 softAP
		}

	} else {
		//udp packet is received from ESP8266 station
		wifi_get_ip_info(STATION_IF, &ipconfig);
		wifi_get_macaddr(STATION_IF, hwaddr);
	}

	if (pusrdata == NULL)
		return;

	if (length == os_strlen(device_find_request) &&
	    os_strncmp(pusrdata, device_find_request,
		       os_strlen(device_find_request)) == 0) {
		//received device find message

		os_sprintf(DeviceBuffer, "%s" MACSTR " " IPSTR,
			   device_find_response_ok, MAC2STR(hwaddr),
			   IP2STR(&ipconfig.ip));

		os_printf("%s\n", DeviceBuffer);
		length = os_strlen(DeviceBuffer);

		//if received "Are You ESP8266 ?" ,
		//response "Yes,I'm ESP8266!" + ESP8266 mac + ESP8266 ip
		espconn_sent(&ptrespconn, DeviceBuffer, length);

	} else {
		//received some other data
	}

}
开发者ID:fernandomorse,项目名称:noduino-sdk,代码行数:53,代码来源:user_main.c


示例8: p2p_wfa_service_adv

static int p2p_wfa_service_adv(struct p2p_data *p2p)
{
	struct p2ps_advertisement *adv;

	for (adv = p2p->p2ps_adv_list; adv; adv = adv->next) {
		if (os_strncmp(adv->svc_name, P2PS_WILD_HASH_STR,
			       os_strlen(P2PS_WILD_HASH_STR)) == 0)
			return 1;
	}

	return 0;
}
开发者ID:priyaanna,项目名称:wpa_supplicant_8,代码行数:12,代码来源:p2p_build.c


示例9: httpdParseHeader

static void ICACHE_FLASH_ATTR httpdParseHeader(char *h, HttpdConnData *conn) {
	int i;
	char first_line = false;

	if (os_strncmp(h, "GET ", 4)==0) {
		conn->requestType = HTTPD_METHOD_GET;
		first_line = true;
	} else if (os_strncmp(h, "Host:", 5)==0) {
		i=5;
		while (h[i]==' ') i++;
		conn->hostName=&h[i];
	} else if (os_strncmp(h, "POST ", 5)==0) {
		conn->requestType = HTTPD_METHOD_POST;
		first_line = true;
	}

	if (first_line) {
		char *e;

		//Skip past the space after POST/GET
		i=0;
		while (h[i]!=' ') i++;
		conn->url=h+i+1;

		//Figure out end of url.
		e=(char*)os_strstr(conn->url, " ");
		if (e==NULL) return; // ?
		*e=0; //terminate url part

		//Parse out the URL part before the GET parameters.
		conn->getArgs=(char*)os_strstr(conn->url, "?");
		if (conn->getArgs!=0) {
			*conn->getArgs=0;
			conn->getArgs++;
			TESTP("GET args = %s\n", conn->getArgs);
		} else {
			conn->getArgs=NULL;
		}
	}
}
开发者ID:Daven005,项目名称:ESP8266,代码行数:40,代码来源:http.c


示例10: httpdParseHeader

//Parse a line of header data and modify the connection data accordingly.
static void ICACHE_FLASH_ATTR httpdParseHeader(char *h, HttpdConnData *conn) {
	int i;
//	os_printf("Got header %s\n", h);
	if (os_strncmp(h, "GET ", 4)==0 || os_strncmp(h, "POST ", 5)==0) {
		char *e;
		
		//Skip past the space after POST/GET
		i=0;
		while (h[i]!=' ') i++;
		conn->url=h+i+1;

		//Figure out end of url.
		e=(char*)os_strstr(conn->url, " ");
		if (e==NULL) return; //wtf?
		*e=0; //terminate url part

		os_printf("URL = %s\n", conn->url);
		//Parse out the URL part before the GET parameters.
		conn->getArgs=(char*)os_strstr(conn->url, "?");
		if (conn->getArgs!=0) {
			*conn->getArgs=0;
			conn->getArgs++;
			os_printf("GET args = %s\n", conn->getArgs);
		} else {
			conn->getArgs=NULL;
		}
	} else if (os_strncmp(h, "Content-Length: ", 16)==0) {
		i=0;
		//Skip trailing spaces
		while (h[i]!=' ') i++;
		//Get POST data length
		conn->postLen=atoi(h+i+1);
		//Clamp if too big. Hmm, maybe we should error out instead?
		if (conn->postLen>MAX_POST) conn->postLen=MAX_POST;
		os_printf("Mallocced buffer for %d bytes of post data.\n", conn->postLen);
		//Alloc the memory.
		conn->postBuff=(char*)os_malloc(conn->postLen+1);
		conn->priv->postPos=0;
	}
}
开发者ID:electrik0150,项目名称:kitchen_experiments,代码行数:41,代码来源:httpd.c


示例11: wpas_dbus_new_decompose_object_path

/**
 * wpas_dbus_new_decompose_object_path - Decompose an interface object path into parts
 * @path: The dbus object path
 * @sep: Separating part (e.g., "Networks" or "PersistentGroups")
 * @item: (out) The part following the specified separator, if any
 * Returns: The object path of the interface this path refers to
 *
 * For a given object path, decomposes the object path into object id and
 * requested part, if those parts exist. The caller is responsible for freeing
 * the returned value. The *item pointer points to that allocated value and must
 * not be freed separately.
 *
 * As an example, path = "/fi/w1/wpa_supplicant1/Interfaces/1/Networks/0" and
 * sep = "Networks" would result in "/fi/w1/wpa_supplicant1/Interfaces/1"
 * getting returned and *items set to point to "0".
 */
char * wpas_dbus_new_decompose_object_path(const char *path, const char *sep,
					   char **item)
{
	const unsigned int dev_path_prefix_len =
		os_strlen(WPAS_DBUS_NEW_PATH_INTERFACES "/");
	char *obj_path_only;
	char *pos;
	size_t sep_len;

	*item = NULL;

	/* Verify that this starts with our interface prefix */
	if (os_strncmp(path, WPAS_DBUS_NEW_PATH_INTERFACES "/",
		       dev_path_prefix_len) != 0)
		return NULL; /* not our path */

	/* Ensure there's something at the end of the path */
	if ((path + dev_path_prefix_len)[0] == '\0')
		return NULL;

	obj_path_only = os_strdup(path);
	if (obj_path_only == NULL)
		return NULL;

	pos = obj_path_only + dev_path_prefix_len;
	pos = os_strchr(pos, '/');
	if (pos == NULL)
		return obj_path_only; /* no next item on the path */

	 /* Separate network interface prefix from the path */
	*pos++ = '\0';

	sep_len = os_strlen(sep);
	if (os_strncmp(pos, sep, sep_len) != 0 || pos[sep_len] != '/')
		return obj_path_only; /* no match */

	 /* return a pointer to the requested item */
	*item = pos + sep_len + 1;
	return obj_path_only;
}
开发者ID:Hansenq,项目名称:wifi-goes-to-town,代码行数:56,代码来源:dbus_new_helpers.c


示例12: eap_sim_ext_sim_result

static int eap_sim_ext_sim_result(struct eap_sm *sm, struct eap_sim_data *data,
				  struct eap_peer_config *conf)
{
	char *resp, *pos;
	size_t i;

	wpa_printf(MSG_DEBUG,
		   "EAP-SIM: Use result from external SIM processing");

	resp = conf->external_sim_resp;
	conf->external_sim_resp = NULL;

	if (os_strncmp(resp, "GSM-AUTH:", 9) != 0) {
		wpa_printf(MSG_DEBUG, "EAP-SIM: Unrecognized external SIM processing response");
		os_free(resp);
		return -1;
	}

	pos = resp + 9;
	for (i = 0; i < data->num_chal; i++) {
		wpa_hexdump(MSG_DEBUG, "EAP-SIM: RAND",
			    data->rand[i], GSM_RAND_LEN);

		if (hexstr2bin(pos, data->kc[i], EAP_SIM_KC_LEN) < 0)
			goto invalid;
		wpa_hexdump_key(MSG_DEBUG, "EAP-SIM: Kc",
				data->kc[i], EAP_SIM_KC_LEN);
		pos += EAP_SIM_KC_LEN * 2;
		if (*pos != ':')
			goto invalid;
		pos++;

		if (hexstr2bin(pos, data->sres[i], EAP_SIM_SRES_LEN) < 0)
			goto invalid;
		wpa_hexdump_key(MSG_DEBUG, "EAP-SIM: SRES",
				data->sres[i], EAP_SIM_SRES_LEN);
		pos += EAP_SIM_SRES_LEN * 2;
		if (i + 1 < data->num_chal) {
			if (*pos != ':')
				goto invalid;
			pos++;
		}
	}

	os_free(resp);
	return 0;

invalid:
	wpa_printf(MSG_DEBUG, "EAP-SIM: Invalid external SIM processing GSM-AUTH response");
	os_free(resp);
	return -1;
}
开发者ID:Bananian,项目名称:hostapd-rtl,代码行数:52,代码来源:eap_sim.c


示例13: WEBFSOpen

/*****************************************************************************
  Function:
	WEBFS_HANDLE WEBFSOpen(uint8* cFile)

  Description:
	Opens a file in the WEBFS2 file system.

  Precondition:
	None

  Parameters:
	cFile - a null terminated file name to open

  Returns:
	An WEBFS_HANDLE to the opened file if found, or WEBFS_INVALID_HANDLE
	if the file could not be found or no free handles exist.
  ***************************************************************************/
WEBFS_HANDLE ICACHE_FLASH_ATTR WEBFSOpen(uint8* cFile)
{
	WEBFS_HANDLE hWEBFS;
	uint16 nameHash; 
	int i, len = 0; 
	uint16 hashCache[16];
	uint8 bufname[MAX_FILE_NAME_LEN];
	uint8 *ptr;

	// Make sure WEBFS is unlocked and we got a filename
	if(*cFile == '\0' || isWEBFSLocked == true)
		return WEBFS_INVALID_HANDLE;

	// Calculate the name hash to speed up searching
	for(nameHash = 0, ptr = cFile; *ptr != '\0'; ptr++)
	{
		nameHash += *ptr;
		nameHash <<= 1;
		len++;
	}
	// Find a free file handle to use
	for(hWEBFS = 1; hWEBFS <= MAX_WEBFS_OPENFILES; hWEBFS++)
		if(WEBFSStubs[hWEBFS].addr == WEBFS_INVALID) break;
	if(hWEBFS == MAX_WEBFS_OPENFILES)
		return WEBFS_INVALID_HANDLE;
	// Read in hashes, and check remainder on a match.  Store 8 in cache for performance
	for(i = 0; i < numFiles; i++) {
		// For new block of 8, read in data
		if((i & 0x0F) == 0)	{
			WEBFSStubs[0].addr = 12 + i*2;
			WEBFSStubs[0].bytesRem = 32;
			WEBFSGetArray(0, (uint8*)hashCache, 32);
		}
		// If the hash matches, compare the full filename
		if(hashCache[i&0x0F] == nameHash)
		{
			GetFATRecord(i);
			// filename comparison
			WEBFSStubs[0].addr = fatCache.string;
			WEBFSStubs[0].bytesRem = MAX_FILE_NAME_LEN;
			WEBFSGetArray(0, bufname, MAX_FILE_NAME_LEN);
			if(os_strncmp(cFile, bufname, len) == 0) { // Filename matches, so return true
				WEBFSStubs[hWEBFS].addr = fatCache.data;
				WEBFSStubs[hWEBFS].bytesRem = fatCache.len;
				WEBFSStubs[hWEBFS].fatID = i;
				return hWEBFS;
			}
		}
	}
	// No file name matched, so return nothing
	return WEBFS_INVALID_HANDLE;
}
开发者ID:AndyKorg,项目名称:esp8266web,代码行数:69,代码来源:webfs.c


示例14: find_json_path

/******************************************************************************
 * FunctionName : find_json_path
 * Description  : find the JSON format tree's path
 * Parameters   : json -- A pointer to a JSON set up
 *                path -- A pointer to the JSON format tree's path
 * Returns      : A pointer to the JSON format tree
*******************************************************************************/
struct jsontree_value *ICACHE_FLASH_ATTR
find_json_path(struct jsontree_context *json, const char *path)
{
    struct jsontree_value *v;
    const char *start;
    const char *end;
    int len;

    v = json->values[0];
    start = path;

    do {
        end = (const char *)os_strstr(start, "/");

        if (end == start) {
            break;
        }

        if (end != NULL) {
            len = end - start;
            end++;
        } else {
            len = os_strlen(start);
        }

        if (v->type != JSON_TYPE_OBJECT) {
            v = NULL;
        } else {
            struct jsontree_object *o;
            int i;

            o = (struct jsontree_object *)v;
            v = NULL;

            for (i = 0; i < o->count; i++) {
                if (os_strncmp(start, o->pairs[i].name, len) == 0) {
                    v = o->pairs[i].value;
                    json->index[json->depth] = i;
                    json->depth++;
                    json->values[json->depth] = v;
                    json->index[json->depth] = 0;
                    break;
                }
            }
        }

        start = end;
    } while (end != NULL && *end != '\0' && v != NULL);

    json->callback_state = 0;
    return v;
}
开发者ID:FRANZEE,项目名称:IoT_Demo_PlugNew,代码行数:59,代码来源:user_json.c


示例15: wrapd_hostapd_ctrl_iface_process

void
wrapd_hostapd_ctrl_iface_process(struct wrap_demon *aptr, char *msg, char *child_ifname)
{
	int addr_off;
    char parent_ifname[IFNAMSIZ] = {0};
    u_int32_t flags = 0;

	if (os_strncmp(msg + HOSTAPD_MSG_ADDR_OFF, "AP-STA-CONNECTED ", 17) == 0) {	
        flags |= WRAPD_PSTA_FLAG_MAT ;
        addr_off = HOSTAPD_MSG_ADDR_OFF + 17;

        if (char2addr(msg + addr_off) != 0) {
            wrapd_printf("Invalid MAC addr");	
            return;
        }

        if (dbdc_ifname) {
            os_strncpy(parent_ifname, dbdc_ifname, IFNAMSIZ);
            parent_ifname[IFNAMSIZ - 1] = '\0';
            flags &= ~WRAPD_PSTA_FLAG_MAT;
        } else {
            wrapd_ifname_to_parent_ifname(aptr, child_ifname, parent_ifname);
        }
        
		wrapd_psta_add(aptr, parent_ifname, child_ifname, (u8 *)(msg + addr_off), flags);
        
	} else if (os_strncmp(msg + HOSTAPD_MSG_ADDR_OFF, "AP-STA-DISCONNECTED ", 20) == 0) {
	    addr_off = HOSTAPD_MSG_ADDR_OFF + 20;
        if (char2addr(msg + addr_off) != 0) {
            wrapd_printf("Invalid MAC addr");	
            return;
        }
		wrapd_psta_remove(aptr, (u8 *)(msg + addr_off));

	} else {
		wrapd_printf("Unknow msg(%s)", msg);
	}

}
开发者ID:KHATEEBNSIT,项目名称:AP,代码行数:39,代码来源:wrapd_api.c


示例16: l2_packet_init

struct l2_packet_data * l2_packet_init(
        const char *ifname, const u8 *own_addr, unsigned short protocol,
        void (*rx_callback)(void *ctx, const u8 *src_addr,
                            const u8 *buf, size_t len),
        void *rx_callback_ctx, int l2_hdr)
{
        struct l2_packet_data *l2;
        DWORD thread_id;

        l2 = os_zalloc(sizeof(struct l2_packet_data));
        if (l2 == NULL)
                return NULL;
        if (os_strncmp(ifname, "\\Device\\NPF_", 12) == 0)
                os_strlcpy(l2->ifname, ifname, sizeof(l2->ifname));
        else
                os_snprintf(l2->ifname, sizeof(l2->ifname), "\\Device\\NPF_%s",
                            ifname);
        l2->rx_callback = rx_callback;
        l2->rx_callback_ctx = rx_callback_ctx;
        l2->l2_hdr = l2_hdr;

        if (own_addr)
                os_memcpy(l2->own_addr, own_addr, ETH_ALEN);

        if (l2_packet_init_libpcap(l2, protocol)) {
                os_free(l2);
                return NULL;
        }

        l2->rx_avail = CreateEvent(NULL, TRUE, FALSE, NULL);
        l2->rx_done = CreateEvent(NULL, TRUE, FALSE, NULL);
        l2->rx_notify = CreateEvent(NULL, TRUE, FALSE, NULL);
        if (l2->rx_avail == NULL || l2->rx_done == NULL ||
            l2->rx_notify == NULL) {
                CloseHandle(l2->rx_avail);
                CloseHandle(l2->rx_done);
                CloseHandle(l2->rx_notify);
                pcap_close(l2->pcap);
                os_free(l2);
                return NULL;
        }

        eloop_register_event(l2->rx_avail, sizeof(l2->rx_avail),
                             l2_packet_rx_event, l2, NULL);

        l2->running = 1;
        l2->rx_thread = CreateThread(NULL, 0, l2_packet_receive_thread, l2, 0,
                                     &thread_id);

        return l2;
}
开发者ID:tigerjibo,项目名称:wpa_suppliant_with_openssl,代码行数:51,代码来源:l2_packet_winpcap.c


示例17: config_parse

void ICACHE_FLASH_ATTR config_parse(serverConnData *conn, char *buf, int len) {
    char *lbuf = (char *)os_malloc(len + 1), **argv;
    uint8_t i, argc;
    // we need a '\0' end of the string
    os_memcpy(lbuf, buf, len);
    lbuf[len] = '\0';
    DBG_MSG("parse %d[%s]\r\n", len, lbuf);

    // remove any CR / LF
    for (i = 0; i < len; ++i)
        if (lbuf[i] == '\n' || lbuf[i] == '\r')
            lbuf[i] = '\0';

    // verify the command prefix
    if (os_strncmp(lbuf, "+++AT", 5) != 0) {
        DBG_MSG("Not a command\r\n");
        return;
    }
    // parse out buffer into arguments
    argv = config_parse_args(&lbuf[5], &argc);
    DBG_MSG("argc: %d, argv[0]: %s.\r\n", argc, argv[0]);

    if (argc == 0) {
        espbuffsentstring(conn, MSG_OK);
    } else {
        argc--; // to mimic C main() argc argv
        for (i = 0; config_commands[i].command; ++i) {
            if (os_strncmp(argv[0], config_commands[i].command, strlen(argv[0])) == 0) {
                config_commands[i].function(conn, argc, argv);
                break;
            }
        }
        if (!config_commands[i].command)
            espbuffsentprintf(conn, "%s - buf: %s\r\n", MSG_INVALID_CMD, argv[0]);
    }
    config_parse_args_free(argc, argv);
    os_free(lbuf);
}
开发者ID:nvl1109,项目名称:esp8266-dev,代码行数:38,代码来源:telnet_config.c


示例18: properties_handler

static DBusMessage * properties_handler(DBusMessage *message,
					struct wpa_dbus_object_desc *obj_dsc)
{
	DBusMessageIter iter;
	char *interface;
	const char *method;

	method = dbus_message_get_member(message);
	dbus_message_iter_init(message, &iter);

	if (!os_strncmp(WPA_DBUS_PROPERTIES_GET, method,
			WPAS_DBUS_METHOD_SIGNAL_PROP_MAX) ||
	    !os_strncmp(WPA_DBUS_PROPERTIES_SET, method,
			WPAS_DBUS_METHOD_SIGNAL_PROP_MAX) ||
	    !os_strncmp(WPA_DBUS_PROPERTIES_GETALL, method,
			WPAS_DBUS_METHOD_SIGNAL_PROP_MAX)) {
		/* First argument: interface name (DBUS_TYPE_STRING) */
		if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
		{
			return dbus_message_new_error(message,
						      DBUS_ERROR_INVALID_ARGS,
						      NULL);
		}

		dbus_message_iter_get_basic(&iter, &interface);

		if (!os_strncmp(WPA_DBUS_PROPERTIES_GETALL, method,
				WPAS_DBUS_METHOD_SIGNAL_PROP_MAX)) {
			/* GetAll */
			return properties_get_all(message, interface, obj_dsc);
		}
		/* Get or Set */
		return properties_get_or_set(message, &iter, interface,
					     obj_dsc);
	}
	return dbus_message_new_error(message, DBUS_ERROR_UNKNOWN_METHOD,
				      NULL);
}
开发者ID:MindShow,项目名称:amlogic_s905_kernel_merges,代码行数:38,代码来源:dbus_new_helpers.c


示例19: CMD_GetCbByName

cmdCallback* ICACHE_FLASH_ATTR
CMD_GetCbByName(char* name) {
  for (uint8_t i = 0; i < MAX_CALLBACKS; i++) {
    //os_printf("CMD_GetCbByName: index %d name=%s cb=%p\n", i, callbacks[i].name,
    //  (void *)callbacks[i].callback);
    // if callback doesn't exist or it's null
    if (os_strncmp(callbacks[i].name, name, CMD_CBNLEN) == 0) {
      DBG("CMD_GetCbByName: cb %s found at index %d\n", name, i);
      return &callbacks[i];
    }
  }
  os_printf("CMD_GetCbByName: cb %s not found\n", name);
  return 0;
}
开发者ID:Drummondh,项目名称:esp-link,代码行数:14,代码来源:handlers.c


示例20: wrapd_wpa_s_ctrl_iface_process

void
wrapd_wpa_s_ctrl_iface_process(struct wrap_demon *aptr, char *msg)
{
	if (os_strncmp(msg + WPA_S_MSG_ADDR_OFF, "CTRL-EVENT-DISCONNECTED ", 24) == 0) {
        aptr->mpsta_conn = 0;
        wrapd_disconn_all(aptr);
        
	} else if (os_strncmp(msg + WPA_S_MSG_ADDR_OFF, "CTRL-EVENT-CONNECTED ", 21) == 0) {
        aptr->mpsta_conn = 1;
        if ((NULL == wrapd_hostapd_conn) || (0 == aptr->do_timer) ){
            wrapd_conn_all(aptr);
        } else {
            if (0 == aptr->in_timer) {
                eloop_register_timeout(1, 0, wrapd_conn_timer, aptr, NULL);
                aptr->in_timer = 1;
            }
        }
        
	} else {
		//wrapd_printf("Unknow msg(%s)", msg);
	}

}
开发者ID:KHATEEBNSIT,项目名称:AP,代码行数:23,代码来源:wrapd_api.c



注:本文中的os_strncmp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ os_strncpy函数代码示例发布时间:2022-05-30
下一篇:
C++ os_strdup函数代码示例发布时间: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