]> andersk Git - libfaim.git/blobdiff - utils/aimdump/util.c
Added aimdump.
[libfaim.git] / utils / aimdump / util.c
diff --git a/utils/aimdump/util.c b/utils/aimdump/util.c
new file mode 100644 (file)
index 0000000..e699252
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ *
+ *
+ *
+ */
+
+#include "aimdump.h"
+
+char *printether(u_int8_t *addr)
+{
+  static char out[18];
+  
+  memset(out, 0, 18);
+  sprintf(out, "%02x:%02x:%02x:%02x:%02x:%02x", 
+         addr[0], addr[1],
+         addr[2], addr[3],
+         addr[4], addr[5]);
+  
+  return out;
+}
+
+int cmpether(u_int8_t *addr, u_int8_t *addr2)
+{
+  int i;
+  for (i=0; i<ETH_ALEN; i++)
+    {
+      if (addr[i] != addr2[i])
+       return 0;
+    }
+  return 1;
+}
+
+void printframe(struct pcap_pkthdr *hdr, char *pkt)
+{
+  int i;
+  struct ether_header *ether = NULL;
+
+  if ( (!hdr) || (!pkt) )
+    return;
+
+  if (hdr->caplen != hdr->len)
+    fprintf(stderr, "rpld: caplen/len mismatch\n");
+
+  ether = (struct ether_header *)pkt;
+  
+  printf("\n\nrpld: %s > ", printether(ether->ether_shost));
+  printf("%s\n", printether(ether->ether_dhost));
+  
+  //pkt = 18; /* skip over ethernet headers */
+  for (i=0;i<hdr->caplen;i+=2)
+    {
+      if (!((i)%8))
+       printf("\nrpld:\t");
+      printf("%02x%02x ", pkt[i] &0xff, pkt[i+1] & 0xff);
+    }
+}
This page took 0.032582 seconds and 4 git commands to generate.