bool test_host_resolver::TestResolveIPs::operator()() { host_resolver IP1("192.168.0.1"); if (IP1.get_host().to_string() != "192.168.0.1") return false; host_resolver IP2("255.255.255.255"); if (IP2.get_host().to_string() != "255.255.255.255") return false; host_resolver IP3("0.0.0.0"); if (IP3.get_host().to_string() != "0.0.0.0") return false; return true; }
/* main(): * The equivalent of the MONCMD server built into uMon... * Blocks on port 777 waiting for an incoming message, then * responds with "thanks". */ int main(int argc, char *argv[]) { int rc = 0; unetStart(); cmdInit(); mon_printf("%s: MONCMD server using uMon's ethernet API...\n", argv[0]); /* This loop processes incoming UDP and incoming serial port * (console) activity... Terminate on reception of ctrl-c * (0x03) from console. */ while(1) { if (mon_gotachar()) { int c = mon_getchar(); if (c == 0x03) { mon_printf("\n<ctrl-c>\n"); break; } else processChar(c); } /* Set up the server to receive packets on any port... * Then after udpRecvFrom returns, use the value of u.dport * to determine which port the packet came in on. */ udpInfo.dport = ANY_UDP_PORT; udpInfo.packet = (char *)unetPacket; udpInfo.plen = sizeof(unetPacket); /* Check for an incoming packet. This does not block. It will * return negative if there is an error, zero of there is no packet * pending; else some positive number representing the incoming * packet size. */ rc = udpRecvFrom(&udpInfo); if (rc > 0) { if (udpInfo.dport == 777) { udp_umoncmd((char *)udpInfo.udata); } else { mon_printf("\nUDP rcv'd on port %d, from %d.%d.%d.%d:%d ...\n", udpInfo.dport, IP1(udpInfo.sip.s_addr), IP2(udpInfo.sip.s_addr), IP3(udpInfo.sip.s_addr), IP4(udpInfo.sip.s_addr), udpInfo.sport); mon_printmem((char *)udpInfo.udata,rc,1); } } else if (rc < 0) { unetError("recv",rc,UNETACT_ALL); } } unetStop(); return(0); }
void FC_handle_message( sys_scatter *scat ) { int16 *cur_fc_buf; packet_header *pack_ptr; proc dummy_proc; int my_index; int16 temp_window,temp_personal_window; configuration *Cn; Cn = Conf_ref(); pack_ptr = (packet_header *)scat->elements[0].buf; if ( ! Conf_get_dangerous_monitor_state() ) { Alarm( FLOW_CONTROL, "FC_handle_message: Request to change flow control from (%d.%d.%d.%d) denied. Monitor in safe mode\n", IP1(pack_ptr->proc_id), IP2(pack_ptr->proc_id), IP3(pack_ptr->proc_id), IP4(pack_ptr->proc_id) ); return; } if( ! ( pack_ptr->memb_id.proc_id == 15051963 && Conf_id_in_conf( Cn, pack_ptr->proc_id ) != -1 ) ) { Alarm( FLOW_CONTROL, "FC_handle_message: Illegal monitor request\n"); return; } cur_fc_buf = (int16 *)scat->elements[1].buf; my_index = Conf_proc_by_id( Conf_my().id, &dummy_proc ); if( Same_endian( pack_ptr->type ) ) { temp_window = cur_fc_buf[Conf_num_procs( Cn )]; temp_personal_window = cur_fc_buf[my_index]; }else{ temp_window = Flip_int16( cur_fc_buf[Conf_num_procs( Cn )] ); temp_personal_window = Flip_int16( cur_fc_buf[my_index] ); } if( temp_window != -1 ) Window = temp_window; if( temp_personal_window != -1 ) Personal_window = temp_personal_window; GlobalStatus.window = Window; GlobalStatus.personal_window = Personal_window; Alarm( FLOW_CONTROL, "FC_handle_message: Got monitor mess, Window %d Personal %d\n", Window, Personal_window ); }