int main(int argc, char *argv[]){ //int tap_fd, option; //int flags = IFF_TAP; // char if_name[IFNAMSIZ] = ""; unsigned int size[P_MAX_NUM]; unsigned int seq, allsize; int mode = 1; int rc; char buffer[P_MAX_SIZE]; char hash[41]; char recv_data[P_MAX_SIZE+sizeof(unsigned int)*(P_MAX_NUM+1)]; int count = 0; pcap_t *pd = NULL; char ebuf[PCAP_ERRBUF_SIZE]; struct mac_list p; mac_list_init(); // if(argc < 2){ // printf("tap name\n"); // exit(1); // } // strncpy(if_name, argv[1], IFNAMSIZ-1); /* initialize tun/tap interface */ // if ( (tap_fd = tun_alloc(if_name, flags | IFF_NO_PI)) < 0 ) { // printf("error:tun_alloc\n"); // exit(1); // } if( (pd = pcap_open_live( "br0" , // インターフェイス名 DPCP_RCV_MAXSIZE , // 最大受信サイズ(最初の68byteまで受信する) DPCP_PROMSCS_MODE , // 自分宛以外のパケットも処理の対象にする DPCP_RCV_TIMEOUT , // タイムアウト時間(ミリ秒) ebuf )) == NULL ){ // error // exit(-1); } if( pcap_loop( pd , DPCP_NOLIMIT_LOOP , // エラーが発生するまで取得を続ける start_pktfunc, // パケット受信した時のCallBack関数 NULL // CallBack関数へ渡す引数 ) < 0 ){ // error exit(-1); } // pcap_close(pd); //printf("writing data:sleep 60 seconds\n"); //sleep(30); // return 0; }
/* initialize internal mac_list of other boxes we see eth_beacons from, * our internal LAN mac address, and our wireless mac address. (we send * the latter out in the eth_beacons, because the wireless mac address is * considered the "name" or identifier of each cloud box.) */ void eth_util_init(char *beacon_file, int socket, int if_index, pio_t *pio, mac_address_t eth_mac_addr, mac_address_t box_wlan_mac_addr) { mac_list_init(&beacons, beacon_file, mac_list_beacon_name, ETH_TIMEOUT_USEC, true); if (pio != NULL) { out_pio = pio; use_pipe = 1; } packet_socket = socket; eth_if_index = if_index; mac_copy(my_mac_addr, eth_mac_addr); mac_copy(name_mac_addr, box_wlan_mac_addr); }
int main(int argc, const char * argv[]){ // system("pwd"); // system("ls -al"); struct mac_list p; mac_list_init(); mac_list_add("XX.XX.XX.A1"); mac_list_add("XX.XX.XX.A2"); mac_list_add("XX.XX.XX.A3"); mac_list_add("XX.XX.XX.A4"); printf("count %d\n", mac_list_count()); return 0; }