]> andersk Git - libfaim.git/blobdiff - utils/aimdump/main.c
- Thu Feb 8 20:12:39 UTC 2001
[libfaim.git] / utils / aimdump / main.c
index fe9123b48402ab804d9408f994c845d3312347ac..6e00d1cf2c78e7af63f15f0e5f6b657415b0ba7b 100644 (file)
@@ -7,14 +7,10 @@
 
 #include "aimdump.h"
 
-#define IMAGEFILE "ibmboot.img"
 #define DEVNAME "eth0"
 
 pcap_t *pd = NULL;
 
-static u_int8_t clientaddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0x0ff, 0xff}; /* loaded with client address */
-static u_int8_t multicastaddr[ETH_ALEN] = {0x03, 0x00, 0x02, 0x00, 0x00, 0x00};
-
 pcap_t *open_pcap(char *device)
 {
   pcap_t *pd = NULL;
@@ -71,6 +67,7 @@ char *next_pcap(pcap_t *pd, struct pcap_pkthdr *hdr)
  * an incoming RPL frame.  
  *
  */
+#if 0
 void processframe(struct pcap_pkthdr *hdr, char *pkt, char *device)
 {
   static struct ether_header *ether = NULL;
@@ -149,6 +146,7 @@ void processframe(struct pcap_pkthdr *hdr, char *pkt, char *device)
     return;
 #endif
 }
+#endif
 
 void sigint(int sig)
 {
@@ -159,10 +157,10 @@ void sigint(int sig)
 }
 
 struct flaphdr {
-  __u8 start;
-  __u8 channel;
-  __u16 seqnum;
-  __u16 len;
+  unsigned char start;
+  unsigned char channel;
+  unsigned short seqnum;
+  unsigned short len;
 };
 
 struct snachdr {
@@ -360,12 +358,12 @@ void detectaim(struct pcap_pkthdr *hdr, char *pkt)
   u_int newlen;
   int maxfamily = 0;
   int maxsubtype = 0;
-    
+  
   if ( (!hdr) || (!pkt) )
     return;
 
   if (hdr->caplen != hdr->len)
-    fprintf(stderr, "aimdump: caplen/len mismatch\n");
+    return; //fprintf(stderr, "aimdump: caplen/len mismatch\n");
 
   newlen = hdr->caplen;
 
@@ -396,7 +394,7 @@ void detectaim(struct pcap_pkthdr *hdr, char *pkt)
   if (flap->start != 0x2a)
     return; /* ditch non-FLAP packets */
 
-#if 0
+#if 0 
   /* TODO: notify user of new connections (SYN) and closed connections (FIN) */
   printf("\nTCP options: %s %s %s %s %s %s\n\n",
         tcp->fin?"fin":"",
@@ -410,57 +408,77 @@ void detectaim(struct pcap_pkthdr *hdr, char *pkt)
   flap->seqnum = ntohs(flap->seqnum);
   flap->len = ntohs(flap->len);
 
-  snac = (struct snachdr *)(pkt+6);
-
-  snac->family = ntohs(snac->family);
-  snac->subtype= ntohs(snac->subtype);
-  snac->id = (htons(snac->id & 0x0000ffff)) + (htons(snac->id >>16)<<16);
-  
   printf("\n--------------------\n");
+  {
+    struct in_addr tmpaddr;
+    tmpaddr.s_addr = ip->saddr;
+    printf("%s -> ", inet_ntoa(tmpaddr));
+    tmpaddr.s_addr = ip->daddr;
+    printf("%s\n\n", inet_ntoa(tmpaddr));
+  }
   printf("FLAP:\n");
   printf("\tChannel:\t0x%02x\t\tSeqNum:\t0x%04x\n\tLength:\t\t0x%04x\n",
         flap->channel,
         flap->seqnum,
         flap->len);
-  printf("SNAC:\n");
 
-
-  /* for overrun checking... */
-  for (maxfamily=1;snactypes[maxfamily].family; maxfamily++)
-    ;
-  if (snac->family <= maxfamily)
+  /* jump around flap */
+  pkt += 6;
+  newlen -= 6;
+  
+  if (flap->channel != 0x02)
     {
-      for (maxsubtype=1;snactypes[snac->family].subtypes[maxsubtype].name; maxsubtype++)
-       ;
+      printf("\t\tNo SNAC.\n");
     }
-  maxfamily--;
-  maxsubtype--;
-
-  printf("\tFamily:\t\t0x%04x (%s)\n", 
-        snac->family,
-        (snac->family > maxfamily)?"Out of Range":snactypes[snac->family].family);
-  printf("\tSubtype:\t0x%04x (%s)\n",
-        snac->subtype,
-        (snac->subtype > maxsubtype)?"Out of Range":snactypes[snac->family].subtypes[snac->subtype].name);
-  printf("\tFlags:\t\t0x%02x,0x%02x\tID:\t0x%08lx\n", snac->flags[0], snac->flags[1], snac->id);
-
-  /* jump around flap+snac */
-  pkt += 16;
-  newlen -= 16;
-
-  if (snactypes[snac->family].subtypes[snac->subtype].parser)
-    (*(snactypes[snac->family].subtypes[snac->subtype].parser))((u_char *)pkt, newlen);
+  else
+    {
+       snac = (struct snachdr *)pkt;
 
+       snac->family = ntohs(snac->family);
+       snac->subtype= ntohs(snac->subtype);
+       snac->id = (htons(snac->id & 0x0000ffff)) + (htons(snac->id >>16)<<16);
+       
+      printf("SNAC:\n");
+      
+      /* for overrun checking... */
+      for (maxfamily=1;snactypes[maxfamily].family; maxfamily++)
+       ;
+      if (snac->family <= maxfamily)
+       {
+         for (maxsubtype=1;snactypes[snac->family].subtypes[maxsubtype].name; maxsubtype++)
+           ;
+       }
+      maxfamily--;
+      maxsubtype--;
+      
+      printf("\tFamily:\t\t0x%04x (%s)\n", 
+            snac->family,
+            (snac->family > maxfamily)?"Out of Range":snactypes[snac->family].family);
+      printf("\tSubtype:\t0x%04x (%s)\n",
+            snac->subtype,
+            (snac->subtype > maxsubtype)?"Out of Range":snactypes[snac->family].subtypes[snac->subtype].name);
+      printf("\tFlags:\t\t0x%02x,0x%02x\tID:\t0x%08lx\n", snac->flags[0], snac->flags[1], snac->id);
+      
+      /* jump around snac */
+      pkt += 10;
+      newlen -= 10;
+#if 0
+      if (snactypes[snac->family].subtypes[snac->subtype].parser)
+       (*(snactypes[snac->family].subtypes[snac->subtype].parser))((u_char *)pkt, newlen);
+#endif
+    }
+  
   printf("\nRAW:\n");
 
+#if 1 
   for (i=0;i<newlen;i+=2)
-    {
+   {
       if (!((i)%16))
        printf("\n\t");
       printf("%02x%02x ", pkt[i] &0xff, pkt[i+1] & 0xff);
     }
   printf("\n\n");
-
+#endif
   fflush(stdout);
   pkt = orig;
 }
This page took 0.042933 seconds and 4 git commands to generate.