您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ uip_newdata函数代码示例

51自学网 2021-06-03 09:08:26
  C++
这篇教程C++ uip_newdata函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中uip_newdata函数的典型用法代码示例。如果您正苦于以下问题:C++ uip_newdata函数的具体用法?C++ uip_newdata怎么用?C++ uip_newdata使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了uip_newdata函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: tcpip_handler

/*---------------------------------------------------------------------------*/static void tcpip_handler(void) {  memset(buf, 0, MAX_PAYLOAD_LEN);  if(uip_newdata()) {    leds_on(LEDS_RED);    len = uip_datalen();    memcpy(buf, uip_appdata, len);    PRINTF("%u bytes from [", len);    PRINT6ADDR(&UIP_IP_BUF->srcipaddr);    PRINTF("]:%u/n", UIP_HTONS(UIP_UDP_BUF->srcport));    uip_ipaddr_copy(&server_conn->ripaddr, &UIP_IP_BUF->srcipaddr);    server_conn->rport = UIP_UDP_BUF->srcport;    uip_udp_packet_send(server_conn, buf, len);    /* Restore server connection to allow data from any node */    uip_create_unspecified(&server_conn->ripaddr);    server_conn->rport = 0;  }  leds_off(LEDS_RED);  return;}
开发者ID:bahmadh,项目名称:rpl-attacks,代码行数:21,


示例2: tcpip_handler

