some stuff for dot11 handling added
This commit is contained in:
		| @ -44,6 +44,8 @@ | |||||||
|  |  | ||||||
| #include "actube.h" | #include "actube.h" | ||||||
|  |  | ||||||
|  | #include "cw/dot11.h" | ||||||
|  |  | ||||||
|  |  | ||||||
| static void wtpman_remove(struct wtpman *wtpman) | static void wtpman_remove(struct wtpman *wtpman) | ||||||
| { | { | ||||||
| @ -319,6 +321,15 @@ static int dataman_process_msg(struct cw_Conn *nc, uint8_t * rawmsg, int len, | |||||||
| 	uint8_t * dot11frame = rawmsg + offs; | 	uint8_t * dot11frame = rawmsg + offs; | ||||||
| 	int dot11len = len-offs; | 	int dot11len = len-offs; | ||||||
| 	cw_dbg_dot11_frame(dot11frame,dot11len); | 	cw_dbg_dot11_frame(dot11frame,dot11len); | ||||||
|  |  | ||||||
|  | 	char frame[1000]; | ||||||
|  | 	dot11_init_assoc_resp(frame); | ||||||
|  | 	dot11_copy_mac(dot11_get_sa(dot11frame),dot11_get_da(frame)); | ||||||
|  | 	dot11_copy_mac(dot11_get_bssid(dot11frame),dot11_get_bssid(frame)); | ||||||
|  | 	dot11_copy_mac(dot11_get_da(dot11frame),dot11_get_sa(frame)); | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  |  | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | |||||||
| @ -7,7 +7,7 @@ | |||||||
|  |  | ||||||
| int cw_format_dot11_fc_flags(char *dst, uint8_t *frame){ | int cw_format_dot11_fc_flags(char *dst, uint8_t *frame){ | ||||||
| 	char *s = dst; | 	char *s = dst; | ||||||
| 	uint8_t f = frame[2]; | 	uint8_t f = frame[0]; | ||||||
| 	s+=sprintf(s,"ToDS:%d ", f&1 ? 1:0); | 	s+=sprintf(s,"ToDS:%d ", f&1 ? 1:0); | ||||||
| 	s+=sprintf(s,"FromDS:%d ", f&2 ? 1:0); | 	s+=sprintf(s,"FromDS:%d ", f&2 ? 1:0); | ||||||
| 	s+=sprintf(s,"More Frgs:%d ", f&4 ? 1:0); | 	s+=sprintf(s,"More Frgs:%d ", f&4 ? 1:0); | ||||||
| @ -88,6 +88,7 @@ int cw_format_dot11_hdr(char * dst, uint8_t * packet, int len) | |||||||
| 	s+=format_mac(s,dot11_get_bssid(packet),6); | 	s+=format_mac(s,dot11_get_bssid(packet),6); | ||||||
| 	s+=sprintf(s," seq: %d\n",dot11_get_seq(packet)); | 	s+=sprintf(s," seq: %d\n",dot11_get_seq(packet)); | ||||||
| 	s+=cw_format_dot11_fc_flags(s,packet); | 	s+=cw_format_dot11_fc_flags(s,packet); | ||||||
|  | 	s+=sprintf(s,"\nDuration: %d",dot11_get_duration(packet)); | ||||||
| // | // | ||||||
| /*	switch (type){ | /*	switch (type){ | ||||||
| 		case DOT11_ASSOC_REQ: | 		case DOT11_ASSOC_REQ: | ||||||
|  | |||||||
| @ -61,6 +61,5 @@ struct cw_StrListElem dot11_names[]={ | |||||||
|  |  | ||||||
| int dot11_init_assoc_resp(uint8_t * dst) | int dot11_init_assoc_resp(uint8_t * dst) | ||||||
| { | { | ||||||
| 	dst[0]=0; | 	dot11_set_type_and_subtype(dst,DOT11_ASSOC_RESP); | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -148,16 +148,11 @@ uint16_t dot11_get_word(uint8_t * ptr); | |||||||
| #define dot11_get_version(frame) ( (frame)[1] & 0x03) | #define dot11_get_version(frame) ( (frame)[1] & 0x03) | ||||||
| #define dot11_get_type(frame)    ( ((frame)[1] & 0x0c) >> 2) | #define dot11_get_type(frame)    ( ((frame)[1] & 0x0c) >> 2) | ||||||
| #define dot11_get_subtype(frame) ( (frame)[1] >> 4 ) | #define dot11_get_subtype(frame) ( (frame)[1] >> 4 ) | ||||||
| #define dot11_get_type_and_subtype( frame) ((frame)[1]) |  | ||||||
|  |  | ||||||
| /**  | #define dot11_get_type_and_subtype(frame) ((frame)[1]) | ||||||
|  * Get Frame Control field  | #define dot11_set_type_and_subtype(frame,val) ((frame)[1]=val) | ||||||
|  * @param frame |  | ||||||
|  * @return Frame Control field |  | ||||||
|  */ |  | ||||||
| #define dot11_get_fc(frame) dot11_get_word(frame) |  | ||||||
|  |  | ||||||
| #define dot11_get_duration(frame) dot11_get_word(frame+2) |  | ||||||
|  |  | ||||||
|  |  | ||||||
| void dot11_get_address(uint8_t * dst, uint8_t * frame); | void dot11_get_address(uint8_t * dst, uint8_t * frame); | ||||||
| @ -251,10 +246,18 @@ extern struct cw_StrListElem dot11_names[]; | |||||||
|  |  | ||||||
| #define dot11_get_frame_name(data) cw_strlist_get_str(dot11_names,(data)[1]) | #define dot11_get_frame_name(data) cw_strlist_get_str(dot11_names,(data)[1]) | ||||||
|  |  | ||||||
| #define dot11_get_da(frame) ((frame)+2+2) | /**  | ||||||
| #define dot11_get_sa(frame) ((frame)+2+2+6) |  * Get Frame Control field  | ||||||
| #define dot11_get_bssid(frame) ((frame)+2+2+12) |  * @param frame uint8_t pointer to the frame | ||||||
| #define dot11_get_seq(frame) dot11_get_word((frame)+2+2+12+6) |  * @return uint16_t Frame Control field | ||||||
|  |  */ | ||||||
|  | #define dot11_get_fc(frame) dot11_get_word(frame) | ||||||
|  | #define dot11_get_duration(frame) dot11_get_word(frame+2) | ||||||
|  | #define dot11_get_da(frame) ((frame)+4) | ||||||
|  | #define dot11_get_sa(frame) ((frame)+10) | ||||||
|  | #define dot11_get_bssid(frame) ((frame)+16) | ||||||
|  | #define dot11_get_seq(frame) dot11_get_word((frame)+22) | ||||||
|  | #define dot11_get_body(frame) ((frame)+24) | ||||||
|  |  | ||||||
| #define dot11_assoc_req_get_cap(frame) \ | #define dot11_assoc_req_get_cap(frame) \ | ||||||
| 		dot11_get_word((frame)+2+2+12+6+2) | 		dot11_get_word((frame)+2+2+12+6+2) | ||||||
| @ -269,6 +272,10 @@ extern struct cw_StrListElem dot11_names[]; | |||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #define dot11_copy_mac(src,dst)\ | ||||||
|  | 	memcpy(dst,src,6); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  | |||||||
| @ -71,3 +71,11 @@ int dot11_put_dsss_param_set(uint8_t *dst,int ch) { | |||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #define DOT11_INLINE | ||||||
|  |  | ||||||
|  |  | ||||||
|  | DOT11_INLINE  | ||||||
|  | uint8_t * dot11_get_body(uint8_t * frame) | ||||||
|  | { | ||||||
|  | 	 | ||||||
|  | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user