Ejemplo n.º 1
0
/*请求头部解析request*/
u32 cloud_wlan_http_skb_parse_request(struct sk_buff *skb, http_t *http_info)
{
	u32 ret;
	struct iphdr *iphdr;
	struct tcphdr *tcphdr;
	
	iphdr = ip_hdr(skb);
	tcphdr = tcp_hdr(skb);
	
	if((IPPROTO_TCP != iphdr->protocol) 
		|| (PROTO_HTTP!= ntohs(tcphdr->dest) && PROTO_HTTP2 != ntohs(tcphdr->dest)) )
	{
		return CWLAN_FAIL;
	}
	/*分析报文头get 未使用*/
	ret = is_http_get_pkt((void *)tcphdr + tcphdr->doff*4 , iphdr->tot_len - tcphdr->doff*4);

	if(ret != CWLAN_OK)
	{
		return CWLAN_FAIL;
	}

	ret = cloud_wlan_get_http_header_info( (u8 *)tcphdr + tcphdr->doff * 4, http_info);
	if(ret != CWLAN_OK)
	{
		return CWLAN_FAIL;
	}

	return CWLAN_OK;
}
Ejemplo n.º 2
0
static void * pkt_cap_cb(void *arg)
{
	pkt_cap_ctx_p ctx = (pkt_cap_ctx_p)arg;
	char *data = NULL;
	int data_len = 0;
	int is_pkt_first = 1;
	cpu_set_t mask;
	struct timeval init_tm;
	memset(&init_tm, 0x00, sizeof(init_tm));
	memset(&ctx->tm_beg, 0x00, sizeof(ctx->tm_beg));

	if (ctx->id >= 0) {
		CPU_ZERO(&mask);
		CPU_SET(ctx->id, &mask);
		if (pthread_setaffinity_np(pthread_self(), sizeof(mask), &mask) < 0) {
			fprintf(stderr, "%s pthread_setaffinity_np on %d failed!\n", __FUNCTION__, ctx->id);
			return NULL;
		}
	}

	while (1) {
		// todo: capture data from device.
		// 

		if (memcmp(&ctx->tm_beg, &init_tm, sizeof(init_tm)) == 0) {
			fprintf(stdout, "is pkt first!\n");
			gettimeofday(&ctx->tm_beg, NULL);
		}
		pkt_st_inc(ctx->p_pkt_info, PKT_PKT, data_len);

		// if packet is http get
		if (is_http_get_pkt(data, data_len)) {
			pkt_st_inc(ctx->p_pkt_info, PKT_HTTP_GET, data_len);
		}

		// todo: send packet.
		//

		gettimeofday(&ctx->tm_end, NULL);
	}

	return NULL;
}