/*---------------------------------------------------------------------------*/static voidtcpip_handler(void){  char *appdata;  if(uip_newdata()) {    appdata = (char *)uip_appdata;    appdata[uip_datalen()] = 0;    PRINTF("DATA recv '%s' from ", appdata);    PRINTF("%d",           UIP_IP_BUF->srcipaddr.u8[sizeof(UIP_IP_BUF->srcipaddr.u8) - 1]);    PRINTF("/n");#if SERVER_REPLY    PRINTF("DATA sending reply/n");    uip_ipaddr_copy(&server_conn->ripaddr, &UIP_IP_BUF->srcipaddr);    uip_udp_packet_send(server_conn, "Reply", sizeof("Reply"));    uip_create_unspecified(&server_conn->ripaddr);#endif  }}
开发者ID:beshrns,项目名称:tsch-minimum,代码行数:21,


示例3: tcpip_handler

/*--------------------------------------------------------------*/static voidtcpip_handler(void){  char *appdata;    PRINTF("  uip_flags = %i/n", uip_flags);   if(uip_newdata()) {    appdata = (char *)uip_appdata;    appdata[uip_datalen()] = 0;    PRINTF("DATA recv '%s' from ", appdata);    PRINTF("%d", UIP_IP_BUF->srcipaddr.u8[15]);    PRINTF("/n");#if SERVER_REPLY    uip_ipaddr_copy(&client_conn->ripaddr, &UIP_IP_BUF->srcipaddr);    uip_udp_packet_send(client_conn, "Reply", sizeof("Reply"));    uip_create_unspecified(&client_conn->ripaddr);#endif  } }
开发者ID:ntuDerekWang,项目名称:uIP_on_eCos,代码行数:21,


示例4: bootp_net_main

voidbootp_net_main(void){    if(uip_newdata()) {	bootp_handle_reply();        return;    }    if(! uip_udp_conn->appstate.bootp.retry_timer) {	bootp_send_request();	if(uip_udp_conn->appstate.bootp.retry_counter < 5)	    uip_udp_conn->appstate.bootp.retry_timer =		2 << (++ uip_udp_conn->appstate.bootp.retry_counter);	else	    uip_udp_conn->appstate.bootp.retry_timer = 64 + (rand() & 63);    }    else	uip_udp_conn->appstate.bootp.retry_timer --;}
开发者ID:simeonfelis,项目名称:ethersex,代码行数:20,


示例5: PROCESS_THREAD

/*---------------------------------------------------------------------------*/PROCESS_THREAD(tcpEcho_process, ev, data){  PROCESS_BEGIN();  /* Listen for a connection on local port */  tcp_listen(UIP_HTONS(local_port));  while (1)  {    PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);    /* If there is new uIP data, display it */    if(uip_newdata()) {      /* Add the end of string. */      ((char *)uip_appdata)[uip_datalen()] = 0;      printf("New uIP data: '%s'/n", uip_appdata);    }  }  PROCESS_END();}
开发者ID:DIYzzuzpb,项目名称:wismote,代码行数:21,


示例6: sms77_net_main

static 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,


示例7: PROCESS_THREAD

/*---------------------------------------------------------------------------*/PROCESS_THREAD(server_process, ev, data){  PROCESS_BEGIN();  uip_ipaddr_t serveraddr;  uip_ipaddr(&serveraddr, 172,16,2,0);  serverport = 2222;  localport = 3333;  udpconn = udp_new(&serveraddr, uip_htons(serverport), NULL);  udp_bind(udpconn, uip_htons(localport));  while(1) {    PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);    if (uip_newdata()) {      newdata(uip_appdata, uip_datalen());    }  }  PROCESS_END();}
开发者ID:kincki,项目名称:contiki,代码行数:22,


示例8: tcpip_handler

/*---------------------------------------------------------------------------*/static voidtcpip_handler(void){  uint8_t *appdata;  rimeaddr_t sender;  uint8_t seqno;  uint8_t hops;  if(uip_newdata()) {	appdata = (uint8_t *)uip_appdata;	sender.u8[0] = UIP_IP_BUF->srcipaddr.u8[15];	sender.u8[1] = UIP_IP_BUF->srcipaddr.u8[14];	seqno = *appdata;	hops = uip_ds6_if.cur_hop_limit - UIP_IP_BUF->ttl + 1;	printf("sender:%u.%u ",sender.u8[0] ,sender.u8[1]);	printf("last_rssi=%d/n",cc2420_last_rssi-45);	collect_common_recv(&sender, seqno, hops,						appdata + 2, uip_datalen() - 2);    /* Ignore incoming data */  }}
开发者ID:bearxiong99,项目名称:Contiki_power_tester,代码行数:22,


示例9: tcpip_handler

/*---------------------------------------------------------------------------*/static voidtcpip_handler(void) {    seq_id_server_expected++;    if (uip_newdata()) {        ((char *) uip_appdata)[uip_datalen()] = 0;        app_data = (data_struct *) & uip_appdata[0];        printf("cb(%u.%u)cf", app_data->seq_id_client, app_data->seq_id_server);        PRINT6ADDR(&UIP_IP_BUF->srcipaddr);        if (seq_id_server < app_data->seq_id_server) {            packets_received++;            seq_id_server = app_data->seq_id_server;            if (seq_id_server_expected < app_data->seq_id_server) {                seq_id_server_expected = app_data->seq_id_server;            }            printf("ci%ucj%uck%u/n", packets_sent, packets_received, packetqueue_len(&tx_queue));        } else {            printf("cm/n");            seq_id_server_expected--;        }    }}
开发者ID:martinabr,项目名称:laneflood,代码行数:22,


示例10: ntp_newdata

voidntp_newdata(void){  if (!uip_newdata ()) return;  uint32_t ntp_timestamp;  struct ntp_packet *pkt = uip_appdata;  /* We must save an unix timestamp */  ntp_timestamp = NTOHL(pkt->rec.seconds) - 2208988800;#ifdef DEBUG_NTP    debug_printf("NTP: Set new time: %lu/n",ntp_timestamp);#endif  clock_set_time(ntp_timestamp);  set_dcf_count(0);  set_ntp_count(1);#ifdef NTPD_SUPPORT  ntp_setstratum(pkt->stratum);#endif}
开发者ID:HansBaechle,项目名称:ethersex,代码行数:21,


示例11: handle_my_tcp_srv

void handle_my_tcp_srv(void){    static struct timer user_timer; //create a timer;    static bool app_init = FALSE;	char mydata[100];    if (uip_newdata()) {        //printf_high("Server RX [%d] bytes/n", uip_datalen());		strncpy(mydata,uip_appdata,strlen(uip_appdata));		proces_data(mydata, uip_datalen());    }    if (uip_poll()) {        /* below codes shows how to send data to client  */        if ((app_init == FALSE) || timer_expired(&user_timer)) {            //printf_high("Poll/n");            timer_set(&user_timer, 5*CLOCK_SECOND);            app_init = TRUE;        }    }}
开发者ID:CrippledBytes,项目名称:CentralHeater,代码行数:21,


示例12: uipudp_appcall

voiduipudp_appcall(void) {  if (uip_udp_userdata_t *data = (uip_udp_userdata_t *)(uip_udp_conn->appstate))    {      if (uip_newdata())        {          if (data->packet_next == NOBLOCK)            {              uip_udp_conn->rport = UDPBUF->srcport;              uip_ipaddr_copy(uip_udp_conn->ripaddr,UDPBUF->srcipaddr);              data->packet_next = Enc28J60Network::allocBlock(ntohs(UDPBUF->udplen)-UIP_UDPH_LEN);                  //if we are unable to allocate memory the packet is dropped. udp doesn't guarantee packet delivery              if (data->packet_next != NOBLOCK)                {                  //discard Linklevel and IP and udp-header and any trailing bytes:                  Enc28J60Network::copyPacket(data->packet_next,0,UIPEthernetClass::in_packet,UIP_UDP_PHYH_LEN,Enc28J60Network::blockSize(data->packet_next));    #ifdef UIPETHERNET_DEBUG_UDP                  Serial.print(F("udp, uip_newdata received packet: "));                  Serial.print(data->packet_next);                  Serial.print(F(", size: "));                  Serial.println(Enc28J60Network::blockSize(data->packet_next));    #endif                }            }        }      if (uip_poll() && data->send)        {          //set uip_slen (uip private) by calling uip_udp_send#ifdef UIPETHERNET_DEBUG_UDP          Serial.print(F("udp, uip_poll preparing packet to send: "));          Serial.print(data->packet_out);          Serial.print(F(", size: "));          Serial.println(Enc28J60Network::blockSize(data->packet_out));#endif          UIPEthernetClass::uip_packet = data->packet_out;          UIPEthernetClass::uip_hdrlen = UIP_UDP_PHYH_LEN;          uip_udp_send(data->out_pos - (UIP_UDP_PHYH_LEN));        }    }}
开发者ID:kissste,项目名称:esp8266-enc28j60-UIP-Ethernet,代码行数:40,


示例13: _udp_sock_callback

/*---------------------------------------------------------------------------*/void _udp_sock_callback(c_event_t c_event, p_data_t p_data){    struct udp_socket *c;    if(c_event == EVENT_TYPE_TCPIP) {        /* An appstate pointer is passed to use from the IP stack           through the 'data' pointer. We registered this appstate when           we did the udp_new() call in udp_socket_register() as the           struct udp_socket pointer. So we extract this           pointer and use it when calling the reception callback. */        c = (struct udp_socket *)p_data;        /* Defensive coding: although the appstate *should* be non-null           here, we make sure to avoid the program crashing on us. */        if(c != NULL) {            LOG_INFO("socket ptr from callback = %p:%p", c, c->input_callback);            /* If we were called because of incoming data, we should call               the reception callback. */            if(uip_newdata()) {                /* Copy the data from the uIP data buffer into our own                   buffer to avoid the uIP buffer being messed with by the                   callee. */                memcpy(buf, uip_appdata, uip_datalen());                /* Call the client process. We use the PROCESS_CONTEXT                   mechanism to temporarily switch process context to the                   client process. */                if(c->input_callback != NULL) {                    c->input_callback(c, c->ptr,                                      &(UIP_IP_BUF->srcipaddr),                                      UIP_HTONS(UIP_IP_BUF->srcport),                                      &(UIP_IP_BUF->destipaddr),                                      UIP_HTONS(UIP_IP_BUF->destport),                                      buf, uip_datalen());                }            }        }    }}
开发者ID:lucasmarwagner,项目名称:emb-6_dtls,代码行数:40,


示例14: tcpip_handler

/* --------------------------------------------------------------- */static void tcpip_handler(){    // Check that what we have received is a new packet    if (!uip_newdata())        return;    // Clean buffer    memset(command, 0, MAX_COMMAND_LEN);    // Get the data    command_len = uip_datalen();    memcpy(command, uip_appdata, command_len);    // Send the command by a serial line    // "putstring" does not depend of the debug verbosity level    printf("%s/n", command);    // Debug messages    PRINTF("# Recevied %u bytes from [", command_len);    PRINT6ADDR(&UIP_IP_BUF->srcipaddr);    PRINTF("]:%u/n", UIP_HTONS(UIP_UDP_BUF->srcport));}
开发者ID:RauPerez25,项目名称:Wall-E,代码行数:23,


示例15: tcpip_handler

/*---------------------------------------------------------------------------*/static voidtcpip_handler(void){  static int seq_id;  char buf[MAX_PAYLOAD_LEN];  if(uip_newdata()) {    ((char *)uip_appdata)[uip_datalen()] = 0;    PRINTF("Server received: '%s'", (char *)uip_appdata);    PRINT6ADDR(&UIP_IP_BUF->srcipaddr);    PRINTF("/r/n");    uip_ipaddr_copy(&server_conn->ripaddr, &UIP_IP_BUF->srcipaddr);    PRINTF("Responding with message: ");    sprintf(buf, "Hello from the server! (%d)", ++seq_id);    PRINTF("%s/r/n", buf);    uip_udp_packet_send(server_conn, buf, strlen(buf));    /* Restore server connection to allow data from any node */    memset(&server_conn->ripaddr, 0, sizeof(server_conn->ripaddr));  }}
开发者ID:mlwymore,项目名称:contiki,代码行数:23,


示例16: tcpip_handler

/*---------------------------------------------------------------------------*/static voidtcpip_handler(void){  static uint32_t number;  static uint16_t loc,i;  if(uip_newdata()) {    switch( ((char*)uip_appdata)[0] ) {    case 'A': // anuncio      memcpy(&number, (char*)uip_appdata+1, sizeof(uint32_t));      //printf("anuncio %lu/n", number);      loc = -1;      for( i = 0 ; loc == -1 && i < HISTORY_SIZE ; ++ i ) {    	  if( history[i].id == number ) {    	    loc = i;    	  }      }      if( loc != -1 ) {    	  if( cur_time-INTERV_END <= history[loc].time && history[loc].time <= cur_time-INTERV_BEG ) {    	    printf("abrir %lu/n", number);    	    history[loc].time = 0;      	} else if( history[loc].time < cur_time-INTERV_END ) {    	    history[loc].time = cur_time;    	  }      } else {    	  loc = 0;    	  for( i = 1 ; i < HISTORY_SIZE ; ++ i ) {		    if( history[i].time < history[loc].time ) {		      loc = i;		    }		  }		  history[loc].id = number;		  history[loc].time = cur_time;      }      break;    default: putchar(((char*)uip_appdata)[0]);    }  }}
开发者ID:vitorqa,项目名称:CC2530_Contiki,代码行数:40,


示例17: PROCESS_THREAD

PROCESS_THREAD(UDP_echo_process, ev, data){    static uip_ipaddr_t localaddr;    static struct uip_udp_conn *localconn;    PROCESS_BEGIN();    /* Create the local listener */    localconn = udp_new(&uip_all_zeroes_addr, 0, NULL);    udp_bind(localconn,uip_htons(local_port));    while (1)    {        PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);        /* If there is new uIP data, display it */        if(uip_newdata()) {            /* Add the end of string. */            ((char *)uip_appdata)[uip_datalen()] = 0;            printf("New uIP data: '%s'/n", uip_appdata);        }    }    PROCESS_END();}
开发者ID:anthonygelibert,项目名称:WiSMote-Contiki,代码行数:23,


示例18: netfind_app_call

void netfind_app_call(void){        if(uip_poll()) {                switch(netfind_s.state) {                        case NETFIND_STATE_WAIT:                                if(get_clock() > netfind_s.send_answer_time)                                        netfind_s.state = NETFIND_STATE_SEND_ANSWER;                                break;                        case NETFIND_STATE_SEND_ANSWER:                                netfind_send_answer();                                break;                }        }        if(uip_newdata()) {                switch(netfind_s.state) {                        case NETFIND_STATE_IDLE:                                netfind_handle_request();                                break;                }        }}
开发者ID:sli92,项目名称:netcon,代码行数:23,


示例19: dc3840_net_main

static voiddc3840_net_main (void){    if (!uip_newdata ())	return;    uip_udp_conn_t dc3840_conn;    #define BUF ((struct uip_udpip_hdr *) (uip_appdata - UIP_IPUDPH_LEN))    uip_ipaddr_copy(dc3840_conn.ripaddr, BUF->srcipaddr);    dc3840_conn.rport = BUF->srcport;    dc3840_conn.lport = HTONS(DC3840_PORT);    uip_udp_conn = &dc3840_conn;    uint16_t offset = atoi (uip_appdata);    dc3840_get_data (uip_appdata, offset, 512);    uip_slen = 512;    uip_process (UIP_UDP_SEND_CONN);    router_output ();    uip_slen = 0;		/* No reply. */}
开发者ID:Leerzeichen,项目名称:ethersex,代码行数:23,


示例20: readUDP

bool readUDP(NetworkSocket * networkSocket, uint8_t * buffer, int bufferLength, NetworkAddress ** sourceAddress, int *readLength){    bool result = true;    *readLength = 0;    //if (uip_newdata() && (UIP_IP_BUF->destport == networkSocket->Port) )    if (uip_newdata())    {        Lwm2m_Debug("Packet from: %d %d/n", uip_htons(UIP_IP_BUF->destport), networkSocket->Port);        if (uip_datalen() > bufferLength)            *readLength = bufferLength;        else            *readLength = uip_datalen();    }    if (*readLength > 0)    {        uip_ipaddr_t * address = &UIP_IP_BUF->srcipaddr;        uint16_t port = uip_htons(UIP_IP_BUF->srcport);        bool secure = (networkSocket->SocketType & NetworkSocketType_Secure) == NetworkSocketType_Secure;        memcpy(buffer, uip_appdata, *readLength);        NetworkAddress * networkAddress = getCachedAddress(address, port);        if (networkAddress == NULL)        {            networkAddress = addCachedAddress(address, port, secure);            if (networkAddress)            {                networkAddress->useCount++;         // TODO - ensure addresses are freed? (after t/o or transaction or DTLS session closed)            }        }        if (networkAddress)        {            *sourceAddress = networkAddress;        }    }    return result;}
开发者ID:FlowM2M,项目名称:AwaLWM2M,代码行数:37,


示例21: _udp_states_process

void _udp_states_process(void) {    if(uip_len>7&&uip_newdata()) { // a minimum packet of udp_states are 8 byte -> smaller are a corrupted packet        uint16_t len = uip_len-5; //header length are 5 byte so the states are uip_len - 5        uint8_t buffer[uip_len]; //get memory for the packet        memcpy(buffer, uip_appdata, uip_len); //get the packet        udp_states_packet_t packet; // place for the header        udp_states_state_t tmp_state; // a state to compare        udp_states_state_t *found_state; //pointer to the found state        packet.node = buffer[1]; //make the packet        packet.type = buffer[2];        packet.part = buffer[3];        packet.prio_byte= buffer[4];        packet.data=&buffer[5];        tmp_state.node=packet.node; //make the compare state        tmp_state.type=packet.type;        tmp_state.part=packet.part;        debug_printf("UDP_STATES %x:%x:%x %x:%x:%x/n%x,%x,%x",tmp_state.node,tmp_state.type,tmp_state.part,udp_states_states[0].node,udp_states_states[0].type,udp_states_states[0].part,buffer[6],buffer[7],buffer[8]);        found_state=(udp_states_state_t*) bsearch((const void*)&tmp_state,(const void*)udp_states_states,udp_states_n_registert_states,sizeof(udp_states_state_t),_udp_states_compare);        udp_states_make_state(found_state,packet,len); //make state from the packet        for(udp_states_state_t *i = found_state; i>=udp_states_states; i--) { //search other states in the packet            if(_udp_states_compare(i,&tmp_state)!=0) //if compare from the state is not null for the state is a other packet needed                break;            else {                udp_states_make_state(i,packet,len); //so make the state            }        }        for(udp_states_state_t *i = found_state; i<=udp_states_states+sizeof(udp_states_state_t); i++) { //search in the other direction            if(_udp_states_compare(i,&tmp_state)!=0) //like the other code                break;            else {                udp_states_make_state(i,packet,len); // like the other code            }        }    }    uip_slen = 0; //all data procecced}
开发者ID:asuro,项目名称:ethersex,代码行数:37,


示例22: tcpip_handler

/*---------------------------------------------------------------------------*/static voidtcpip_handler(void){  /* handle the incoming packet */  if(uip_newdata()) {    if( ((query_pkt_t*)uip_appdata)->type == 1){      /* Query Packet */      query_pkt_t *appdata;      appdata = (query_pkt_t*)uip_appdata;        if(!appdata->multicast_flag)          collect_common_send();        else{          if(appdata->query_id > cur_query_id) { /* Do not reply to the duplicate query */            cur_query_id = appdata->query_id;            if(region == SENSOR || region == ANONYMOUS){              collect_common_send();            }            else if (appdata->id < region) { //else drop the query, received from the lower region            /* send multicast query to the lower regions */              appdata->id = region;              uip_ipaddr_t addr;              uip_create_linklocal_allnodes_mcast(&addr);              uip_udp_packet_sendto(server_conn, appdata, sizeof(query_pkt_t),                          &addr, UIP_HTONS(UDP_CLIENT_PORT));            }          }         }    }    else if( ((identity_pkt_t*)uip_appdata)->type == 2){      /* Identity Packet */      if(region > ((identity_pkt_t*)uip_appdata)->id )        add_new_nbr(((identity_pkt_t*)uip_appdata)->id, UIP_IP_BUF->srcipaddr, cc2420_last_rssi);      print_nbr_table();    }  }}
开发者ID:engalex,项目名称:652Final,代码行数:38,


示例23: tcpip_handler

/*---------------------------------------------------------------------------*/static voidtcpip_handler(void){	uint8_t *appdata;	rimeaddr_t sender;    uint8_t seqno;	uint16_t len;	//uint16_t client_clock;	//uint16_t rank;	uint16_t num_neighbors;	uint8_t hops;	if(uip_newdata()) {	    appdata = (uint8_t *)uip_appdata;	    seqno = *appdata;	    sender.u8[0] = UIP_IP_BUF->srcipaddr.u8[15];	    sender.u8[1] = UIP_IP_BUF->srcipaddr.u8[14];	    hops = uip_ds6_if.cur_hop_limit - UIP_IP_BUF->ttl + 1;	    uint16_t data;	    uint16_t payload_len = uip_datalen() - 2;	    uint8_t* payload = appdata +2;	    int i;	    PRINTF("DATA recv from %d: ",UIP_IP_BUF->srcipaddr.u8[sizeof(UIP_IP_BUF->srcipaddr.u8) - 1]);	    PRINTF(" %u ",seqno);	    for(i = 0; i < payload_len / 2; i++) {	      memcpy(&data, payload, sizeof(data));	      payload += sizeof(data);	      PRINTF("  %u ", data);	    }	    PRINTF(" %d, %u/n",hops,clock_time());	    //print format: node id | seqno,len | client_time | client_rank | client_neighbor_num | hops | current_time	  }}
开发者ID:lixinlu2000,项目名称:iot-rpl,代码行数:38,


示例24: PROCESS_THREAD

/*---------------------------------------------------------------------*/PROCESS_THREAD(test_uip_process, ev, data){    PROCESS_BEGIN();    printf("uIP test process started/n");    broadcast_conn = udp_broadcast_new(COOJA_PORT, NULL);    button_sensor.configure(SENSORS_ACTIVE, 1);    while(1) {        PROCESS_WAIT_EVENT();        printf("An event occured: ");        if(ev == PROCESS_EVENT_EXIT) {            printf("shutting down/n");            break;        }        if(ev == sensors_event && data == &button_sensor) {            printf("button clicked, sending packet/n");            tcpip_poll_udp(broadcast_conn);            PROCESS_WAIT_UNTIL(ev == tcpip_event && uip_poll());            uip_send("cooyah COOJA", 12);        } else if(ev == sensors_event) {            printf("unknown sensor event: %s/n", ((struct sensors_sensor *)data)->type);        } else if(ev == tcpip_event && uip_newdata()) {            printf("a packet was received, toggling leds/n");            printf("packet data: '%s'/n", (char*) uip_appdata);            leds_toggle(LEDS_ALL);        } else {            printf("unknown event: %d/n", ev);        }    }    PROCESS_END();}
开发者ID:21moons,项目名称:contiki,代码行数:38,


示例25: zbus_raw_net_main

voidzbus_raw_net_main(void) {  if (uip_newdata ())    {      /* 600ms timeout */      uip_udp_conn->appstate.zbus_raw.timeout = 3;      uip_ipaddr_copy(uip_udp_conn->ripaddr, BUF->srcipaddr);      uip_udp_conn->rport = BUF->srcport;            zbus_send_data(uip_appdata, uip_len);      return;    }  if (! uip_udp_conn->appstate.zbus_raw.timeout)    return;  if (-- uip_udp_conn->appstate.zbus_raw.timeout)    return;			/* timeout not yet over. */  uip_ipaddr_copy(uip_udp_conn->ripaddr, all_ones_addr);  uip_udp_conn->rport = 0;}
开发者ID:muccc,项目名称:matemat,代码行数:24,


示例26: dhcp_app_call

void dhcp_app_call(void){        if(uip_newdata()) {                switch(dhcp_s.state) {                        case DHCP_STATE_OFFER:                                dhcp_parse_offer();                                break;                        case DHCP_STATE_ACK:                                dhcp_parse_ack();                                break;                }        }        if(uip_poll()) {                switch(dhcp_s.state) {                        case DHCP_STATE_BOOT_WAIT:                                if(get_clock() > dhcp_s.dhcp_renew_time)                                        dhcp_s.state = DHCP_STATE_DISCOVER;                                break;                        case DHCP_STATE_DISCOVER:                                dhcp_send_discover();                                break;                        case DHCP_STATE_REQUEST:                                dhcp_send_request();                                break;                        case DHCP_STATE_WAIT_RENEW:                                if(get_clock() > dhcp_s.dhcp_renew_time)                                        dhcp_s.state = DHCP_STATE_REQUEST;                                break;                }        }}
开发者ID:sli92,项目名称:netcon,代码行数:36,


示例27: PROCESS_THREAD

/*---------------------------------------------------------------------------*/PROCESS_THREAD(shell_udpsend_process, ev, data){  const char *next, *nextptr;  struct shell_input *input;  uint16_t port, local_port;    PROCESS_BEGIN();  next = strchr(data, ' ');  if(next == NULL) {    shell_output_str(&udpsend_command,		     "udpsend <server> <port> [localport]: server as address", "");    PROCESS_EXIT();  }  if(next - (char *)data > sizeof(server)) {    shell_output_str(&udpsend_command, "Too long input", "");    PROCESS_EXIT();  }  strncpy(server, data, sizeof(server));  /* NULL-terminate the server string. */  server[next - (char *)data] = 0;  ++next;  port = shell_strtolong(next, &nextptr);  uiplib_ipaddrconv(server, &serveraddr);  udpconn = udp_new(&serveraddr, uip_htons(port), NULL);    if(next != nextptr) {    local_port = shell_strtolong(nextptr, &nextptr);    udp_bind(udpconn, uip_htons(local_port));  }  running = 1;  while(running) {    PROCESS_WAIT_EVENT();    if(ev == shell_event_input) {      input = data;      if(input->len1 + input->len2 == 0) {		PROCESS_EXIT();      }	  if(input->len1 == 5) {		  	PROCESS_EXIT();  //YIBO: For exit this process.    	  }      if(input->len1 > 0) {		send_line(input->data1, input->len1);      }    } else if(ev == tcpip_event) {      if(uip_newdata()) {		newdata(uip_appdata, uip_datalen());      }#if 0    } else if(ev == resolv_event_found) {      /* Either found a hostname, or not. */      if((char *)data != NULL &&	 resolv_lookup((char *)data, &ipaddr) == RESOLV_STATUS_CACHED) {	uip_ipaddr_copy(serveraddr, ipaddr);	telnet_connect(&s, server, serveraddr, nick);      } else {	shell_output_str(&udpsend_command, "Host not found.", "");      }#endif /* 0 */    }  }  PROCESS_END();}
开发者ID:yibochen-smir,项目名称:IWoTCore_MiLive_testbed,代码行数:70,


示例28: raven_gui_loop

/*------------------------------------------------------------------*/static u8_traven_gui_loop(process_event_t ev, process_data_t data){    uint8_t *ptr;    int len = 0;    if(ev == tcpip_event) {        PRINTF("[APP] TCPIP event lport %u rport %u raddress/n",uip_udp_conn->lport, uip_udp_conn->rport);        if(uip_udp_conn == node_conn) {            PRINTF("[APP] UDP packet/n");            if(uip_newdata()) {                ptr = (uint8_t *)uip_appdata;                /* Make sure the data is terminated */                ptr[uip_datalen()] = 0;                /* Command to this node */                switch(*ptr) {                case 'T':                    send_frame(TEMP_REQUEST, 0, 0);                    len = snprintf(udp_data,                                   DATA_LEN, "%c%s/r/n", *ptr, last_temp);                    if(len > 0) {                        reply_packet(udp_data, len);                    }                    break;                case 'A':                    if(ptr[1] > 32) {                        invert_led = ptr[1] == '1';                        send_frame(LED_REQUEST, 1, &invert_led);                    }                    len = sprintf(udp_data, "A%u/r/n", invert_led ? 1 : 0);                    if(len > 0) {                        reply_packet(udp_data, len);                    }                    break;                case 'P':                    PRINTF("[APP] Request for periodic sending of temperatures/n");                    if(sscanf((char *)ptr+1,"%d", &periodic_interval)) {                        PRINTF("[APP] Period %d/n", periodic_interval);                        if(periodic_interval == 0) {                            etimer_stop(&periodic_timer);                        } else {                            etimer_set(&periodic_timer, periodic_interval * CLOCK_SECOND);                        }                        len = snprintf(udp_data,                                       DATA_LEN, "P%d/r/n", periodic_interval);                        if(len > 0) {                            reply_packet(udp_data, len);                        }                    }                    break;                case 'C':                    PRINTF("[APP] Command %c/n",ptr[1]);                    if(sscanf((char *)ptr+2,                              "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x %d",                              &addr[0],&addr[1],&addr[2],&addr[3],&addr[4],                              &addr[5],&addr[6],&addr[7],&len) >= 8) {                        uip_ip6addr(&locaddr, addr[0], addr[1],addr[2],                                    addr[3],addr[4],addr[5],addr[6],addr[7]);                        if(ptr[1] == 'E') {                            PRINTF("[APP] Send ping to");                            PRINT6ADDR(&locaddr);                            PRINTF("len %d/n", len);                            raven_ping6(&locaddr, len);                        } else if (ptr[1] == 'T') {                            PRINTF("[APP] Send temperature to");                            PRINT6ADDR(&locaddr);                            PRINTF("/n");                            len = snprintf(udp_data, DATA_LEN, "%c/r/n", ptr[1]);                            if(len > 0) {                                send_packet(&locaddr, HTONS(0xF0B0), udp_data, len);                            }                        } else {                            PRINTF("[APP] Command unknown/n");                        }                    }                    break;                default:                    break;                }            }        }    } else {        switch (ev) {        case ICMP6_ECHO_REQUEST:            /* We have received a ping request over the air.               Send frame back to 3290 */            send_frame(PING_REQUEST, 0, 0);            break;        case ICMP6_ECHO_REPLY:            /* We have received a ping reply over the air.               Send frame back to 3290 */            send_frame(PING_REPLY, 1, &seqno);            break;        case PROCESS_EVENT_TIMER:            if(data == &periodic_timer) {                PRINTF("[APP] Periodic Timer/n");                /* Send to server if time to send */                len = sprintf(udp_data, "T%s/r/n", last_temp);//.........这里部分代码省略.........
开发者ID:kincki,项目名称:contiki,代码行数:101,


示例29: PT_THREAD

/*---------------------------------------------------------------------------*/staticPT_THREAD(handle_dhcp(void)){  PT_BEGIN(&s.pt);    /* try_again:*/  s.state = STATE_SENDING;  s.ticks = CLOCK_SECOND;  do {    send_discover();    timer_set(&s.timer, s.ticks);    PT_YIELD(&s.pt);    PT_WAIT_UNTIL(&s.pt, uip_newdata() || timer_expired(&s.timer));    if(uip_newdata() && parse_msg() == DHCPOFFER) {      s.state = STATE_OFFER_RECEIVED;      break;    }    if(s.ticks < CLOCK_SECOND * 60) {      s.ticks *= 2;    }  } while(s.state != STATE_OFFER_RECEIVED);    s.ticks = CLOCK_SECOND;  do {    send_request();    timer_set(&s.timer, s.ticks);    PT_YIELD(&s.pt);    PT_WAIT_UNTIL(&s.pt, uip_newdata() || timer_expired(&s.timer));    if(uip_newdata() && parse_msg() == DHCPACK) {      s.state = STATE_CONFIG_RECEIVED;      break;    }    if(s.ticks <= CLOCK_SECOND * 10) {      s.ticks += CLOCK_SECOND;    } else {      PT_RESTART(&s.pt);    }  } while(s.state != STATE_CONFIG_RECEIVED);  #if 0  printf("Got IP address %d.%d.%d.%d/n",	 uip_ipaddr1(s.ipaddr), uip_ipaddr2(s.ipaddr),	 uip_ipaddr3(s.ipaddr), uip_ipaddr4(s.ipaddr));  printf("Got netmask %d.%d.%d.%d/n",	 uip_ipaddr1(s.netmask), uip_ipaddr2(s.netmask),	 uip_ipaddr3(s.netmask), uip_ipaddr4(s.netmask));  printf("Got DNS server %d.%d.%d.%d/n",	 uip_ipaddr1(s.dnsaddr), uip_ipaddr2(s.dnsaddr),	 uip_ipaddr3(s.dnsaddr), uip_ipaddr4(s.dnsaddr));  printf("Got default router %d.%d.%d.%d/n",	 uip_ipaddr1(s.default_router), uip_ipaddr2(s.default_router),	 uip_ipaddr3(s.default_router), uip_ipaddr4(s.default_router));  printf("Lease expires in %ld seconds/n",	 ntohs(s.lease_time[0])*65536ul + ntohs(s.lease_time[1]));#endif  dhcpc_configured(&s);    /*  timer_stop(&s.timer);*/  /*   * PT_END restarts the thread so we do this instead. Eventually we   * should reacquire expired leases here.   */  while(1) {    PT_YIELD(&s.pt);  }  PT_END(&s.pt);}
开发者ID:Anil8590,项目名称:tiva-c,代码行数:77,


示例30: 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,



注:本文中的uip_newdata函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ uip_ntohs函数代码示例
C++ uip_listen函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。