void Arp::arp_resolve(Packet_ptr pckt) { debug("<ARP RESOLVE> %s\n", pckt->next_hop().str().c_str()); const auto next_hop = pckt->next_hop(); await_resolution(std::move(pckt), next_hop); auto req = static_unique_ptr_cast<PacketArp>(inet_.create_packet(sizeof(header))); req->init(mac_, inet_.ip_addr()); req->set_dest_mac(Ethernet::BROADCAST_FRAME); req->set_dest_ip(next_hop); req->set_opcode(H_request); // Stat increment requests sent requests_tx_++; linklayer_out_(std::move(req)); }
void Arp::arp_respond(header* hdr_in) { debug2("\t IP Match. Constructing ARP Reply\n"); // Stat increment replies sent replies_tx_++; // Populate ARP-header auto res = static_unique_ptr_cast<PacketArp>(inet_.create_packet(sizeof(header))); res->init(mac_, inet_.ip_addr()); res->set_dest_mac(hdr_in->shwaddr); res->set_dest_ip(hdr_in->sipaddr); res->set_opcode(H_reply); debug2("\t My IP: %s belongs to My Mac: %s\n", res->source_ip().str().c_str(), res->source_mac().str().c_str()); linklayer_out_(std::move(res)); }
unsigned char gsm_check_gprs( ) { //check gprs set_at_echo(0);//设置禁止回显 if( !check_gprs_net() ) { return 6 ; //no gprs network } //check gprs attached set_at_echo(0);//设置禁止回显 if( !check_gprs_att() ) { prompt("GPRS attache failure! mg323.cgatt: %d\r\n", my_icar.mg323.cgatt); return 7 ; //gprs attach failure } //set connect type if( !set_conn_type( ) ) { prompt("Set connect type error\r\n"); return 8 ; //set connect type error } //check apn if( !get_apn_by_imsi( ) ) { prompt("Get APN error\r\n"); return 9 ; //get apn error } debug_gsm("Get APN ok: %s %s %s\r\n", apn_list[my_icar.mg323.apn_index][1],\ apn_list[my_icar.mg323.apn_index][2],\ apn_list[my_icar.mg323.apn_index][3]); //set APN if( !set_gprs_apn( ) ) { debug_gsm("Set APN error\r\n"); return 10 ; //set apn error } prompt("Set APN ok.\r\n"); if ( *(apn_list[my_icar.mg323.apn_index][2]) ) { if( !set_gprs_user( ) ) { debug_gsm("Set APN user error\r\n"); return 10 ; //set apn user error } } if ( *(apn_list[my_icar.mg323.apn_index][3]) ) { if( !set_gprs_passwd( ) ) { debug_gsm("Set APN passwd error\r\n"); return 10 ; //set apn passwd error } } //set connect ID if( !set_conn_id( ) ) { prompt("Set connect id error\r\n"); return 11 ; //set connect type error } //set service type, only support socket if( !set_svr_type( ) ) { prompt("Set service type error\r\n"); return 12 ; //set svr type error } //set destination IP and port if( !set_dest_ip( ) ) { prompt("Set dest IP and port error\r\n"); return 13 ; //set dest IP and port error } prompt("Initiate GPRS setting ok\r\n"); return 0 ; }