/** @brief print a MAC address in a familiar format to stdout * * @param mac the MAC address to print */ void print_mac (const volatile unsigned char *mac) { fprint_mac (stdout, mac); }
void print_host(FILE * outf, wiviz_host * host) { int i; if (!host->occupied) return; fprintf(outf, "h.mac = '"); fprint_mac(outf, host->mac, "';\n"); if (host->RSSI < 0) fprintf(outf, "h.rssi = %i;\nh.type = '", host->RSSI / 100); else fprintf(outf, "h.rssi = -%i;\nh.type = '", host->RSSI / 100); switch (host->type) { case typeAP: fprintf(outf, "ap"); break; case typeWDS: fprintf(outf, "wds"); break; case typeSta: fprintf(outf, "sta"); break; case typeAdhocHub: fprintf(outf, "adhoc"); break; } fprintf(outf, "';\nh.self = "); fprintf(outf, host->isSelf ? "true;\n" : "false;\n"); if (host->type == typeSta) { switch (host->staInfo->state) { case ssAssociated: fprintf(outf, "h.sta_state='assoc';\nh.sta_bssid='"); fprint_mac(outf, host->staInfo->connectedBSSID, "';\n"); break; case ssUnassociated: fprintf(outf, "h.sta_state='unassoc';\n"); } fprintf(outf, "h.sta_lastssid = '"); for (i = 0; i < host->staInfo->lastssidlen; i++) { fprintf(outf, "&#%04i;", *((char *)host->staInfo->lastssid + i) & 0xFF); } fprintf(outf, "';\n"); } if (host->type == typeAP || host->type == typeAdhocHub) { fprintf(outf, "h.channel = %i;\nh.ssid = '", host->apInfo->channel & 0xFF); for (i = 0; i < host->apInfo->ssidlen; i++) { fprintf(outf, "&#%04i;", *((char *)host->apInfo->ssid + i) & 0xFF); } fprintf(outf, "';\nh.encrypted = "); switch (host->apInfo->encryption) { case aetUnknown: fprintf(outf, "'unknown';\n"); break; case aetUnencrypted: fprintf(outf, "'no';\n"); break; case aetEncUnknown: fprintf(outf, "'yes';\nh.enctype = 'unknown';\n"); break; case aetEncWEP: fprintf(outf, "'yes';\nh.enctype = 'wep';\n"); break; case aetEncWPA: fprintf(outf, "'yes';\nh.enctype = 'wpa';\n"); break; case aetEncWPA2: fprintf(outf, "'yes';\nh.enctype = 'wpa2';\n"); break; case aetEncWPAmix: fprintf(outf, "'yes';\nh.enctype = 'wpa wpa2';\n"); break; } } if (host->type == typeWDS) { fprintf(outf, "h.channel = %i;\nh.ssid = '", host->apInfo->channel & 0xFF); fprintf(outf, "';\nh.encrypted = "); switch (host->apInfo->encryption) { case aetUnknown: fprintf(outf, "'unknown';\n"); break; case aetUnencrypted: fprintf(outf, "'no';\n"); break; case aetEncUnknown: fprintf(outf, "'yes';\nh.enctype = 'unknown';\n"); break; case aetEncWEP: fprintf(outf, "'yes';\nh.enctype = 'wep';\n"); break; case aetEncWPA: fprintf(outf, "'yes';\nh.enctype = 'wpa';\n"); break; case aetEncWPA2: fprintf(outf, "'yes';\nh.enctype = 'wpa2';\n"); break; case aetEncWPAmix: fprintf(outf, "'yes';\nh.enctype = 'wpa wpa2';\n"); break; } } fprintf(outf, "h.age = %i;\n", time(0) - host->lastSeen); }
/** @brief print the device static information to stream * * @param f the device context * @param stream the output stream (i.e. stdout, stderr...) * @param packet_in the DOOF_STATIC_INFO data structure containing the information to display */ void fprint_static_info (libfb_t * f, FILE * stream, DOOF_STATIC_INFO * packet_in) { struct tm *time_info = malloc (sizeof (struct tm)); time_t calendar_time; set_reftime (f); fprintf (stream, "SW ver: %s\n", packet_in->sw_ver); fprintf (stream, "SW Compile date: %s\n", packet_in->sw_compile_date); fprintf (stream, "Build number: %d\n", packet_in->build_num); fprintf (stream, "FB core ver sig: 0x%X\n", packet_in->fb_core_version); fprintf (stream, "Spans: %d Devices: %d MACs: %d\n", packet_in->spans, packet_in->devices, packet_in->mac_num); fprintf (stream, "EPCS Blocks: %d\n", packet_in->epcs_blocks); fprintf (stream, "EPCS Block size: 0x%X (%d KB)\n", packet_in->epcs_block_size, packet_in->epcs_block_size / 1024); fprintf (stream, "EPCS Region size: 0x%X (%d KB)\n", packet_in->epcs_region_size, packet_in->epcs_region_size / 1024); fprintf (stream, "\nStored config data:\n"); fprintf (stream, "--------------------\n"); fprintf (stream, "MAC[0]: "); fprint_mac (stream, packet_in->epcs_config.mac_addr); packet_in->epcs_config.mac_addr[5]++; fprintf (stream, "MAC[1]: "); fprint_mac (stream, packet_in->epcs_config.mac_addr); fprintf (stream, "Serial: %s\n", packet_in->epcs_config.snumber); fprintf (stream, "IP[0]: "); fprint_ip (stream, packet_in->epcs_config.ip_address[0]); fprintf (stream, "IP[1]: "); fprint_ip (stream, packet_in->epcs_config.ip_address[1]); fprintf (stream, "CFG Flags: 0x%X (%s)\n", packet_in->epcs_config.cfg_flags, packet_in->epcs_config.cfg_flags & (1 << 0) ? "IEC" : "FB2"); calendar_time = packet_in->epcs_config.mfg_date + libfb_get_ctime (f); time_info = localtime (&calendar_time); fprintf (stream, "Flash Date: %d (%d/%d/%d %d:%d:%d)\n", (int) calendar_time, time_info->tm_mon + 1, time_info->tm_mday, time_info->tm_year + 1900, time_info->tm_hour, time_info->tm_min, time_info->tm_sec); fprintf (stream, "CRC: 0x%X\n", packet_in->epcs_config.crc16); fprintf (stream, "SYSID CRC: 0x%X\n", packet_in->fpga_sysid); calendar_time = packet_in->fpga_timestamp + libfb_get_systime (f); time_info = localtime (&calendar_time); fprintf (stream, "SYSID Timestamp: 0x%X (%d/%d/%d %d:%d:%d)\n", packet_in->fpga_timestamp, time_info->tm_mon + 1, time_info->tm_mday, time_info->tm_year + 1900, time_info->tm_hour, time_info->tm_min, time_info->tm_sec); fprintf (stream, "Attempted boots: %d\n", packet_in->epcs_config.attempted_boots); fprintf (stream, "GPAK File Length: %d bytes\n", packet_in->epcs_config.gpak_len); fprintf (stream, "\nDSP Parameters\n-----------------\n"); fprintf (stream, "Active/Max channels: %d/%d\n", packet_in->gpak_config.active_channels, packet_in->gpak_config.max_channels); fprintf (stream, "BIST: %d Num EC: %d\n", packet_in->gpak_config.bist, packet_in->gpak_config.num_ec); fprintf (stream, "Stream0: Max channels: %d Supported channels: %d\n", packet_in->gpak_config.stream_slots[0], packet_in->gpak_config.stream_supported_slots[0]); fprintf (stream, "Stream1: Max channels: %d Supported channels: %d\n", packet_in->gpak_config.stream_slots[1], packet_in->gpak_config.stream_supported_slots[1]); fprintf (stream, "GPAK VerID: 0x%X\n", packet_in->gpak_config.ver); }
void print_mac(u_char * mac, char *extra) { fprint_mac(stdout, mac, extra); }