- e_hdr=(struct ethhdr *)package;
- /* what types ? */
- printf("type = ");
- printf("%x ",ntohs(e_hdr->h_proto));
- printf("dest_addr = ");
- for(i=0;i<ETH_ALEN;i++)
- printf("%x%s",*(e_hdr->h_dest+i),((i==ETH_ALEN-1)?" ":":"));
- printf(" src_addr = ");
- for(i=0;i<ETH_ALEN;i++)
- printf("%x%s",*(e_hdr->h_source+i),((i==ETH_ALEN-1)?"\n":":"));
- /* IP ? */
- if(ntohs(e_hdr->h_proto)==ETH_P_IP) {
- printf("ip protocol: ");
- ip_hdr=(struct ip *)(package+sizeof(struct ethhdr));
- printf("version = %x ",ntohs(ip_hdr->ip_v));
- printf("header_length = %x \n",ntohs(ip_hdr->ip_hl));
- printf("service = %x ",ntohs(ip_hdr->ip_tos));
- printf("total_length(dec.) = %d \n",ntohs(ip_hdr->ip_len));
- printf("ip_addresses: source = ");
- printf("%s\tdestination = %s\n",inet_ntoa(ip_hdr->ip_src),
- inet_ntoa(ip_hdr->ip_dst));
- printf("ip_id = %x ",ntohs(ip_hdr->ip_id));
- printf("ip_offset = %x \n",ntohs(ip_hdr->ip_off));
- printf("time2live = %x ip_proto = %x\n",ntohs(ip_hdr->ip_ttl),
- ntohs(ip_hdr->ip_p));
- printf("chksum: %x\n",ntohs(ip_hdr->ip_sum));
+ if((strncmp(my_info_struct->dev,"eth",3)==0) |
+ ((w_hdr->frame_ctl & IEEE802_11_FTYPE_DATA)==IEEE802_11_FTYPE_DATA)) {
+
+ if((strncmp(my_info_struct->dev,"eth",3)==0)) {
+ printf("ethernet: (%d bytes)\n",e_o);
+ e_hdr=(struct ethhdr *)(package+p_o+w_o);
+ /* what types ? */
+ printf("type = ");
+ printf("%x ",ntohs(e_hdr->h_proto));
+ printf("dest_addr = ");
+ for(i=0;i<ETH_ALEN;i++)
+ printf("%x%s",*(e_hdr->h_dest+i),((i==ETH_ALEN-1)?" ":":"));
+ printf(" src_addr = ");
+ for(i=0;i<ETH_ALEN;i++) printf("%x%s",*(e_hdr->h_source+i),
+ ((i==ETH_ALEN-1)?"\n":":"));
+ if((ntohs(e_hdr->h_proto)==ETH_P_IP))
+ parse_ip(package+p_o+w_o+e_o);
+ }
+ else {
+ snap_hdr=(struct snaphdr *)(package+p_o+w_o);
+ if((snap_hdr->snap[0]==0xaa) &
+ (snap_hdr->snap[1]==0xaa) &
+ (snap_hdr->snap[2]==0x03) &
+ (snap_hdr->snap[3]==0x00) &
+ (snap_hdr->snap[4]==0x00) &
+ (snap_hdr->snap[5]==0x00)) {
+ printf("- no encryption!\n");
+ if(snap_hdr->proto==ntohs(ETH_P_IP)) {
+ e_o=sizeof(struct snaphdr);
+ parse_ip(snap_hdr+e_o);
+ }
+
+ }
+ else {
+ printf("- crypted packet!\n");
+ /* print crypted snap - write into file */
+ printf("snap: (iv(3) + index(1) + crypted snap(6)) ");
+ for(i=0;i<10;i++) {
+ printf("%x ",*(snap_hdr->snap+i));
+ crypted_snap[i]=*(snap_hdr->snap+i);
+ }
+ /* xor with plain
+ crypted_snap[4]^=0xaa;
+ crypted_snap[5]^=0xaa;
+ crypted_snap[6]^=0x03;
+ crypted_snap[7]^=0x00;
+ crypted_snap[8]^=0x00;
+ crypted_snap[9]^=0x00;
+ */
+
+ printf("\n");
+ crypted_snap[10]='\0';
+ crypted_snap[11]='\n';
+
+ if(file_fd>0) {
+ printf("debug: saved to file\n");
+ dprintf(file_fd,IVLINE,IVL_ARGS);
+ }
+ }