*/
#include "parse.h"
-#include "802.11b.h"
#include "main.h"
-#include "parse.h"
+/* all the parsing stuff will go here
+ *
+ * different protocols should get to seperated files though ...
+ */
+
+void parse_package(unsigned char *ptr,const struct pcap_pkthdr *pcap_header,const unsigned char *package) {
+
+ t_info *info;
+ int i;
+ t_sta new_sta;
+ t_frame4_hdr *f4hdr;
+ t_frame3_hdr *f3hdr;
+ t_frame2_hdr *f2hdr;
+ t_frame1_hdr *f1hdr;
+ t_beacon_fb *beacon_fb;
+ int ret;
+
+ info=(t_info *)ptr;
+
+ info->count++;
-int parse_package(unsigned char *info,const struct pcap_pkthdr *pcap_hdr,cont unsigned char *package)
-{
- if(info->caps&MONITORING_MODE)
- {
- struct linux_wlan_ng_prism_hdr *prism_hdr;
+ memset(&new_sta,0,sizeof(t_sta));
- prism_hdr=(struct linux_wlan_ng_prism_hdr *)package;
+ if(info->dump_fd!=0) {
+ ret=write(info->dump_fd,pcap_header,sizeof(struct pcap_pkthdr));
+ if(ret!=sizeof(struct pcap_pkthdr))
+ display_console(info,"warning, pcap header write failed!");
+ ret=write(info->dump_fd,package,pcap_header->caplen);
+ if(ret!=pcap_header->caplen)
+ display_console(info,"warning, package write failed!");
+ }
+ /* maybe there is offset to the actual ieee802.11 frame,
+ for example prism header ... */
+ if(FCTL_TYPE(package[0])==FCTL_TYPE_MGMT) {
+ info->count_m++;
+ if(FCTL_STYPE(package[0])==FCTL_STYPE_BEACON) {
+ f3hdr=(t_frame3_hdr *)package;
+ beacon_fb=(t_beacon_fb *)(package+sizeof(t_frame3_hdr));
+ // new_sta.
+ /* debug output */
+ dprintf(info->log_fd,"beacon: ");
+ for(i=0;i<ADDR_LEN;i++) dprintf(info->log_fd,"%02x ",*((f3hdr->addr2)+i));
+ dprintf(info->log_fd," essid: (len=%x) ",beacon_fb->ssid_length);
+ for(i=0;i<beacon_fb->ssid_length;i++)
+ dprintf(info->log_fd,"%c ",*(u8 *)(beacon_fb->ssid+i));
+ dprintf(info->log_fd,"\n");
+ }
+ }
+ else if(FCTL_TYPE(package[0])==FCTL_TYPE_CTRL) {
+ info->count_c++;
+ }
+ else if(FCTL_TYPE(package[0])==FCTL_TYPE_DATA) {
+ info->count_d++;
+ }
+ display_console(info,"");
}