int ParseToken(HttpState* state, int *bytesRead) { int i; int retval; int len; for (i = 0; i < (sizeof(FORMSpec)/sizeof(FORMType)); i++) { if (!strcmp(FORMSpec[i].name, state->buffer)) { parsePtr = FORMSpec[i].value; len = 0; retval = sock_fastread(&state->s, parsePtr, 1); while ((*bytesRead < (state->content_length - 2)) && (tcp_tick(&state->s) != 0) && (*parsePtr != '&')) { if (retval != 0) { (*bytesRead)++; if (len < (FORMSpec[i].len - 1)) { parsePtr++; len++; } } retval = sock_fastread(&state->s, parsePtr, 1); } *parsePtr = '\0'; } if (i < (sizeof(FORMSpec)/sizeof(FORMType) - 1) && (tcp_tick(&state->s) == 0)) { return -1; } } return 1; }
void main() { int bytes_read; char buffer[100]; /* Currently (DC 7.30), printf() has max 127 bytes it can output. */ tcp_Socket socket; sock_init(); while(1) { tcp_listen(&socket,PORT,0,0,NULL,0); printf("Waiting for connection...\n"); while(!sock_established(&socket) && sock_bytesready(&socket)==-1) tcp_tick(NULL); printf("Connection received...\n"); do { bytes_read=sock_fastread(&socket,buffer,sizeof(buffer)-1); if(bytes_read>0) { buffer[bytes_read]=0; printf("%s",buffer); sock_write(&socket,buffer,bytes_read); } } while(tcp_tick(&socket)); printf("Connection closed...\n"); } }
/* * Receive a message. The socket is re-opened and message read. The need * for a response is indicated. tcp_tick() fails if peer closed socket. */ void RecvMessage(tcp_Socket* tcpSock, int* respond) { auto char buffer[500]; auto int numBytes; tcp_listen(tcpSock, PORT, 0, 0, NULL, 0); dispClear(); /* Wait for connection. */ while( ! tcp_established( tcpSock ) ) { if( ! tcp_tick( (sock_type *) tcpSock ) ) { dispPrintf( "ERROR: listening: %s\n", tcpSock->err_msg ); exit( 99 ); } } /* Wait for some data to appear, or an error... */ while( 0 == (numBytes = sock_fastread(tcpSock, buffer, sizeof(buffer))) ) { if( ! tcp_tick( tcpSock ) ) { bad_read: dispPrintf( "ERROR: read: %s\n", tcpSock->err_msg ); exit( 99 ); } } if (numBytes == -1) { goto bad_read; } buffer[numBytes] = '\0'; dispPrintf("%s", buffer); *respond = 1; // Indicate the need for a response } /* end RecvMessage() */
void main(void) { /* * All initialization of TCP/IP, clients, servers, and I/O * must be done by the user prior to using any console * functions. */ sock_init(); /* * Initialize the console */ if (console_init() != 0) { printf("Could not load the console configuration!\n"); /* * Save the backup information to the console. */ con_backup(); } while (1) { /* * console_tick() drives the console. */ console_tick(); tcp_tick(NULL); } }
/* send one packet (heartbeat) */ int send_packet(void) { static long sequence; auto char buf[128]; auto int length, retval; #GLOBAL_INIT { sequence = 0; } /* fill the packet with interesting data (a sequence number) */ sequence++; sprintf(buf, "SEQ=%ld",sequence); length = strlen(buf) + 1; /* send the packet */ retval = udp_send(&sock, buf, length); if (retval < 0) { printf("Error sending datagram! Closing and reopening socket...\n"); if (sequence == 1) { printf(" (initial ARP request may not have finished)\n"); } sock_close(&sock); if(!udp_open(&sock, LOCAL_PORT, resolve(REMOTE_IP), REMOTE_PORT, NULL)) { printf("udp_open failed!\n"); exit(0); } } tcp_tick(NULL); return 1; }
void main() { sock_init(); // Wait for the interface to come up while (ifpending(IF_DEFAULT) == IF_COMING_UP) { tcp_tick(NULL); } #if _USER smtp_setserver(SMTP_SERVER); #endif #ifdef USE_SMTP_AUTH smtp_setauth ("myusername", "mypassword"); #endif smtp_sendmail(TO, FROM, SUBJECT, BODY); while(smtp_mailtick()==SMTP_PENDING) continue; if(smtp_status()==SMTP_SUCCESS) printf("Message sent\n"); else printf("Error sending message\n"); }
int main() { int line_num; // This is our data handler opaque parameter. sock_init(); // Wait for the interface to come up while (ifpending(IF_DEFAULT) == IF_COMING_UP) { tcp_tick(NULL); } #if _USER smtp_setserver(SMTP_SERVER); #endif #ifdef USE_SMTP_AUTH smtp_setauth ("myusername", "mypassword"); #endif smtp_sendmail(TO, FROM, SUBJECT, NULL); // No fixed message smtp_data_handler(mail_generator, &line_num, 0); // Set message generator function line_num = 1; // Initialize for data handler benefit. while(smtp_mailtick()==SMTP_PENDING) continue; if(smtp_status()==SMTP_SUCCESS) printf("Message sent\n"); else printf("Error sending message\n"); return 0; }
/* * Parse the url-encoded POST data into the FORMSpec struct * (ie: parse 'foo=bar&baz=qux' into the struct). Return -1 * on error. */ int ParsePost(HttpState* state) { int retval; int bytesRead; bytesRead = 0; while ((bytesRead < (state->content_length - 2)) && (tcp_tick(&state->s) != 0)) { retval = sock_fastread(&state->s, state->p, 1); if (retval != 0) { bytesRead++; if (*state->p == '=') { *state->p = '\0'; state->p = state->buffer; if (ParseToken(state, &bytesRead) == -1) { return -1; } } else { state->p++; } } } if (bytesRead == (state->content_length - 2)) { return 1; } else { return -1; } }
void main() { static long address; static int retval; sock_init(); // Wait for the interface to come up while (ifpending(IF_DEFAULT) == IF_COMING_UP) { tcp_tick(NULL); } pop3_init(storemsg); printf("Resolving name...\n"); address = resolve(POP_HOST); printf("Calling pop3_getmail()...\n"); pop3_getmail(POP_USER, POP_PASS, address); printf("Entering pop3_tick()...\n"); while((retval = pop3_tick()) == POP_PENDING) continue; if(retval == POP_SUCCESS) printf("POP was successful!\n"); if(retval == POP_TIME) printf("POP timed out!\n"); if(retval == POP_ERROR) printf("POP returned a general error!\n"); printf("All done!\n"); }
SSPEC_MIMETABLE_END void main() { /* * sock_init initializes the TCP/IP stack. * http_init initializes the web server. */ sock_init(); http_init(); /* * tcp_reserveport causes the web server to ignore requests when there * isn't an available socket (HTTP_MAXSERVERS are all serving index_html * or rabbit1.gif). This saves some memory, but can cause the client * delays when retrieving pages. */ tcp_reserveport(80); dlp_init(); /* * http_handler needs to be called to handle the active http servers. */ for(;;) { tcp_tick(NULL); http_handler(); dlp_handler(); } }
void main() { // Start network and wait for interface to come up (or error exit). sock_init_or_exit(1); for (;;) { tcp_tick(NULL); } }
/* * Send the response to the remote machine */ void SendMessage(tcp_Socket *tcpSock, unsigned key, char* messages[]) { sock_write(tcpSock, messages[key], strlen(messages[key])+1); sock_close(tcpSock); while (tcp_tick(tcpSock) != 0); return; }
/**************************************************************************** scan_assoc_callback Much like scan_callback above, this function is called as a result of a Wi-Fi scan. The main difference is that this function gives the user the option of associating with one of the BSS's. It uses scan_callback above to sort and print the scan results. Inputs: data -- far pointer to wifi_scan_data structure, which contains a count of the number of responses, and an array of _wifi_wln_scan_bss structures, with the first `count' containing valid data for the responses. ****************************************************************************/ root void scan_assoc_callback(far wifi_scan_data* data) { char c, ssid[WLN_SSID_SIZE+1]; int ssid_len; far _wifi_wln_scan_bss *bss; // Sort and print the scan results scan_callback(data); bss = data->bss; printf("\nSelect a new BSS or quit ([0-%x, q to quit)]\n", data->count-1); while (1) { tcp_tick(NULL); // While we're waiting, continue to tick. if (kbhit()) { c = getchar(); // Echo the character printf("%c\n", c); // Convert character to numeric value. if ('0' <= c && c <= '9') { c = c - '0'; } else if (isxdigit(c)) { c = (tolower(c) - 'a' + 10); } else if (tolower(c) == 'q') { printf("Quitting scan selection\n"); break; } if (c >= data->count) { printf("Unlisted option, quitting...\n"); break; } // c is now the index of the BSS the user opted to associate with bss = &(data->bss[c]); ssid_len = bss->ssid_len; // Need near copy of SSID to call ifconfig. ssid will be promoted to // far for this call, but the results will be in ssid as a near // variable _f_memcpy(ssid, bss->ssid, ssid_len); #ifdef IFC_WIFI_WPA_PSK_PASSPHRASE printf("Resetting the passphrase--this will take some time.\n"); #endif // Set the SSID. Also, if a passphrase has been defined as a macro, // then reconfigure the passphrase. This is necessary because the // passphrase and SSID together are used to generate the key. If the // SSID changes, then the generated key must change. Note that // regenerating the key will take about another 20 seconds on an // RCM54xxW. if (ifconfig (IF_WIFI0, IFS_WIFI_SSID, ssid_len, ssid, #ifdef IFC_WIFI_WPA_PSK_PASSPHRASE IFS_WIFI_WPA_PSK_PASSPHRASE, IFC_WIFI_WPA_PSK_PASSPHRASE, #endif IFS_END)) { printf (" error setting SSID\n"); } wifi_ssid_to_str (ssid, ssid, ssid_len); printf("Selected BSS is [%s]. Wait a bit, then check MAC status\n", ssid); break; } } }
int send_iac( char cmd, char opt) { byte io_data[3]; io_data[0] = IAC; io_data[1] = cmd; io_data[2] = opt; sock_fastwrite( s, io_data, 3 ); return( !tcp_tick( s )); }
void main(void) { int iferr; char ipbuf[16]; printf("Starting the network interface..."); sock_init(); printf("done.\nConfiguring the network interface..."); iferr = ifconfig(IF_DEFAULT, IFS_DHCP, 0, IFS_IPADDR, DHCPD_ADDRESS, IFS_NETMASK, DHCPD_NETMASK, IFS_UP, IFS_END); printf("done (result %d).\n\n", iferr); printf("Starting the dhcp server (v%s).\n", DHCPD_VER_STR); if (dhcpd_init(IF_DEFAULT)) { printf("dhcpd_init() failed, program terminated.\n"); } else { printf(" server ip: %s\n", inet_ntoa (ipbuf, DHCPD_ADDRESS)); printf("subnet mask: %s\n", inet_ntoa (ipbuf, DHCPD_NETMASK)); printf("dhcpd serving addresses from .1 to .%u\n", DHCPD_MAX_HOST); #ifdef PERMANENT_LEASE_MAC_ADDRESS // IP address .1 goes to PERMANENT_LEASE_MAC_ADDRESS dhcpd_add_permanent(1, PERMANENT_LEASE_MAC_ADDRESS); #endif // dump the complete DHCP leases table, including empty entries dhcpd_dump_leases(1); printf("Press 'D' to dump the table of DHCP leases.\n"); while (1) { tcp_tick(NULL); dhcpd_tick(); if (kbhit()) { switch (getchar()) { case 'd': case 'D': // dump only the used entries in the DHCP leases table dhcpd_dump_leases(0); break; } } } } }
void set_nist_time(){ int dst, health; struct tm t; unsigned long longsec; char response[100]; int bytes_read,total_bytes; tcp_Socket sock; longword nist_server; printf("Trying to set time from NIST server...\n"); //get the time if (!(nist_server = resolve(NIST_SERVER))) { printf(" ! Could not resolve time host\n"); exit( 3 ); } if( !tcp_open(&sock,0,nist_server,NIST_PORT,NULL)){ printf(" ! Unable to connect to time server\n"); exit( 3 ); } while (!sock_established(&sock) && sock_bytesready(&sock)==-1){ tcp_tick(NULL); } sock_mode(&sock, TCP_MODE_ASCII); total_bytes=0; do{ bytes_read=sock_fastread(&sock,response+total_bytes,sizeof(response)-1-total_bytes); total_bytes+=bytes_read; } while(tcp_tick(&sock) && (total_bytes < sizeof(response)-2)); //parse it t.tm_year = 100 + 10*(response[7]-'0') + (response[8]-'0'); t.tm_mon = 10*(response[10]-'0') + (response[11]-'0'); t.tm_mday = 10*(response[13]-'0') + (response[14]-'0'); t.tm_hour = 10*(response[16]-'0') + (response[17]-'0'); t.tm_min = 10*(response[19]-'0') + (response[20]-'0'); t.tm_sec = 10*(response[22]-'0') + (response[23]-'0'); dst = 10*(response[25]-'0') + (response[26]-'0'); health = response[28]-'0'; longsec = mktime(&t); longsec += 3600ul * NIST_TIMEZONE; // adjust for timezone if (dst != 0) longsec += 3600ul; // DST is in effect if (health < 2) write_rtc(longsec); printf(" Time set to : "); print_time(read_rtc()); }
void main() { /* init the TCP/IP stack and the Ethernet Loader */ sock_init(); targetproc_init(); /* drive it all */ while(1) { tcp_tick(NULL); targetproc_tick(); } }
/* * Send the response to the remote machine. Close the socket. */ void SendMessage(tcp_Socket *tcpSock, unsigned key, char* messages[]) { auto char * p; auto int len; /* Use sock_fastwrite() here to encourage good programming practices. */ sock_write(tcpSock, messages[key-1], strlen(messages[key-1])+1); sock_close(tcpSock); while (tcp_tick(tcpSock) != 0); dispClear(); dispPrintf("Response sent"); }
/********************************************************************************* This function handles and controls the xml socket. ********************************************************************************/ void My_Handler(My_Socket_Type *my_sock) { static char ipaddr[25],DispStrOut[100]; switch(my_sock->nextstate) { case 0:/*INITIALIZATION*/ // listen for incoming connection inet_ntoa( ipaddr, my_ip_addr ); sprintf(DispStrOut,"OFFLINE\nCONNECT TO\nIP: %s\nPORT: %d", ipaddr, MY_PORT); while(!btnMsgBox(40,0,240,90,&fi14x16,DispStrOut,1,1)); if(tcp_listen(&my_sock->sock,MY_PORT,INCOMING_IP,INCOMING_PORT,NULL,0)) { my_sock->rxbytes = my_sock->txbytes = 0; my_sock->statetime = 0L; (my_sock->nextstate)++; // init complete move onto next state my_sock->statetime = MS_TIMER+TCP_TIMEOUT; // reset the statetime } else exit(0); break; case 1://LISTEN// if(sock_established(&my_sock->sock)) // check for a connection { inet_ntoa(ipaddr,my_sock->sock.hisaddr); sprintf(DispStrOut,"CONNECTED\nIP: %s",ipaddr); while(!btnMsgBox(40,0,240,90,&fi14x16,DispStrOut,1,0)); //printf("%s\nConnection Established.\n",BLACK); (my_sock->statetime) = MS_TIMER+TCP_TIMEOUT; // reset statetime for RECEIVE state (my_sock->nextstate)++; // we have connection so move on } else if ((long)(MS_TIMER-(my_sock->statetime)) > 0) // if X sec and no sock my_sock->nextstate = 4; // abort and re-init break; case 2://RECEIVE// my_sock->nextstate = My_Rcv_Pkt(my_sock); // see function for details if ((long)(MS_TIMER-(my_sock->statetime)) > 0) // if X sec and still waiting my_sock->nextstate = 4; // abort and re-init break; case 3://SEND// my_sock->nextstate = My_Snd_Pkt(my_sock); // see function for details if ((long)(MS_TIMER-(my_sock->statetime)) > 0) // if X sec and still waiting my_sock->nextstate = 4; // abort and re-init break; case 4://NO WAIT_CLOSE// sock_abort(&my_sock->sock); // close the socket my_sock->nextstate = 0; // go back to the INIT state } if(!tcp_tick(&my_sock->sock)) my_sock->nextstate = 0; }
void main() { // Start network and wait for interface to come up (or error exit). sock_init_or_exit(1); if(!udp_extopen(&sock, IF_ANY, LOCAL_PORT, -1L, 0, echo_handler, 0, 0)) { printf("udp_extopen failed!\n"); exit(0); } /* Let the stack do everything... */ for(;;) tcp_tick(NULL); }
/* * Receive a message. The connected socket and is sent back, and the need * for a response is indicated. */ void RecvMessage(tcp_Socket* tcpSock) { auto char buffer[500]; auto int numBytes; tcp_listen(tcpSock, PORT, 0, 0, NULL, 0); /* Wait for connection. */ while( ! tcp_established( tcpSock ) ) { if( ! tcp_tick( (sock_type *) tcpSock ) ) { TextGotoXY(&wholewindow, 0, 0 ); TextPrintf(&wholewindow, "Error: listen"); return; } } /* Wait for some data to appear, or an error... */ while((numBytes = sock_fastread(tcpSock, buffer, sizeof(buffer))) == 0 ) { if( ! tcp_tick( tcpSock ) || numBytes == -1 ) { TextGotoXY(&wholewindow, 0, 0 ); TextPrintf(&wholewindow, "Error: read"); return; } } // Display received from other controller glBlankScreen(); TextGotoXY(&wholewindow, 0, 0 ); TextPrintf(&wholewindow, "Message received:"); buffer[numBytes] = '\0'; TextGotoXY(&wholewindow, 0, 1 ); TextPrintf(&wholewindow, "%s", buffer); } /* end RecvMessage() */
void main() { int state,status; state = 0; sock_init(); while(1) { switch(state) { case 0:/*INITIALIZATION*/ // listen for incoming connection if(!tcp_listen(&sock,MY_PORT,INCOMING_IP,INCOMING_PORT,NULL,0)) printf("%sERROR OPENNING SOCKET!\n",RED); else { printf("%swaiting for incomming session\n",GREEN); statetime = MS_TIMER+TIME_OUT; // setup the time to be in LISTEN state state++; // init complete move onto next state } break; case 1:/*LISTEN*/ if(sock_established(&sock)) // check for a connection { printf("%ssocket established\n",BLUE); statetime = MS_TIMER+TIME_OUT; // reset time to be in the RECEIVE state state++; // we have connection so move on } else if ((long)(MS_TIMER-statetime) > 0) // if X millisecs and still waiting state = 4; // abort and re-init break; case 2:/*RECEIVE*/ state = receive_packet(); // see function for details if ((long)(MS_TIMER-statetime) > 0) // if X millisecs and still waiting state = 4; // abort and re-init break; case 3:/*SEND*/ state = send_packet(); // see function for details if ((long)(MS_TIMER-statetime) > 0) // if X millisecs and still waiting state = 4; // abort and re-init break; case 4:/*NO WAIT_CLOSE*/ printf("%sABORT SOCKET\n",RED); sock_abort(&sock); // close the socket state = 0; // go back to the INIT state } status = tcp_tick(&sock); } }
/** * Does network and HTTP setup */ void setupHttp() { // IP Buffer char buffer[16]; // User ID int userid; // Initialize the board brdInit(); // Initialize the socket sock_init(); // Wait for IP address to be obtained while (ifpending(IF_DEFAULT) == IF_COMING_UP) { tcp_tick(NULL); } // Output the IP Address printf("My IP address is %s\n", inet_ntoa(buffer, gethostid())); //Set up the HTTP Server http_init(); tcp_reserveport(80); // Set redirect http_set_path("/", "/index.zhtml"); // Set up authentication sspec_addrule("/", "Admin", admin, admin, SERVER_ANY, SERVER_AUTH_BASIC, NULL); // Add our users // Ario userid = sauth_adduser("ario", "fish", SERVER_ANY); sauth_setusermask(userid, admin, NULL); // Chan userid = sauth_adduser("chan", "bar", SERVER_ANY); sauth_setusermask(userid, admin, NULL); // Jeff userid = sauth_adduser("jeff", "bar7", SERVER_ANY); sauth_setusermask(userid, admin, NULL); // Shea userid = sauth_adduser("shea", "bar2", SERVER_ANY); sauth_setusermask(userid, admin, NULL); // Toby userid = sauth_adduser("toby", "bar3", SERVER_ANY); sauth_setusermask(userid, admin, NULL); //Done }
main() { char ch; long ipaddr; char ipaddr_string[16]; printf ("Wi-Fi DHCP or Static sample\n"); do { // Prompt for configuration method printf("Select method (s=static, d=dhcp): "); ch=getchar(); // Give feedback on the choice printf("%c\n",ch); if(ch=='s' || ch=='S') { // Bring the interface up statically configured printf ("configuring interface for static IP\n"); ifconfig(IF_WIFI0, IFS_IPADDR,aton(_PRIMARY_STATIC_IP), IFS_NETMASK, aton(_PRIMARY_NETMASK), IFS_ROUTER_SET, aton(MY_GATEWAY), IFS_END); break; } else if(ch=='d' || ch=='D') { // Bring the interface up with DCHP printf ("configuring interface for DHCP\n"); ifconfig(IF_WIFI0, IFS_DHCP, 1, IFS_END); break; } else { printf("Invalid selection\n\n"); } } while(1); // Initialize the TCP/IP stack sock_init_or_exit(1); // Print the IP Address to stdio ifconfig(IF_WIFI0,IFG_IPADDR,&ipaddr,IFS_END); printf("IP Address: %s -- responding to pings\n",inet_ntoa(ipaddr_string,ipaddr)); // Give the stack time... Ready to be PINGed while(1) { tcp_tick(NULL); } }
static void interrupt newinterrupt( void ) { (*oldinterrupt)(); disable(); if (!sem_up( &inside )) { oldss = _SS; oldsp = _SP; _SP = FP_OFF( &tempstack[ sizeof( tempstack ) - 4 ] ); _SS = FP_SEG( tempstack ); enable(); if (userroutine) (*userroutine)(); tcp_tick( NULL ); disable(); _SP = oldsp; _SS = oldss; inside = 0; } enable(); }
static INTR_PROTOTYPE newinterrupt (void) { (*oldinterrupt)(); DISABLE(); if (inside) { static UINT tempstack [STK_SIZE]; #ifdef __WATCOMC__ STACK_SET (&tempstack[STK_SIZE-1]); #else static UINT old_SP; static WORD old_SS; asm mov ax, ss asm mov old_SS, ax asm mov ax, sp asm mov old_SP, ax asm mov ax, ds asm mov ss, ax asm lea sp, tempstack[STK_SIZE-1] #endif ENABLE(); if (user_routine) (*user_routine)(); tcp_tick (NULL); DISABLE(); #ifdef __WATCOMC__ STACK_RESTORE(); #else asm mov ax, old_SS asm mov ss, ax asm mov ax, old_SP asm mov sp, ax #endif inside = 0; } ENABLE(); }
static void interrupt newinterrupt(void) { (*oldinterrupt)(); DISABLE(); if (inside) { static UINT tempstack [STK_SIZE]; #ifdef __WATCOMC__ stackset (&tempstack[STK_SIZE-1]); #else static UINT old_SP; static WORD old_SS; asm mov ax,ss asm mov old_SS,ax asm mov ax,sp asm mov old_SP,ax asm mov ax,ds asm mov ss,ax asm lea sp,tempstack[STK_SIZE-1] #endif ENABLE(); if (userRoutine) (*userRoutine)(); tcp_tick (NULL); DISABLE(); #ifdef __WATCOMC__ stackrestore(); #else asm mov ax,old_SS asm mov ss,ax asm mov ax,old_SP asm mov sp,ax #endif inside = 0; } ENABLE(); }
void main() { sock_init(); /*printf("Opening UDP socket\n");*/ if(!udp_open(&sock, LOCAL_PORT, resolve(REMOTE_IP), REMOTE_PORT, NULL)) { printf("udp_open failed!\n"); exit(0); } /* send heartbeats */ for(;;) { //putchar('.'); tcp_tick(NULL); costate { waitfor(IntervalSec(HEARTBEAT_RATE)); waitfor(send_packet()); } } }
static int reverse_lookup (question_t *q, char *name, DWORD nameserver) { int i, ret; int ready = 0; udp_Socket dom_sock; if (!nameserver || /* no nameserver, give up */ dns_timeout == 0) return (0); udp_open (&dom_sock, 997, nameserver, 53, NULL); for (i = 2; i < 17 && !_resolve_exit; i *= 2) { sock_write ((sock_type*)&dom_sock, (BYTE*)q, sizeof(*q)); ip_timer_init (&dom_sock, i); do { kbhit(); tcp_tick ((sock_type*)&dom_sock); if (watcbroke || (_resolve_hook && (*_resolve_hook)() == 0)) { _resolve_exit = 1; break; } if (ip_timer_expired(&dom_sock) || chk_timeout(resolve_timeout)) break; if (sock_dataready((sock_type*)&dom_sock)) ready = 1; } while (!ready); } if (ready) ret = getresult (&dom_sock, name); else ret = 0; sock_close ((sock_type*)&dom_sock); return (ret); }
/** * Loop waiting for timeout or a PAD response. * Blocks until some got_X flags in by pppoe_handler(). */ static BOOL pppoe_wait (int wait_code) { DWORD timer = set_timeout (1000 * cfg.timeout); while (1) { tcp_tick (NULL); if ((wait_code == PPPOE_CODE_PADO && got_PADO) || (wait_code == PPPOE_CODE_PADS && got_PADS)) { #if defined(USE_DEBUG) if (cfg.trace) (*_printf) ("PPPoE: got %s\n", pppoe_get_code(wait_code)); #endif return (TRUE); } if (chk_timeout(timer)) break; } return (FALSE); }