这篇教程C++ uip_rexmit函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中uip_rexmit函数的典型用法代码示例。如果您正苦于以下问题:C++ uip_rexmit函数的具体用法?C++ uip_rexmit怎么用?C++ uip_rexmit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了uip_rexmit函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: irc_mainstatic voidirc_main(void){ if (uip_aborted() || uip_timedout()) { IRCDEBUG ("connection aborted/n"); irc_conn = NULL; } if (uip_closed()) { IRCDEBUG ("connection closed/n"); irc_conn = NULL; } if (uip_connected()) { IRCDEBUG ("new connection/n"); STATE->stage = IRC_SEND_USERNICK; STATE->sent = IRC_SEND_INIT;#ifdef ECMD_IRC_SUPPORT STATE->reparse = 0;#endif *STATE->outbuf = 0; } if (STATE->stage == IRC_SEND_JOIN && uip_acked ()) STATE->stage ++; else if (STATE->stage == IRC_CONNECTED && uip_acked ()) { *STATE->outbuf = 0;#ifdef ECMD_IRC_SUPPORT if (STATE->reparse) irc_handle_ecmd ();#endif } else if (uip_newdata() && uip_len) { ((char *) uip_appdata)[uip_len] = 0; IRCDEBUG ("received data: %s/n", uip_appdata); if (irc_parse ()) { uip_close (); /* Parse error */ return; } } if (uip_rexmit ()) irc_send_data (STATE->sent); else if ((STATE->stage > STATE->sent || STATE->stage == IRC_CONNECTED) && (uip_newdata() || uip_acked() || uip_connected())) irc_send_data (STATE->stage); else if (STATE->stage == IRC_CONNECTED && uip_poll() && *STATE->outbuf) irc_send_data (STATE->stage);}
开发者ID:HansBaechle,项目名称:ethersex,代码行数:59,
示例2: webclient_appcall/*-----------------------------------------------------------------------------------*/voidwebclient_appcall(void){ if(uip_connected()) { s.timer = 0; s.state = WEBCLIENT_STATE_STATUSLINE; senddata(); webclient_connected(); return; } if(s.state == WEBCLIENT_STATE_CLOSE) { webclient_closed(); uip_abort(); return; } if(uip_aborted()) { webclient_aborted(); } if(uip_timedout()) { webclient_timedout(); } if(uip_acked()) { s.timer = 0; acked(); } if(uip_newdata()) { s.timer = 0; newdata(); } if(uip_rexmit() || uip_newdata() || uip_acked()) { senddata(); } else if(uip_poll()) { ++s.timer; if(s.timer == WEBCLIENT_TIMEOUT) { webclient_timedout(); uip_abort(); return; } /* senddata();*/ } if(uip_closed()) { if(s.httpflag != HTTPFLAG_MOVED) { /* Send NULL data to signal EOF. */ webclient_datahandler(NULL, 0); } else { if(resolv_lookup(s.host) == NULL) { resolv_query(s.host); } webclient_get(s.host, s.port, s.file); } }}
开发者ID:Ascenix,项目名称:uip_rx62n_cloud,代码行数:60,
示例3: yport_net_mainvoid yport_net_main(void){ if(uip_connected()) { if (yport_conn == NULL) { yport_conn = uip_conn; uip_conn->wnd = YPORT_BUFFER_LEN - 1; } else /* if we have already an connection, send an error */ uip_send("ERROR: Connection blocked/n", 27); } else if (uip_acked()) { /* If the peer is not our connection, close it */ if (yport_conn != uip_conn) uip_close(); else { /* Some data we have sent was acked, jipphie */ /* disable interrupts */ uint8_t sreg = SREG; cli(); yport_recv_buffer.len -= yport_recv_buffer.sent; /* We should use memmove, because the data may overlap */ memmove(yport_recv_buffer.data, yport_recv_buffer.data + yport_recv_buffer.sent, yport_recv_buffer.len); /* enable interrupts again */ SREG = sreg; } } else if (uip_closed() || uip_aborted() || uip_timedout()) { /* if the closed connection was our connection, clean yport_conn */ if (yport_conn == uip_conn) yport_conn = NULL; } else if (uip_newdata()) { if (uip_len <= YPORT_BUFFER_LEN && yport_rxstart(uip_appdata, uip_len) != 0) { /* Prevent the other side from sending more data */ uip_stop(); } } if (uip_poll() && uip_conn == yport_conn && uip_stopped(yport_conn) && yport_send_buffer.sent == yport_send_buffer.len) uip_restart(); /* Send data */ if ((uip_poll() || uip_acked() || uip_rexmit()) && yport_conn == uip_conn && yport_recv_buffer.len > 0) { /* We have recieved data, lets propagade it */ /* disable interrupts */ uint8_t sreg = SREG; cli(); /* Send the data */ uip_send(yport_recv_buffer.data, yport_recv_buffer.len); /* so many data was send */ yport_recv_buffer.sent = yport_recv_buffer.len; /* enable interrupts again */ SREG = sreg; }}
开发者ID:muccc,项目名称:matemat,代码行数:58,
示例4: telnetd_appcall/*---------------------------------------------------------------------------*/voidtelnetd_appcall(void *ts){ if(uip_connected()) { if(!connected) { buf_init(&buf); s.bufptr = 0; s.state = STATE_NORMAL; connected = 1; shell_start(); timer_set(&s.silence_timer, MAX_SILENCE_TIME); ts = (char *)0; } else { uip_send(telnetd_reject_text, strlen(telnetd_reject_text)); ts = (char *)1; } tcp_markconn(uip_conn, ts); } if(!ts) { if(s.state == STATE_CLOSE) { s.state = STATE_NORMAL; uip_close(); return; } if(uip_closed() || uip_aborted() || uip_timedout()) { shell_stop(); connected = 0; } if(uip_acked()) { timer_set(&s.silence_timer, MAX_SILENCE_TIME); acked(); } if(uip_newdata()) { timer_set(&s.silence_timer, MAX_SILENCE_TIME); newdata(); } if(uip_rexmit() || uip_newdata() || uip_acked() || uip_connected() || uip_poll()) { senddata(); if(s.numsent > 0) { timer_set(&s.silence_timer, MAX_SILENCE_TIME); } } if(uip_poll()) { if(timer_expired(&s.silence_timer)) { uip_close(); tcp_markconn(uip_conn, NULL); } } }}
开发者ID:Abdellazizhammami,项目名称:contiki,代码行数:58,
示例5: jabber_mainstatic voidjabber_main(void){ if (uip_aborted() || uip_timedout()) { JABDEBUG("connection aborted/n"); jabber_conn = NULL; } if (uip_closed()) { JABDEBUG("connection closed/n"); jabber_conn = NULL; } if (uip_connected()) { JABDEBUG("new connection/n"); STATE->stage = JABBER_OPEN_STREAM; STATE->sent = JABBER_INIT;#ifdef JABBER_STARTUP_MESSAGE_SUPPORT strncpy_P(STATE->target, PSTR(CONF_JABBER_BUDDY), sizeof(STATE->target)); strncpy_P(STATE->outbuf, jabber_startup_text, sizeof(STATE->outbuf)); STATE->action = JABBER_ACTION_MESSAGE;#endif /* JABBER_STARTUP_MESSAGE_SUPPORT */ } if (uip_acked() && STATE->stage == JABBER_CONNECTED) { STATE->action = JABBER_ACTION_NONE; *STATE->outbuf = 0; } if (uip_newdata() && uip_len) { /* Zero-terminate */ ((char *) uip_appdata)[uip_len] = 0; JABDEBUG("received data: %s/n", uip_appdata); if (jabber_parse()) { uip_close(); /* Parse error */ return; } } if (uip_rexmit()) jabber_send_data(STATE->stage, STATE->action); else if ((STATE->stage > STATE->sent || STATE->stage == JABBER_CONNECTED) && (uip_newdata() || uip_acked() || uip_connected())) jabber_send_data(STATE->stage, STATE->action); else if (STATE->stage == JABBER_CONNECTED && uip_poll() && STATE->action) jabber_send_data(STATE->stage, STATE->action);}
开发者ID:AnDann,项目名称:ethersex,代码行数:57,
示例6: netcon_app_callvoid netcon_app_call(void){ if(uip_newdata()) { parse_request(); } if(uip_rexmit()) { // Psst no one saw this :D strcpy_P(uip_appdata, PSTR("ERROR/r/n")); uip_send(uip_appdata, 7); }}
开发者ID:sli92,项目名称:netcon,代码行数:12,
示例7: httpd_mainvoidhttpd_main(void){ if (uip_aborted() || uip_timedout()) { httpd_cleanup (); printf ("httpd: connection aborted/n"); } if (uip_closed()) { httpd_cleanup (); printf ("httpd: connection closed/n"); } if (uip_connected()) { printf ("httpd: new connection/n"); /* initialize struct */ STATE->handler = NULL; STATE->header_acked = 0; STATE->eof = 0; STATE->header_reparse = 0;#ifdef HTTPD_AUTH_SUPPORT STATE->auth_state = PAM_UNKOWN;#endif } if (uip_newdata() && (!STATE->handler || STATE->header_reparse)) { printf ("httpd: new data/n"); httpd_handle_input (); }#ifdef HTTPD_AUTH_SUPPORT if (STATE->auth_state == PAM_DENIED && STATE->handler != httpd_handle_401) { httpd_cleanup(); STATE->handler = httpd_handle_401; STATE->header_reparse = 0; printf("httpd: auth failed/n"); } else if (STATE->auth_state == PAM_PENDING) return; /* Waiting for the PAM Layer */#endif if(uip_rexmit() || uip_newdata() || uip_acked() || uip_poll() || uip_connected()) { /* Call associated handler, if set already. */ if (STATE->handler && (!STATE->header_reparse)) STATE->handler (); }}
开发者ID:HansBaechle,项目名称:ethersex,代码行数:53,
示例8: send_data_Pchar send_data_P(register struct psock *s){ if(s->state != STATE_DATA_SENT || uip_rexmit()) { if(s->sendlen > uip_mss()) { uip_send_P((PGM_P)s->sendptr, uip_mss()); } else { uip_send_P((PGM_P)s->sendptr, s->sendlen); } s->state = STATE_DATA_SENT; return 1; } return 0;}
开发者ID:andykarpov,项目名称:EtherBright,代码行数:13,
示例9: exosite_appcall/******************************************************************************* void exosite_appcall(void)** This function is uIP's application function. It is called whenever a uIP * event occurs (e.g. when a new connection is established, new data arrives, * sent data is acknowledged, data needs to be retransmitted, etc.).* ******************************************************************************/ void exosite_appcall(void){ if(uip_connected()) { s.timer = 0; senddata(); return; } if(s.state == EXO_STATE_CLOSE) { uip_abort(); return; } if(uip_aborted()) { } if(uip_timedout()) { } if(uip_acked()) { s.timer = 0; acked(); } if(uip_newdata()) { s.timer = 0; newdata(); } if(uip_rexmit() || uip_newdata() || uip_acked()) { senddata(); } else if(uip_poll()) { ++s.timer; if(s.timer == EXO_TIMEOUT) { uip_abort(); return; } }#if 0 if(uip_closed()) { if(s.httpflag != HTTPFLAG_MOVED) { memset(s.rxdata,0,sizeof(s.rxdata)); } else { if(resolv_lookup(s.host) == NULL) { resolv_query(s.host); } } }#endif}
开发者ID:exosite-garage,项目名称:rx62n_pmod_cloud,代码行数:58,
示例10: send_data/*---------------------------------------------------------------------------*/static charsend_data(struct psock *s){ if(s->state != STATE_DATA_SENT || uip_rexmit()) { if(s->sendlen > uip_mss()) { uip_send(s->sendptr, uip_mss()); } else { uip_send(s->sendptr, s->sendlen); } s->state = STATE_DATA_SENT; return 1; } return 0;}
开发者ID:cristi85,项目名称:uIP_ENC28J60,代码行数:15,
示例11: send_data/*---------------------------------------------------------------------------*/static charsend_data(register struct psock *s){ if(s->state != STATE_DATA_SENT || uip_rexmit()) { // printf("sd %d/n",s->sendlen ); if(s->sendlen > uip_mss()) { uip_send(s->sendptr, uip_mss()); } else { uip_send(s->sendptr, s->sendlen); } s->state = STATE_DATA_SENT; return 1; } return 0;}
开发者ID:bergyla,项目名称:mist-board,代码行数:16,
示例12: ustream_mainvoid ustream_main(void){ if(uip_connected() || uip_rexmit()) { uip_send(USTREAM_URI, strlen(USTREAM_URI)); return; } if(uip_newdata()) { // TBD: Push data to VS1053 ((char *) uip_appdata)[uip_len] = 0; printf("Got some data./n"); }}
开发者ID:thkaiser,项目名称:ethersex,代码行数:15,
示例13: mysql_mainstatic voidmysql_main(void){ if (uip_aborted() || uip_timedout()) { MYDEBUG ("connection aborted/n"); mysql_conn = NULL; } if (uip_closed()) { MYDEBUG ("connection closed/n"); mysql_conn = NULL; } if (uip_connected()) { MYDEBUG ("new connection/n"); STATE->stage = MYSQL_WAIT_GREETING; STATE->sent = MYSQL_WAIT_GREETING; STATE->packetid = 0; } if (uip_newdata() && uip_len) {#ifdef DEBUG_MYSQL MYDEBUG ("received data: %s/n", uip_appdata); for (uint16_t i = 0; i < uip_len; i ++) debug_putchar (((unsigned char *) uip_appdata)[i]); debug_putchar (10);#endif if (mysql_parse ()) { uip_close (); /* Parse error */ return; } } if (uip_rexmit()) { STATE->packetid --; mysql_send_data (STATE->sent); } else if ((STATE->stage > STATE->sent || STATE->stage == MYSQL_CONNECTED) && (uip_newdata() || uip_acked() || uip_connected())) mysql_send_data (STATE->stage); else if (STATE->stage == MYSQL_CONNECTED && uip_poll() && *STATE->u.stmtbuf) mysql_send_data(STATE->stage);}
开发者ID:simeonfelis,项目名称:ethersex,代码行数:48,
示例14: mqttclient_appcallvoid mqttclient_appcall(void) { if (uip_poll()) { _mqttclient_transfer_buffer(); } else if (uip_connected()) { update_state(MQTTCLIENT_BROKER_CONNECTION_ESTABLISHED); umqtt_connect(&_mqtt, &_connection_config); _mqttclient_transfer_buffer(); } else if (uip_aborted() || uip_timedout() || uip_closed()) { _mqttclient_handle_communication_error(); } else if (uip_newdata()) { _mqttclient_handle_new_data(); } else if (uip_acked()) { _is_sending = false; } else if (uip_rexmit()) { _mqttclient_send(); }}
开发者ID:mcmatrix,项目名称:avr-dht22-node,代码行数:17,
示例15: httplog_net_mainstatic voidhttplog_net_main(void){ if (uip_aborted() || uip_timedout()) { HTTPLOG_DEBUG("connection aborted/n"); goto end; } if (uip_closed()) { HTTPLOG_DEBUG("connection closed/n"); goto end; } if (uip_connected() || uip_rexmit()) { HTTPLOG_DEBUG("new connection or rexmit, sending message/n"); char *p = uip_appdata; p += sprintf_P(p, get_string_head);#ifdef CONF_HTTPLOG_INCLUDE_UUID p += sprintf_P(p, uuid_string);#endif#ifdef CONF_HTTPLOG_INCLUDE_TIMESTAMP p += sprintf_P(p, time_string); p += sprintf(p, "%lu&", clock_get_time());#endif p += sprintf(p, httplog_tmp_buf); p += sprintf_P(p, get_string_foot); uip_udp_send(p - (char *) uip_appdata); HTTPLOG_DEBUG("send %d bytes/n", p - (char *) uip_appdata); } if (uip_acked()) { uip_close(); end: if (httplog_tmp_buf) { free(httplog_tmp_buf); httplog_tmp_buf = NULL; } }}
开发者ID:picohari,项目名称:intewa_firmware,代码行数:45,
示例16: telnet_app/*-----------------------------------------------------------------------------------*/voidtelnet_app(void *ts){ struct telnet_state *s = (struct telnet_state *)ts; if(uip_connected()) { s->flags = 0; telnet_connected(s); senddata(s); return; } if(uip_closed()) { telnet_closed(s); } if(uip_aborted()) { telnet_aborted(s); } if(uip_timedout()) { telnet_timedout(s); } if(s->flags & FLAG_CLOSE) { uip_close(); return; } if(s->flags & FLAG_ABORT) { uip_abort(); return; } if(uip_acked()) { acked(s); } if(uip_newdata()) { telnet_newdata(s, (char *)uip_appdata, uip_datalen()); } if(uip_rexmit() || uip_newdata() || uip_acked()) { senddata(s); } else if(uip_poll()) { senddata(s); }}
开发者ID:Asterios,项目名称:contiki-econotag,代码行数:46,
示例17: telnetd_appcall/*---------------------------------------------------------------------------*/voidtelnetd_appcall(void){ static unsigned int i; if(uip_connected()) { /* tcp_markconn(uip_conn, &s);*/ for(i = 0; i < TELNETD_CONF_NUMLINES; ++i) { s.lines[i] = NULL; } s.bufptr = 0; s.state = STATE_NORMAL; shell_start(); } if(s.state == STATE_CLOSE) { s.state = STATE_NORMAL; uip_close(); return; } if(uip_closed() || uip_aborted() || uip_timedout()) { closed(); } if(uip_acked()) { acked(); } if(uip_newdata()) { newdata(); } if(uip_rexmit() || uip_newdata() || uip_acked() || uip_connected() || uip_poll()) { senddata(); }}
开发者ID:JKcompute,项目名称:395_midi_controller,代码行数:44,
示例18: sms77_net_mainstatic voidsms77_net_main(void){ if (uip_aborted() || uip_timedout()) { SMSDEBUG ("connection aborted/n"); if (sms77_tmp_buf) { free(sms77_tmp_buf); sms77_tmp_buf = NULL; } return; } if (uip_closed()) { SMSDEBUG ("connection closed/n"); if (sms77_tmp_buf) { free(sms77_tmp_buf); sms77_tmp_buf = NULL; } return; } if (uip_connected() || uip_rexmit()) { SMSDEBUG ("new connection or rexmit, sending message/n"); char *p = uip_appdata; p += sprintf(p, "GET /?u=%s&p=%s&to=%s&type=%s&text=", sms77_user, sms77_pass, sms77_recv, sms77_type); p += urlencode(sms77_tmp_buf, strlen(sms77_tmp_buf), p); p += sprintf_P(p, sms77_secheader); uip_udp_send(p - (char *)uip_appdata); SMSDEBUG("send %d bytes/n", p - (char *)uip_appdata); } if (uip_acked()) { uip_close(); } if (uip_newdata()) SMSDEBUG("data: %s/n", uip_appdata);}
开发者ID:1234tester,项目名称:ethersex,代码行数:41,
示例19: httpd_handle_vfsvoidhttpd_handle_vfs (void){ if (uip_acked ()) { if (STATE->header_acked) STATE->u.vfs.acked = STATE->u.vfs.sent; else { STATE->header_acked = 1; STATE->u.vfs.acked = 0; } } if (!STATE->header_acked) httpd_handle_vfs_send_header (); else if (STATE->eof && !uip_rexmit()) uip_close (); else httpd_handle_vfs_send_body ();}
开发者ID:NeoBelerophon,项目名称:ethersex,代码行数:21,
示例20: PROCESS_THREAD/*---------------------------------------------------------------------------*/PROCESS_THREAD(tcp_server, ev, data){ PROCESS_BEGIN(); tcp_listen(UIP_HTONS(8080)); while(1) { PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event); printf("TCP server: receive TCP event/n"); if(uip_closed() || uip_aborted() || uip_timedout()) { printf("TCP server: connection closed/n"); } else if(uip_connected()) { printf("TCP server: connected/n"); } if(uip_newdata()) { printf("TCP server: receive new data/n"); uint16_t len = uip_datalen(); uint8_t *ptr = uip_appdata; while(len--){ printf("%c", *ptr++); } printf("/n"); printf("TCP server: send echo message/n"); uip_send(uip_appdata, uip_datalen()); } if(uip_rexmit() || uip_newdata() || uip_acked() || uip_connected() || uip_poll()) { //senddata(); } } PROCESS_END();}
开发者ID:ShidoShinji,项目名称:uipv6-6lowpan,代码行数:40,
示例21: pachube_net_mainstatic voidpachube_net_main(void) { if (uip_aborted() || uip_timedout()) { return; } if (uip_closed()) { return; } if (uip_connected() || uip_rexmit()) { char *p = uip_appdata; p += sprintf_P(p, pachube_header, DS, KEY, strlen(pachube_tmp_buf)); p += sprintf(p, pachube_tmp_buf); uip_udp_send(p - (char *)uip_appdata); } if (uip_acked()) { uip_close(); } }
开发者ID:sankeq,项目名称:ethersex,代码行数:22,
示例22: twitter_net_mainstatic voidtwitter_net_main(void){ if (uip_aborted() || uip_timedout()) { TWDEBUG ("connection aborted/n"); if (twitter_tmp_buf) { free(twitter_tmp_buf); twitter_tmp_buf = NULL; } return; } if (uip_closed()) { TWDEBUG ("connection closed/n"); if (twitter_tmp_buf) { free(twitter_tmp_buf); twitter_tmp_buf = NULL; } return; } if (uip_connected() || uip_rexmit()) { TWDEBUG ("new connection or rexmit, sending message/n"); char *p = uip_appdata; p += sprintf_P(p, twitter_header); p += sprintf(p, "%d", strlen(twitter_tmp_buf) + 7); p += sprintf_P(p, twitter_body); p += sprintf(p, twitter_tmp_buf); uip_udp_send(p - (char *)uip_appdata); TWDEBUG("send %d bytes/n", p - (char *)uip_appdata); } if (uip_acked()) { uip_close(); }}
开发者ID:HansBaechle,项目名称:ethersex,代码行数:38,
示例23: httpd_mainvoidhttpd_main(void){ if (uip_aborted() || uip_timedout()) { httpd_cleanup (); printf ("httpd: connection aborted/n"); } if (uip_closed()) { httpd_cleanup (); printf ("httpd: connection closed/n"); } if (uip_connected()) { printf ("httpd: new connection/n"); /* initialize struct */ STATE->handler = NULL; STATE->header_acked = 0; STATE->eof = 0; STATE->header_reparse = 0; } if (uip_newdata() && (!STATE->handler || STATE->header_reparse)) { printf ("httpd: new data/n"); httpd_handle_input (); } if(uip_rexmit() || uip_newdata() || uip_acked() || uip_connected()) { /* Call associated handler, if set already. */ if (STATE->handler && (!STATE->header_reparse)) STATE->handler (); }}
开发者ID:simeonfelis,项目名称:ethersex,代码行数:38,
示例24: telnetd_appcallvoid telnetd_appcall(void *ts) { if(uip_connected()) { tcp_markconn(uip_conn, &s); buf_init(&buf); s.bufptr = 0; s.state = STATE_NORMAL; stdout = &telnet_stream; shell_input("", 0); //shell_start(); } if(s.state == STATE_CLOSE) { s.state = STATE_NORMAL; uip_close(); return; } if(uip_closed() || uip_aborted() || uip_timedout()) { closed(); } if(uip_acked()) { acked(); } if(uip_newdata()) { newdata(); } if(uip_rexmit() || uip_newdata() || uip_acked() || uip_connected() || uip_poll()) { senddata(); }}
开发者ID:bootc,项目名称:PolyController,代码行数:36,
示例25: data_is_sent_and_acked/*---------------------------------------------------------------------------*/static chardata_is_sent_and_acked(CC_REGISTER_ARG struct psock *s){ /* If data has previously been sent, and the data has been acked, we increase the send pointer and call send_data() to send more data. */ if(s->state != STATE_DATA_SENT || uip_rexmit()) { if(s->sendlen > uip_mss()) { uip_send(s->sendptr, uip_mss()); } else { uip_send(s->sendptr, s->sendlen); } s->state = STATE_DATA_SENT; return 0; } else if(s->state == STATE_DATA_SENT && uip_acked()) { if(s->sendlen > uip_mss()) { s->sendlen -= uip_mss(); s->sendptr += uip_mss(); } else { s->sendptr += s->sendlen; s->sendlen = 0; } s->state = STATE_ACKED; return 1; } return 0;}
开发者ID:aiss83,项目名称:nucbit,代码行数:37,
示例26: specserver_appcall/*-----------------------------------------------------------------------------------*/voidspecserver_appcall(void){ static uint8_t reqs = 0; static char *data; if( uip_conn->lport != HTONS( SPECIAL_SERVER_PORT ) ) return; specserver_stats.frames++; if( uip_connected() ) { reqs = 0; } if( uip_newdata() ) { specserver_stats.recv++; char *p; // Process response data = (char*)uip_appdata; p = strchr( data, '/r' ); if( p != NULL ) *p = 0; p = strchr( data, '/n' ); if( p != NULL ) *p = 0; data[50] = 0; // Limit max size to one line or 50 char, whicever is smaller reqs++; } if( uip_acked() ) { } if( uip_rexmit() || uip_newdata() || uip_acked()) { // Send response if( reqs > 0 ) { reqs--; uip_send( specserver_resp_data, specserver_resp_data_len ); }else{ uip_close(); } } else if(uip_poll()) { uip_close(); }}
开发者ID:GaizkaBellido,项目名称:origin_stellaris,代码行数:37,
示例27: TELNETServerApp_Callback/** uIP stack application callback for the TELNET server. This function must be called each time the * TCP/IP stack needs a TCP packet to be processed. */void TELNETServerApp_Callback(void){ uip_tcp_appstate_t* const AppState = &uip_conn->appstate; char* const AppData = (char*)uip_appdata; if (uip_connected()) { /* New connection - initialize connection state values */ AppState->TELNETServer.CurrentState = TELNET_STATE_SendHeader; } if (uip_acked()) { /* Progress to the next state once the current state's data has been ACKed */ AppState->TELNETServer.CurrentState = AppState->TELNETServer.NextState; } if (uip_rexmit() || uip_acked() || uip_newdata() || uip_connected() || uip_poll()) { switch (AppState->TELNETServer.CurrentState) { case TELNET_STATE_SendHeader: /* Copy over and send the TELNET welcome message upon first connection */ strcpy_P(AppData, WelcomeHeader); uip_send(AppData, strlen(AppData)); AppState->TELNETServer.NextState = TELNET_STATE_SendMenu; break; case TELNET_STATE_SendMenu: /* Copy over and send the TELNET menu to the client */ strcpy_P(AppData, TELNETMenu); uip_send(AppData, strlen(AppData)); AppState->TELNETServer.NextState = TELNET_STATE_GetCommand; break; case TELNET_STATE_GetCommand: if (!(uip_datalen())) break; /* Save the issued command for later processing */ AppState->TELNETServer.IssuedCommand = AppData[0]; AppState->TELNETServer.CurrentState = TELNET_STATE_SendResponse; break; case TELNET_STATE_SendResponse: /* Determine which command was issued, perform command processing */ switch (AppState->TELNETServer.IssuedCommand) { case 'c': TELNETServerApp_DisplayTCPConnections(); break; default: strcpy_P(AppData, PSTR("Invalid Command./r/n")); uip_send(AppData, strlen(AppData)); break; } AppState->TELNETServer.NextState = TELNET_STATE_SendMenu; break; } }}
开发者ID:Armadill0,项目名称:CANBus-Triple_Genesis-Connect,代码行数:65,
示例28: client_task_impl/** * Handle client communications */void client_task_impl() { uip_tcp_appstate_t *app = &(uip_conn->appstate); GETrequest *req = (GETrequest*)app->request; if (uip_connected()) { if (verbose) { Serial.print("Connected to "); Serial.println(req->hostName); } app->ackedCount = 0; sendRequest(); } // Did we get an ack for the last packet? if (uip_acked()) { // Record the bytes that were successfully sent app->ackedCount += app->sentCount; app->sentCount = 0; // Check if we're done or need to send more content for this // request if (app->ackedCount != (int)app->cursor) { // Generate the post again to send the next packet of data sendRequest(); } } if (uip_rexmit()) { sendRequest(); } if (uip_newdata()) { setRXPin(HIGH); if (verbose) { Serial.print("RX "); Serial.print(uip_datalen()); Serial.print(" bytes from "); Serial.println(req->hostName); } // Check if the sketch cares about the returned data if ((req->returnFunc) && (uip_datalen() > 0)){ // Call the sketch's callback function req->returnFunc((char*)uip_appdata, uip_datalen()); } } if (uip_aborted() || uip_timedout() || uip_closed()) { if (req != NULL) { if (verbose) { Serial.print("Ended connection with "); Serial.println(req->hostName); } if (req->returnFunc) { // Call the sketch's callback function with 0 bytes to indicate End Of Data req->returnFunc((char*)uip_appdata, 0); } // Remove the request from the connection app->request = NULL; // Request is no longer active req->active = false; } }}
开发者ID:hmeyer,项目名称:RadioClock,代码行数:71,
示例29: server_task_impl/* * Handles high-level server communications */void server_task_impl() { // Get the connection's app state uip_tcp_appstate_t *app = &(uip_conn->appstate); if (uip_connected()) { if (verbose) { Serial.println("Server connected"); } // Initialize the server request data app->ackedCount = 0; app->request = NULL; } if (uip_newdata()) { setRXPin(HIGH); // Process the received packet and check if a valid GET request had been received if (processPacket((char*)uip_appdata, uip_datalen()) && app->request) { if (verbose) { Serial.print("Processing request for "); Serial.println((char*)app->request); } sendPage(); } } // Did we get an ack for the last packet? if (uip_acked()) { // Record the bytes that were successfully sent app->ackedCount += app->sentCount; app->sentCount = 0; // Check if we're done or need to send more content for this // request if (app->ackedCount == (int)app->cursor) { // Done with the current request and connection uip_close(); } else { // Generate the content again to send the next packet of data sendPage(); } } // Check if we need to retransmit if (uip_rexmit()) { // Send the same data again (same ackedCount value) sendPage(); } if (uip_aborted() || uip_closed() || uip_timedout()) { // Check if a URL was stored for this connection if (app->request != NULL) { if (verbose) { Serial.println("Server connection closed"); } // Free RAM and clear the pointer free(app->request); app->request = NULL; } }}
开发者ID:hmeyer,项目名称:RadioClock,代码行数:69,
示例30: elua_uip_appcallvoid elua_uip_appcall(){ volatile struct elua_uip_state *s; elua_net_size temp; int sockno; // If uIP is not yet configured (DHCP response not received), do nothing if( !elua_uip_configured ) return; s = ( struct elua_uip_state* )&( uip_conn->appstate ); // Need to find the actual socket location, since UIP doesn't provide this ... for( temp = 0; temp < UIP_CONNS; temp ++ ) if( uip_conns + temp == uip_conn ) break; sockno = ( int )temp; if( uip_connected() ) {#ifdef BUILD_CON_TCP if( uip_conn->lport == HTONS( ELUA_NET_TELNET_PORT ) ) // special case: telnet server { if( elua_uip_telnet_socket != -1 ) { uip_close(); return; } else elua_uip_telnet_socket = sockno; } else#endif if( elua_uip_accept_request ) { elua_uip_accept_sock = sockno; elua_uip_accept_remote.ipwords[ 0 ] = uip_conn->ripaddr[ 0 ]; elua_uip_accept_remote.ipwords[ 1 ] = uip_conn->ripaddr[ 1 ]; elua_uip_accept_request = 0; } else if( s->state == ELUA_UIP_STATE_CONNECT ) s->state = ELUA_UIP_STATE_IDLE; uip_stop(); return; } if( s->state == ELUA_UIP_STATE_IDLE ) return; // Do we need to read? if( s->state == ELUA_UIP_STATE_RECV ) { // Re-enable data transfer on the socket and change state s->state = ELUA_UIP_STATE_RECV_2; uip_restart(); return; } if( uip_aborted() || uip_timedout() || uip_closed() ) { // Signal this error s->res = uip_aborted() ? ELUA_NET_ERR_ABORTED : ( uip_timedout() ? ELUA_NET_ERR_TIMEDOUT : ELUA_NET_ERR_CLOSED );#ifdef BUILD_CON_TCP if( sockno == elua_uip_telnet_socket ) elua_uip_telnet_socket = -1; #endif s->state = ELUA_UIP_STATE_IDLE; return; } // Handle data send if( ( uip_acked() || uip_rexmit() || uip_poll() ) && ( s->state == ELUA_UIP_STATE_SEND ) ) { // Special translation for TELNET: prepend all '/n' with '/r' // We write directly in UIP's buffer if( uip_acked() ) { elua_net_size minlen = UMIN( s->len, uip_mss() ); s->len -= minlen; s->ptr += minlen; if( s->len == 0 ) s->state = ELUA_UIP_STATE_IDLE; } if( s->len > 0 ) // need to (re)transmit? {#ifdef BUILD_CON_TCP if( sockno == elua_uip_telnet_socket ) { temp = elua_uip_telnet_prep_send( s->ptr, s->len ); uip_send( uip_sappdata, temp ); } else#endif uip_send( s->ptr, UMIN( s->len, uip_mss() ) ); } return; } // Handle close if( s->state == ELUA_UIP_STATE_CLOSE ) {//.........这里部分代码省略.........
开发者ID:Linux-enCaja,项目名称:robotica,代码行数:101,
注:本文中的uip_rexmit函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ uip_send函数代码示例 C++ uip_poll函数代码示例 |