void AnalyzePacket(struct iovec *packet_ring, char **argv) { struct ether_header *eth; struct ip *iptr; struct ether_arp *arptr; if ( packet_ring->iov_len > sizeof(struct ether_header) ) { eth = (struct ether_header *)packet_ring->iov_base; printf("=-=-=-=-=-=-=-=-=-=-=\n" "Ethernet Header\n"); printf("source mac:"); PrintMac(eth->ether_shost); printf("\ndestination mac:"); PrintMac(eth->ether_dhost); printf("\n"); } else return; switch(ntohs(eth->ether_type)) { case ETHERTYPE_IP: iptr = (struct ip *)((unsigned char *)packet_ring->iov_base+sizeof(struct ether_header)); printf("=-=-=-=-=-=-=-=-=-=-=\n" "Ip Header\n"); //printf("source_addr: %s\n", inet_ntoa(iptr -> ip_src)); //printf("destination_addr: %s\n", inet_ntoa(iptr -> ip_dst)); break; case ETHERTYPE_ARP: arptr = (struct ether_arp *)((unsigned char *)packet_ring->iov_base+sizeof(struct ether_header)); printf("=-=-=-=-=-=-=-=-=-=-=\n" "Arp Header\n"); printf("sender ip: %s\n", arptr->arp_spa); break; default: printf("unknown\n"); break; } }
void PrintRouter(void) { if( RouterExist() == -1 ) return; printf("=-=-=-=-=Router=-=-=-=-=\n"); printf("Router mac = "); PrintMac(router->mac); printf("Router ip = "); PrintIp(router->ip); printf("=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"); printf("_____________________________________________________\n"); }
void PrintClients() { struct client *tmp; register int i = 0; if( ClientExist() == -1 ) return; printf("_____________________________________________________\n"); tmp = c; printf("=-=-=-=-=Clients=-=-=-=-=\n"); do { printf("client mac [%d] = ", i); PrintMac(tmp->mac); printf("client ip [%d] = ", i); PrintIp(tmp->ip); tmp = tmp -> next; i++; }while (tmp != (struct client *)NULL); printf("=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"); }
//***************************************************************************** // // The "getmac" command prints the user's current MAC address to the UART. // //***************************************************************************** int Cmd_getmac(int argc, char *argv[]) { PrintMac(); return 0; }