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

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

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

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

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

示例1: uip_ds6_init

/*---------------------------------------------------------------------------*/voiduip_ds6_init(void){  PRINTF("Init of IPv6 data structures/n");  PRINTF("%u neighbors/n%u default routers/n%u prefixes/n%u routes/n%u unicast addresses/n%u multicast addresses/n%u anycast addresses/n",     UIP_DS6_NBR_NB, UIP_DS6_DEFRT_NB, UIP_DS6_PREFIX_NB, UIP_DS6_ROUTE_NB,     UIP_DS6_ADDR_NB, UIP_DS6_MADDR_NB, UIP_DS6_AADDR_NB);  memset(uip_ds6_prefix_list, 0, sizeof(uip_ds6_prefix_list));  memset(&uip_ds6_if, 0, sizeof(uip_ds6_if));  memset(uip_ds6_routing_table, 0, sizeof(uip_ds6_routing_table));  /* Set interface parameters */  uip_ds6_if.link_mtu = UIP_LINK_MTU;  uip_ds6_if.cur_hop_limit = UIP_TTL;  uip_ds6_if.maxdadns = 0;  /* Create link local address, prefix, multicast addresses, anycast addresses */  uip_create_linklocal_prefix(&loc_fipaddr);  uip_ds6_prefix_add(&loc_fipaddr, UIP_DEFAULT_PREFIX_LEN, 0, 0, 0, 0);  uip_ds6_set_addr_iid(&loc_fipaddr, &uip_lladdr);  uip_ds6_addr_add(&loc_fipaddr, 0, ADDR_AUTOCONF);  uip_create_linklocal_allnodes_mcast(&loc_fipaddr);  uip_ds6_maddr_add(&loc_fipaddr);  uip_create_linklocal_allrouters_mcast(&loc_fipaddr);  uip_ds6_maddr_add(&loc_fipaddr);  PRINTF("DS: init set timer to %u/n",UIP_DS6_PERIOD);  return;}
开发者ID:Feandil,项目名称:RPL_Gateway,代码行数:30,


示例2: uip_ds6_set_lladdr

/*---------------------------------------------------------------------------*/void uip_ds6_set_lladdr(uip_lladdr_t *lladdr){  /* First remove the current address from system as this function   * can be called many times.   */  uip_ds6_addr_rm(uip_ds6_addr_lookup(&loc_fipaddr));  /* Create link local address, prefix, multicast addresses,   * anycast addresses   */  uip_create_linklocal_prefix(&loc_fipaddr);#if UIP_CONF_ROUTER  uip_ds6_prefix_add(&loc_fipaddr, UIP_DEFAULT_PREFIX_LEN, 0, 0, 0, 0);#else /* UIP_CONF_ROUTER */  uip_ds6_prefix_add(&loc_fipaddr, UIP_DEFAULT_PREFIX_LEN, 0);#endif /* UIP_CONF_ROUTER */  memcpy(&uip_lladdr, lladdr, sizeof(uip_lladdr));  uip_ds6_set_addr_iid(&loc_fipaddr, &uip_lladdr);  uip_ds6_addr_add(&loc_fipaddr, 0, ADDR_AUTOCONF);  uip_create_linklocal_allnodes_mcast(&loc_fipaddr);  uip_ds6_maddr_add(&loc_fipaddr);#if UIP_CONF_ROUTER  uip_create_linklocal_allrouters_mcast(&loc_fipaddr);  uip_ds6_maddr_add(&loc_fipaddr);#endif /* UIP_CONF_ROUTER */}
开发者ID:CurieBSP,项目名称:zephyr,代码行数:31,


示例3: PROCESS_THREAD

/*---------------------------------------------------------------------------*/PROCESS_THREAD(broadcast_example_process, ev, data){  static struct etimer periodic_timer;  static struct etimer send_timer;  uip_ipaddr_t addr;  PROCESS_BEGIN();  simple_udp_register(&broadcast_connection, UDP_PORT,                      NULL, UDP_PORT,                      receiver);  etimer_set(&periodic_timer, SEND_INTERVAL);  while(1) {    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer));    etimer_reset(&periodic_timer);   // etimer_set(&send_timer, SEND_TIME);  //  PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&send_timer));   // printf("Jamming/n");    uip_create_linklocal_allnodes_mcast(&addr);    simple_udp_sendto(&broadcast_connection, "jamming", 7, &addr);  }  PROCESS_END();}
开发者ID:xytgeorge,项目名称:User-conflict-prevention-CLS,代码行数:27,


示例4: send_broadcast

static voidsend_broadcast(unsigned char *buf, int size){    printf("In send broadcast: /n");    uip_create_linklocal_allnodes_mcast(&udp_bconn->ripaddr);    uip_udp_packet_send(udp_bconn, buf, size);    uip_create_unspecified(&udp_bconn->ripaddr);}
开发者ID:alirezapourbahram,项目名称:IoT-Wormhole-IDS,代码行数:8,


示例5: send_msg

/*---------------------------------------------------------------------------*/static voidsend_msg(struct simple_udp_connection *conn, int seconds){  uip_ipaddr_t addr;  struct network_reboot_msg msg;  memcpy(msg.magic_bytes, magic_bytes, sizeof(msg.magic_bytes));  msg.seconds = uip_htons(seconds_until_reboot);  uip_create_linklocal_allnodes_mcast(&addr);  simple_udp_sendto(conn, &msg, sizeof(msg), &addr);}
开发者ID:ADVANSEE,项目名称:mist,代码行数:11,


示例6: timeout_handler

/*---------------------------------------------------------------------------*/static voidtimeout_handler(void){  cur_time++;  buf[0] = 'P';  uip_create_linklocal_allnodes_mcast(&conn->ripaddr);  conn->rport = UIP_HTONS(3000);  uip_udp_packet_send(conn, buf, 1);  uip_create_unspecified(&conn->ripaddr);  conn->rport = 0;}
开发者ID:vitorqa,项目名称:CC2530_Contiki,代码行数:12,


示例7: uip_ds6_init

/*---------------------------------------------------------------------------*/voiduip_ds6_init(void){  uip_ds6_route_init();  PRINTF("Init of IPv6 data structures/n");  PRINTF("%u neighbors/n%u default routers/n%u prefixes/n%u routes/n%u unicast addresses/n%u multicast addresses/n%u anycast addresses/n",     UIP_DS6_NBR_NB, UIP_DS6_DEFRT_NB, UIP_DS6_PREFIX_NB, UIP_DS6_ROUTE_NB,     UIP_DS6_ADDR_NB, UIP_DS6_MADDR_NB, UIP_DS6_AADDR_NB);  memset(uip_ds6_nbr_cache, 0, sizeof(uip_ds6_nbr_cache));  //  memset(uip_ds6_defrt_list, 0, sizeof(uip_ds6_defrt_list));  memset(uip_ds6_prefix_list, 0, sizeof(uip_ds6_prefix_list));  memset(&uip_ds6_if, 0, sizeof(uip_ds6_if));  //  memset(uip_ds6_routing_table, 0, sizeof(uip_ds6_routing_table));  uip_ds6_addr_size = sizeof(struct uip_ds6_addr);  uip_ds6_netif_addr_list_offset = offsetof(struct uip_ds6_netif, addr_list);  /* Set interface parameters */  uip_ds6_if.link_mtu = UIP_LINK_MTU;  uip_ds6_if.cur_hop_limit = UIP_TTL;  uip_ds6_if.base_reachable_time = UIP_ND6_REACHABLE_TIME;  uip_ds6_if.reachable_time = uip_ds6_compute_reachable_time();  uip_ds6_if.retrans_timer = UIP_ND6_RETRANS_TIMER;  uip_ds6_if.maxdadns = UIP_ND6_DEF_MAXDADNS;  /* Create link local address, prefix, multicast addresses, anycast addresses */  uip_create_linklocal_prefix(&loc_fipaddr);#if UIP_CONF_ROUTER  uip_ds6_prefix_add(&loc_fipaddr, UIP_DEFAULT_PREFIX_LEN, 0, 0, 0, 0);#else /* UIP_CONF_ROUTER */  uip_ds6_prefix_add(&loc_fipaddr, UIP_DEFAULT_PREFIX_LEN, 0);#endif /* UIP_CONF_ROUTER */  uip_ds6_set_addr_iid(&loc_fipaddr, &uip_lladdr);  uip_ds6_addr_add(&loc_fipaddr, 0, ADDR_AUTOCONF);  uip_create_linklocal_allnodes_mcast(&loc_fipaddr);  uip_ds6_maddr_add(&loc_fipaddr);#if UIP_CONF_ROUTER  uip_create_linklocal_allrouters_mcast(&loc_fipaddr);  uip_ds6_maddr_add(&loc_fipaddr);#if UIP_ND6_SEND_RA  stimer_set(&uip_ds6_timer_ra, 2);     /* wait to have a link local IP address */#endif /* UIP_ND6_SEND_RA */#else /* UIP_CONF_ROUTER */  etimer_set(&uip_ds6_timer_rs,             random_rand() % (UIP_ND6_MAX_RTR_SOLICITATION_DELAY *                              CLOCK_SECOND));#endif /* UIP_CONF_ROUTER */  etimer_set(&uip_ds6_timer_periodic, UIP_DS6_PERIOD);  return;}
开发者ID:chanderbgoel,项目名称:contiki,代码行数:54,


示例8: PROCESS_THREAD

/*---------------------------------------------------------------------------*/PROCESS_THREAD(udp_broadcast_process, ev, data){  static struct etimer periodic_timer;  uip_ipaddr_t addr;  PROCESS_BEGIN();  simple_udp_register(&broadcast_connection, UDP_PORT, NULL, UDP_PORT,                      receiver);  etimer_set(&periodic_timer, SEND_INTERVAL);#if (MIST_CONF_NETSTACK & MIST_CONF_MULTICHAN)  if(HAS_MULTICHANNEL_AUTH()) {    multichan_force_auth(1);  }#endif /* (MIST_CONF_NETSTACK & MIST_CONF_MULTICHAN) */#if (MIST_CONF_NETSTACK & MIST_CONF_DROWSIE_MULTICHANNEL)  if(HAS_MULTICHANNEL_AUTH()) {    drowsie_multichannel_force_auth(1);  }#endif /* (MIST_CONF_NETSTACK & MIST_CONF_DROWSIE_MULTICHANNEL) */  while(1) {    static char buf[MAX_SIZE + 1];    static int current_size = MIN_SIZE;    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer));    etimer_reset(&periodic_timer);    if(IS_SENDER()) {      int i;      current_size++;      if(current_size > MAX_SIZE) {        current_size = MIN_SIZE;      }      for(i = 0; i < current_size; i++) {        buf[i] = 'a';      }      buf[current_size] = '/0';      printf("TX[%02d]: '%s'/n", current_size, buf);      leds_toggle(LEDS_GREEN);      uip_create_linklocal_allnodes_mcast(&addr);      simple_udp_sendto(&broadcast_connection, buf, current_size, &addr);    }  }  PROCESS_END();}
开发者ID:ADVANSEE,项目名称:mist,代码行数:54,


示例9: PROCESS_THREAD

/*---------------------------------------------------------------------------*/PROCESS_THREAD(broadcast_example_process, ev, data){  static struct etimer periodic_timer;  static struct etimer send_timer;  uip_ipaddr_t addr;  char buf[sizeof(uip_ipaddr_t) * MAX_IP];  char* ptr;  int len;  struct ip_list_struct *s;  PROCESS_BEGIN();  simple_udp_register(&broadcast_connection, UDP_PORT,                      NULL, UDP_PORT,                      receiver);  list_init(ip_list);  etimer_set(&periodic_timer, SEND_INTERVAL);  while(1) {    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer));    etimer_reset(&periodic_timer);    etimer_set(&send_timer, SEND_TIME);    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&send_timer));    printf("Sending broadcast adv message/n");        // Create the message with the list of mi neighbors    ptr = &buf;    len = 0;    for(s = list_head(ip_list);        s != NULL;        s = list_item_next(s)) {      uip_ipaddr_copy((uip_ipaddr_t*)ptr, &s->ip);      ptr += sizeof(uip_ipaddr_t);      len += sizeof(uip_ipaddr_t);    }    // An empty message is not delivered, make some padding and sent it!    if(len == 0){       buf[0] = 0;       len++;    }    // Showtime, deliver the message    uip_create_linklocal_allnodes_mcast(&addr);    simple_udp_sendto(&broadcast_connection, &buf, len, &addr);  }  PROCESS_END();}
开发者ID:lab-anaws,项目名称:lab2,代码行数:52,


示例10: udp_broadcast_new

/*---------------------------------------------------------------------------*/struct uip_udp_conn *udp_broadcast_new(uint16_t port, void *appstate){    uip_ipaddr_t addr;    struct uip_udp_conn *conn;#if UIP_CONF_IPV6    uip_create_linklocal_allnodes_mcast(&addr);#else    uip_ipaddr(&addr, 255,255,255,255);#endif /* UIP_CONF_IPV6 */    conn = udp_new(&addr, port, appstate);    if(conn != NULL) {        udp_bind(conn, port);    }    return conn;}
开发者ID:kenog,项目名称:contiki-inga,代码行数:18,


示例11: PROCESS_THREAD

/*--------------------------------PROCESS BROADCAST----------------------------------*/PROCESS_THREAD(broadcast_example_process, ev, data){  static struct etimer periodic_timer;  static struct etimer send_timer;  uip_ipaddr_t addr;  static uint8_t initialize = 1; //this is used for mote-1 only for intialization#if RANDOM_TOKEN_ERROR  random_init(clock_time() % 100);#endif  PROCESS_BEGIN();  simple_udp_register(&broadcast_connection, UDP_PORT,                      NULL, UDP_PORT,                      receiver);  etimer_set(&periodic_timer, SEND_INTERVAL);  while(1) {    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer));    etimer_reset(&periodic_timer);    etimer_set(&send_timer, SEND_TIME);    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&send_timer));    //printf("Sending broadcast/n");    uip_create_linklocal_allnodes_mcast(&addr);    // initialize transmission by mote-1    if (1 == node_id && 1 == initialize) {      token = 1;      initialize = 0; // this statement will never execute again    }    if (token) {       printf("I got the token, it's my turn/n");      simple_udp_sendto(&broadcast_connection, (uint8_t *) &node_id, 4, &addr);      token = 0;            //trigger an event to all service subscribers      printf("RES-Event Process/n");      res_event.trigger();    }  }  PROCESS_END();}
开发者ID:kincki,项目名称:contiki,代码行数:47,


示例12: send_purge_na

voidsend_purge_na(uip_ipaddr_t *prefix){    if ( (nvm_data.mode & CETIC_MODE_SMART_MULTI_BR) == 0 ) {        return;    }    LOG6LBR_6ADDR(INFO, prefix, "Sending purge NA for ");    uip_ext_len = 0;    UIP_IP_BUF->vtc = 0x60;    UIP_IP_BUF->tcflow = 0;    UIP_IP_BUF->flow = 0;    UIP_IP_BUF->len[0] = 0;       /* length will not be more than 255 */    UIP_IP_BUF->len[1] = UIP_ICMPH_LEN + UIP_ND6_NA_LEN + UIP_ND6_OPT_LLAO_LEN;    UIP_IP_BUF->proto = UIP_PROTO_ICMP6;    UIP_IP_BUF->ttl = UIP_ND6_HOP_LIMIT;    uip_create_linklocal_allnodes_mcast(&UIP_IP_BUF->destipaddr);    uip_ipaddr_copy(&UIP_IP_BUF->srcipaddr, prefix);    UIP_ICMP_BUF->type = ICMP6_NA;    UIP_ICMP_BUF->icode = 0;    UIP_ND6_NA_BUF->flagsreserved = UIP_ND6_NA_FLAG_OVERRIDE;    memcpy(&UIP_ND6_NA_BUF->tgtipaddr, prefix, sizeof(uip_ipaddr_t));    create_llao(&uip_buf[uip_l2_l3_icmp_hdr_len + UIP_ND6_NA_LEN],                UIP_ND6_OPT_TLLAO);    UIP_ICMP_BUF->icmpchksum = 0;    UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum();    uip_len =        UIP_IPH_LEN + UIP_ICMPH_LEN + UIP_ND6_NA_LEN + UIP_ND6_OPT_LLAO_LEN;    UIP_STAT(++uip_stat.nd6.sent);    PRINTF("Sending Unsolicited NA to ");    PRINT6ADDR(&UIP_IP_BUF->destipaddr);    PRINTF(" from ");    PRINT6ADDR(&UIP_IP_BUF->srcipaddr);    PRINTF(" with target address ");    PRINT6ADDR(&UIP_ND6_NA_BUF->tgtipaddr);    PRINTF("/n");    tcpip_ipv6_output();}
开发者ID:drandreas,项目名称:6lbr,代码行数:44,


示例13: PROCESS_THREAD

/*---------------------------------------------------------------------------*/PROCESS_THREAD(trickle_protocol_process, ev, data){  PROCESS_BEGIN();  PRINTF("Trickle protocol started/n");  uip_create_linklocal_allnodes_mcast(&ipaddr); /* Store for later */  trickle_conn = udp_new(NULL, UIP_HTONS(TRICKLE_PROTO_PORT), NULL);  udp_bind(trickle_conn, UIP_HTONS(TRICKLE_PROTO_PORT));  PRINTF("Connection: local/remote port %u/%u/n",         UIP_HTONS(trickle_conn->lport), UIP_HTONS(trickle_conn->rport));  token = 0;  trickle_timer_config(&tt, IMIN, IMAX, REDUNDANCY_CONST);  trickle_timer_set(&tt, trickle_tx, &tt);  /*   * At this point trickle is started and is running the first interval. All   * nodes 'agree' that token == 0. This will change when one of them randomly   * decides to generate a new one   */  etimer_set(&et, NEW_TOKEN_INTERVAL);  while(1) {    PROCESS_YIELD();    if(ev == tcpip_event) {      tcpip_handler();    } else if(etimer_expired(&et)) {      /* Periodically (and randomly) generate a new token. This will trigger       * a trickle inconsistency */      if((random_rand() % NEW_TOKEN_PROB) == 0) {        token++;        PRINTF("At %lu: Generating a new token 0x%02x/n",               (unsigned long)clock_time(), token);        trickle_timer_reset_event(&tt);      }      etimer_set(&et, NEW_TOKEN_INTERVAL);    }  }  PROCESS_END();}
开发者ID:13416795,项目名称:contiki,代码行数:44,


示例14: broadcast_identity

/*---------------------------------------------------------------------------*/void broadcast_identity(int id){  /* Broadcast its own region rank */  uip_ipaddr_t addr;  identity_pkt_t ipkt;  ipkt.type = 2;  ipkt.id = id;  /* Will be dynamic based on the packet transmission with the parent */  ipkt.loc_addr[0] = sender_id;  ipkt.loc_addr[1] = 0;  ipkt.loc_addr[2] = 0;  ipkt.loc_addr[3] = 0;  uip_create_linklocal_allnodes_mcast(&addr);  uip_udp_packet_sendto(server_conn, &ipkt, sizeof(ipkt),                        &addr, UIP_HTONS(UDP_CLIENT_PORT));}
开发者ID:engalex,项目名称:652Final,代码行数:21,


示例15: PROCESS_THREAD

/*---------------------------------------------------------------------------*/PROCESS_THREAD(broadcast_example_process, ev, data){  static struct etimer periodic_timer;  static struct etimer send_timer;  uip_ipaddr_t addr;  //uip_ip6addr(&addr, 0xfe80, 0, 0, 0, 0, 0, 0, 1);  //uip_ip6addr(&addr, 0xfe01, 0, 0, 0, 0, 0, 0, 1);  PROCESS_BEGIN();#if PLATFORM_HAS_LEDS  leds_off(LEDS_ALL);#endif  simple_udp_register(&broadcast_connection, UDP_PORT,                      NULL, UDP_PORT,                      receiver);  etimer_set(&periodic_timer, SEND_INTERVAL);  while(1) {    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer));    etimer_reset(&periodic_timer);    etimer_set(&send_timer, SEND_TIME);    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&send_timer));    uip_create_linklocal_allnodes_mcast(&addr);#if PLATFORM_HAS_LEDS  leds_on(LEDS_ALL);#endif    /*printf("Sending broadcast from: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x on port %d/n", 	addr.u16[0],addr.u16[1],addr.u16[2],addr.u16[3],addr.u16[4],addr.u16[5],addr.u16[6],addr.u16[7], 	UDP_PORT);*/    printf("Sending broadcast from: %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x on port %d/n", addr.u8[0],addr.u8[1],addr.u8[2],addr.u8[3],addr.u8[4],addr.u8[5],addr.u8[6],addr.u8[7], addr.u8[8],addr.u8[9],addr.u8[10],addr.u8[11],addr.u8[12],addr.u8[13],addr.u8[14],addr.u8[15], UDP_PORT);    simple_udp_sendto(&broadcast_connection, "Test", 4, &addr);#if PLATFORM_HAS_LEDS  leds_off(LEDS_ALL);#endif  }  PROCESS_END();}
开发者ID:LoriDD,项目名称:contiki,代码行数:42,


示例16: receiver

/*---------------------------------------------------------------------------*/static void receiver(struct simple_udp_connection *c, const uip_ipaddr_t *sender_addr, uint16_t sender_port, const uip_ipaddr_t *receiver_addr, uint16_t receiver_port, const uint8_t *data, uint16_t datalen){	C(data)[datalen] = '/0';	int id;	char cmd = jsonData(C(data), "cmd")[0];	uip_ipaddr_t addr;	if(cmd == 'g'){ /* GET SENSOR STATUS */		id = atoi(jsonData(C(data),"id"));		sensorsList[id].status = atoi(jsonData(C(data),"st"));		if(sensorsList[id].type == SENSOR_NONE)			sensorsList[id].type = atoi(jsonData(C(data),"ty"));		sensorsList[id].lastTime = 0;		sensorsList[id].failedTimeouts = 0;		updateDataToServer(C(data)); /* SEND DATA TO RASPBERRY PI */	}else if(cmd == 'c'){		id = atoi(jsonData(C(data),"id"));		sensorsList[id].status = atoi(jsonData(C(data),"st"));		sensorsList[id].lastTime = 0;		sensorsList[id].failedTimeouts = 0;		if(isAllowed(jsonData(C(data),"key")) == 0)			return;		uip_create_linklocal_allnodes_mcast(&addr);		if(isAlarmEnabled == 0){ /* ALARM IS DISABLED */			isAlarmEnabled = 1;			sprintf(string6LOWPAN,"{/"cmd/":/"l/"}");		}else{ /*ALARM IS ENABLED*/			isAlarmEnabled = 0;			sprintf(string6LOWPAN,"{/"cmd/":/"u/"}");		}		simple_udp_sendto(&broadcast_connection, string6LOWPAN, strlen(string6LOWPAN), &addr);		updateDataToServer(C(data));		updateDataToServer(C(string6LOWPAN));	}}
开发者ID:lomithrani,项目名称:E-protect,代码行数:42,


示例17: send

/*---------------------------------------------------------------------------*/static voidsend(void *ptr){  struct propple_socket *s = ptr;  struct propple_msg m;  uip_ipaddr_t addr;  m.h.seqno = s->seqno;  m.h.datalen = s->datalen;  memcpy(m.data, s->data, s->datalen);  uip_create_linklocal_allnodes_mcast(&addr);  printf("propple-socket: send sending/n");  if(udp_socket_sendto(&s->s,                       &m, sizeof(struct propple_hdr) + s->datalen,                       &addr, s->port) == 0) {    printf("propple-socket: send: failed/n");  } else {    printf("propple-socket: send: sending %d bytes/n",           sizeof(struct propple_hdr) + s->datalen);  }}
开发者ID:ADVANSEE,项目名称:mist,代码行数:24,


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


示例19: uip_nd6_ra_output

/*---------------------------------------------------------------------------*/voiduip_nd6_ra_output(uip_ipaddr_t * dest){    UIP_IP_BUF->vtc = 0x60;    UIP_IP_BUF->tcflow = 0;    UIP_IP_BUF->flow = 0;    UIP_IP_BUF->proto = UIP_PROTO_ICMP6;    UIP_IP_BUF->ttl = UIP_ND6_HOP_LIMIT;    if(dest == NULL) {        uip_create_linklocal_allnodes_mcast(&UIP_IP_BUF->destipaddr);    } else {        /* For sollicited RA */        uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, dest);    }    uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);    UIP_ICMP_BUF->type = ICMP6_RA;    UIP_ICMP_BUF->icode = 0;    UIP_ND6_RA_BUF->cur_ttl = uip_ds6_if.cur_hop_limit;    UIP_ND6_RA_BUF->flags_reserved =        (UIP_ND6_M_FLAG << 7) | (UIP_ND6_O_FLAG << 6);    UIP_ND6_RA_BUF->router_lifetime = uip_htons(UIP_ND6_ROUTER_LIFETIME);    //UIP_ND6_RA_BUF->reachable_time = uip_htonl(uip_ds6_if.reachable_time);    //UIP_ND6_RA_BUF->retrans_timer = uip_htonl(uip_ds6_if.retrans_timer);    UIP_ND6_RA_BUF->reachable_time = 0;    UIP_ND6_RA_BUF->retrans_timer = 0;    uip_len = UIP_IPH_LEN + UIP_ICMPH_LEN + UIP_ND6_RA_LEN;    nd6_opt_offset = UIP_ND6_RA_LEN;    /* Prefix list */    for(prefix = uip_ds6_prefix_list;            prefix < uip_ds6_prefix_list + UIP_DS6_PREFIX_NB; prefix++) {        if((prefix->isused) && (prefix->advertise)) {            UIP_ND6_OPT_PREFIX_BUF->type = UIP_ND6_OPT_PREFIX_INFO;            UIP_ND6_OPT_PREFIX_BUF->len = UIP_ND6_OPT_PREFIX_INFO_LEN / 8;            UIP_ND6_OPT_PREFIX_BUF->preflen = prefix->length;            UIP_ND6_OPT_PREFIX_BUF->flagsreserved1 = prefix->l_a_reserved;            UIP_ND6_OPT_PREFIX_BUF->validlt = uip_htonl(prefix->vlifetime);            UIP_ND6_OPT_PREFIX_BUF->preferredlt = uip_htonl(prefix->plifetime);            UIP_ND6_OPT_PREFIX_BUF->reserved2 = 0;            uip_ipaddr_copy(&(UIP_ND6_OPT_PREFIX_BUF->prefix), &(prefix->ipaddr));            nd6_opt_offset += UIP_ND6_OPT_PREFIX_INFO_LEN;            uip_len += UIP_ND6_OPT_PREFIX_INFO_LEN;        }    }    /* Source link-layer option */    create_llao((uint8_t *)UIP_ND6_OPT_HDR_BUF, UIP_ND6_OPT_SLLAO);    uip_len += UIP_ND6_OPT_LLAO_LEN;    nd6_opt_offset += UIP_ND6_OPT_LLAO_LEN;    /* MTU */    UIP_ND6_OPT_MTU_BUF->type = UIP_ND6_OPT_MTU;    UIP_ND6_OPT_MTU_BUF->len = UIP_ND6_OPT_MTU_LEN >> 3;    UIP_ND6_OPT_MTU_BUF->reserved = 0;    //UIP_ND6_OPT_MTU_BUF->mtu = uip_htonl(uip_ds6_if.link_mtu);    UIP_ND6_OPT_MTU_BUF->mtu = uip_htonl(1500);    uip_len += UIP_ND6_OPT_MTU_LEN;    nd6_opt_offset += UIP_ND6_OPT_MTU_LEN;#if UIP_CONF_DS6_ROUTE_INFORMATION    for(rtinfo = uip_ds6_route_info_list;            rtinfo < uip_ds6_route_info_list + UIP_DS6_ROUTE_INFO_NB; rtinfo++) {        if((rtinfo->isused)) {            UIP_ND6_OPT_ROUTE_BUF->type = UIP_ND6_OPT_ROUTE_INFO;            UIP_ND6_OPT_ROUTE_BUF->len =(rtinfo->length >> 6) + 1 ;            UIP_ND6_OPT_ROUTE_BUF->preflen = rtinfo->length;            UIP_ND6_OPT_ROUTE_BUF->flagsreserved = rtinfo->flags;            UIP_ND6_OPT_ROUTE_BUF->rlifetime = uip_htonl(rtinfo->lifetime);            uip_ipaddr_copy(&(UIP_ND6_OPT_ROUTE_BUF->prefix), &(rtinfo->ipaddr));            nd6_opt_offset += ((rtinfo->length >> 6) + 1)<<3;            uip_len += ((rtinfo->length >> 6) + 1)<<3;        }    }
开发者ID:drandreas,项目名称:6lbr,代码行数:84,


示例20: ns_input

static voidns_input(void){    uint8_t flags;#if CETIC_6LBR_SMARTBRIDGE    uip_ds6_route_t * route;#endif    uip_ipaddr_t tgtipaddr;    PRINTF("Received NS from ");    PRINT6ADDR(&UIP_IP_BUF->srcipaddr);    PRINTF(" to ");    PRINT6ADDR(&UIP_IP_BUF->destipaddr);    PRINTF(" with target address");    PRINT6ADDR((uip_ipaddr_t *) (&UIP_ND6_NS_BUF->tgtipaddr));    PRINTF("/n");    UIP_STAT(++uip_stat.nd6.recv);#if UIP_CONF_IPV6_CHECKS    if((UIP_IP_BUF->ttl != UIP_ND6_HOP_LIMIT) ||            (uip_is_addr_mcast(&UIP_ND6_NS_BUF->tgtipaddr)) ||            (UIP_ICMP_BUF->icode != 0)) {        PRINTF("NS received is bad/n");        goto discard;    }#endif /* UIP_CONF_IPV6_CHECKS */    /* Options processing */    nd6_opt_llao = NULL;    nd6_opt_offset = UIP_ND6_NS_LEN;    while(uip_l3_icmp_hdr_len + nd6_opt_offset < uip_len) {#if UIP_CONF_IPV6_CHECKS        if(UIP_ND6_OPT_HDR_BUF->len == 0) {            PRINTF("NS received is bad/n");            goto discard;        }#endif /* UIP_CONF_IPV6_CHECKS */        switch (UIP_ND6_OPT_HDR_BUF->type) {        case UIP_ND6_OPT_SLLAO:            nd6_opt_llao = &uip_buf[uip_l2_l3_icmp_hdr_len + nd6_opt_offset];#if UIP_CONF_IPV6_CHECKS            /* There must be NO option in a DAD NS */            if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {                PRINTF("NS received is bad/n");                goto discard;            } else {#endif /*UIP_CONF_IPV6_CHECKS */                nbr = uip_ds6_nbr_lookup(&UIP_IP_BUF->srcipaddr);                if(nbr == NULL) {                    /* Copy link address to a uip_lladdr_t first                     * to ensure the second argument to uip_ds6_nbr_add is word-aligned */                    uip_lladdr_t lladdr;                    memcpy(&lladdr, &nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], UIP_LLADDR_LEN);                    uip_ds6_nbr_add(&UIP_IP_BUF->srcipaddr, &lladdr, 0, NBR_STALE);                } else {                    uip_lladdr_t *lladdr = (uip_lladdr_t *)uip_ds6_nbr_get_ll(nbr);                    if(memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],                              lladdr, UIP_LLADDR_LEN) != 0) {                        memcpy(lladdr, &nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], UIP_LLADDR_LEN);                        nbr->state = NBR_STALE;                    } else {                        if(nbr->state == NBR_INCOMPLETE) {                            nbr->state = NBR_STALE;                        }                    }                }#if UIP_CONF_IPV6_CHECKS            }#endif /*UIP_CONF_IPV6_CHECKS */            break;        default:            PRINTF("ND option not supported in NS");            break;        }        nd6_opt_offset += (UIP_ND6_OPT_HDR_BUF->len << 3);    }    memcpy(&tgtipaddr, &UIP_ND6_NS_BUF->tgtipaddr, sizeof(tgtipaddr));    addr = uip_ds6_addr_lookup(&tgtipaddr);#if CETIC_6LBR_SMARTBRIDGE    //ND Proxy implementation    if ( addr == NULL ) {        if ( (route = uip_ds6_route_lookup(&tgtipaddr)) != NULL ) {            if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {                /* DAD CASE */                uip_create_linklocal_allnodes_mcast(&tgtipaddr);                uip_ipaddr_copy(&UIP_IP_BUF->srcipaddr, &tgtipaddr);                flags = UIP_ND6_NA_FLAG_OVERRIDE;                goto create_na;            } else {                uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &UIP_IP_BUF->srcipaddr);                uip_ipaddr_copy(&UIP_IP_BUF->srcipaddr, &tgtipaddr);                flags = UIP_ND6_NA_FLAG_SOLICITED | UIP_ND6_NA_FLAG_OVERRIDE;                goto create_na;            }        }    }#endif    if(addr != NULL) {#if UIP_ND6_DEF_MAXDADNS > 0//.........这里部分代码省略.........
开发者ID:drandreas,项目名称:6lbr,代码行数:101,


示例21: PROCESS_THREAD

/* this process handle the reception of messages */PROCESS_THREAD(delugeGroupP, ev, data){	int fd;	char* buf;	uint8_t nr_pages_local;	static struct etimer et;		static struct jsonparse_state jsonState;	static ContainerRoot * newModel;	static uip_ipaddr_t addr;	PROCESS_BEGIN();		/* keep track of the singleton instance */	instance = (DelugeGroup*)data;	/* register new event types */	NEW_AVAILABLE_OA_MODEL = process_alloc_event();	NEW_OA_MODEL_DOWNLOADED = process_alloc_event();	/* initialize model announcement's system */	simple_udp_register(&deluge_group_broadcast, 34555, NULL, 34555, model_version_recv);	/* set announcement's initial value*/	instance->info.version = 0;	instance->info.nr_pages = 0;		/* set timer for announcements */	etimer_set(&et, CLOCK_SECOND * instance->interval);	while (1) {		/* Listen for announcements every interval seconds. */		PROCESS_WAIT_EVENT();		if (ev == PROCESS_EVENT_TIMER) {			/* announce my model */			uip_create_linklocal_allnodes_mcast(&addr);  			simple_udp_sendto(&deluge_group_broadcast, &instance->info, sizeof(struct ModelInfo), &addr);  						etimer_restart(&et);		}		else if (ev == NEW_AVAILABLE_OA_MODEL){			/* receive the new over the air model */			 			/* contains the number of pages */			nr_pages_local = instance->info.nr_pages;						/* create the file with the required number of pages */			cfs_remove(instance->fileNameWithModel);			fd = cfs_open(instance->fileNameWithModel, CFS_WRITE);			buf = (char*) malloc(S_PAGE);			memset(buf, '0' , S_PAGE);			PRINTF("Number of pages is %d/n", nr_pages_local);			while(nr_pages_local) {				cfs_seek(fd, 0, CFS_SEEK_END);				cfs_write(fd, buf, S_PAGE);				nr_pages_local--;			}			free(buf);			cfs_close(fd);			/* Deluge-based dissemination */			if (deluge_disseminate(instance->fileNameWithModel, 0, modelDownloaded)) {				PRINTF("ERROR: some problem waiting for new version of the file/n");			}			else {				PRINTF("INFO: Waiting for new version of the file /n");			}		}		else if (ev == NEW_OA_MODEL_DOWNLOADED) {			/* deserialize the model received over the air */			PRINTF("New model %s received in group with instance %p/n", instance->fileNameWithModel, instance);			newModel = NULL;						/* TODO: check if the file exists */						/* parse model from json file */			jsonparse_setup(&jsonState, instance->fileNameWithModel);			newModel = JSONKevDeserializer(&jsonState, jsonparse_next(&jsonState));			cfs_close(jsonState.fd);			PRINTF("INFO: Deserialization finished in Deluge Group %p/n", newModel);			/* save a reference to the new model */			instance->lastReceivedModel = newModel;			/* Afterwards, just call notifyNewModel */						if (newModel != NULL && notifyNewModel(newModel) == PROCESS_ERR_OK) {				PRINTF("INFO: Model was successfully sent/n");			}			else {				PRINTF("ERROR: The model cannot be loaded!/n");			}					}	}	PROCESS_END();//.........这里部分代码省略.........
开发者ID:AlexandreRio,项目名称:contiki,代码行数:101,


示例22: uip_nd6_ns_input

voiduip_nd6_ns_input(void){  u8_t flags;  PRINTF("Received NS from");  PRINT6ADDR(&UIP_IP_BUF->srcipaddr);  PRINTF("to");  PRINT6ADDR(&UIP_IP_BUF->destipaddr);  PRINTF("with target address");  PRINT6ADDR((uip_ipaddr_t *) (&UIP_ND6_NS_BUF->tgtipaddr));  PRINTF("/n");  UIP_STAT(++uip_stat.nd6.recv);#if UIP_CONF_IPV6_CHECKS  if((UIP_IP_BUF->ttl != UIP_ND6_HOP_LIMIT) ||     (uip_is_addr_mcast(&UIP_ND6_NS_BUF->tgtipaddr)) ||     (UIP_ICMP_BUF->icode != 0)) {    PRINTF("NS received is bad/n");    goto discard;  }#endif /* UIP_CONF_IPV6_CHECKS */  /* Options processing */  nd6_opt_llao = NULL;  nd6_opt_offset = UIP_ND6_NS_LEN;  while(uip_l3_icmp_hdr_len + nd6_opt_offset < uip_len) {#if UIP_CONF_IPV6_CHECKS    if(UIP_ND6_OPT_HDR_BUF->len == 0) {      PRINTF("NS received is bad/n");      goto discard;    }#endif /* UIP_CONF_IPV6_CHECKS */    switch (UIP_ND6_OPT_HDR_BUF->type) {    case UIP_ND6_OPT_SLLAO:      nd6_opt_llao = &uip_buf[uip_l2_l3_icmp_hdr_len + nd6_opt_offset];#if UIP_CONF_IPV6_CHECKS      /* There must be NO option in a DAD NS */      if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {        PRINTF("NS received is bad/n");        goto discard;      } else {#endif /*UIP_CONF_IPV6_CHECKS */        nbr = uip_ds6_nbr_lookup(&UIP_IP_BUF->srcipaddr);        if(nbr == NULL) {          uip_ds6_nbr_add(&UIP_IP_BUF->srcipaddr,			  (uip_lladdr_t *)&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],			  0, NBR_STALE);        } else {          if(memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],		    &nbr->lladdr, UIP_LLADDR_LEN) != 0) {            memcpy(&nbr->lladdr, &nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],		   UIP_LLADDR_LEN);            nbr->state = NBR_STALE;          } else {            if(nbr->state == NBR_INCOMPLETE) {              nbr->state = NBR_STALE;            }          }        }#if UIP_CONF_IPV6_CHECKS      }#endif /*UIP_CONF_IPV6_CHECKS */      break;    default:      PRINTF("ND option not supported in NS");      break;    }    nd6_opt_offset += (UIP_ND6_OPT_HDR_BUF->len << 3);  }  addr = uip_ds6_addr_lookup(&UIP_ND6_NS_BUF->tgtipaddr);  if(addr != NULL) {    if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {      /* DAD CASE */#if UIP_CONF_IPV6_CHECKS      if(!uip_is_addr_solicited_node(&UIP_IP_BUF->destipaddr)) {        PRINTF("NS received is bad/n");        goto discard;      }#endif /* UIP_CONF_IPV6_CHECKS */      if(addr->state != ADDR_TENTATIVE) {        uip_create_linklocal_allnodes_mcast(&UIP_IP_BUF->destipaddr);        uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);        flags = UIP_ND6_NA_FLAG_OVERRIDE;        goto create_na;      } else {          /** /todo if I sent a NS before him, I win */        uip_ds6_dad_failed(addr);        goto discard;      }    }#if UIP_CONF_IPV6_CHECKS    if(uip_ds6_is_my_addr(&UIP_IP_BUF->srcipaddr)) {        /**         * /NOTE do we do something here? we both are using the same address.         * If we are doing dad, we could cancel it, though we should receive a         * NA in response of DAD NS we sent, hence DAD will fail anyway. If we         * were not doing DAD, it means there is a duplicate in the network!         */      PRINTF("NS received is bad/n");//.........这里部分代码省略.........
开发者ID:EmuxEvans,项目名称:ContikiCC2530Port,代码行数:101,


示例23: uip_nd6_ra_output

/*---------------------------------------------------------------------------*/voiduip_nd6_ra_output(uip_ipaddr_t * dest){  UIP_IP_BUF->vtc = 0x60;  UIP_IP_BUF->tcflow = 0;  UIP_IP_BUF->flow = 0;  UIP_IP_BUF->proto = UIP_PROTO_ICMP6;  UIP_IP_BUF->ttl = UIP_ND6_HOP_LIMIT;  if(dest == NULL) {    uip_create_linklocal_allnodes_mcast(&UIP_IP_BUF->destipaddr);  } else {    /* For sollicited RA */    uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, dest);  }  uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);  UIP_ICMP_BUF->type = ICMP6_RA;  UIP_ICMP_BUF->icode = 0;  UIP_ND6_RA_BUF->cur_ttl = uip_ds6_if.cur_hop_limit;  UIP_ND6_RA_BUF->flags_reserved =    (UIP_ND6_M_FLAG << 7) | (UIP_ND6_O_FLAG << 6);  UIP_ND6_RA_BUF->router_lifetime = uip_htons(UIP_ND6_ROUTER_LIFETIME);  //UIP_ND6_RA_BUF->reachable_time = uip_htonl(uip_ds6_if.reachable_time);  //UIP_ND6_RA_BUF->retrans_timer = uip_htonl(uip_ds6_if.retrans_timer);  UIP_ND6_RA_BUF->reachable_time = 0;  UIP_ND6_RA_BUF->retrans_timer = 0;  uip_len = UIP_IPH_LEN + UIP_ICMPH_LEN + UIP_ND6_RA_LEN;  nd6_opt_offset = UIP_ND6_RA_LEN;#if !UIP_CONF_ROUTER  /* Prefix list */  for(prefix = uip_ds6_prefix_list;      prefix < uip_ds6_prefix_list + UIP_DS6_PREFIX_NB; prefix++) {    if((prefix->isused) && (prefix->advertise)) {      UIP_ND6_OPT_PREFIX_BUF->type = UIP_ND6_OPT_PREFIX_INFO;      UIP_ND6_OPT_PREFIX_BUF->len = UIP_ND6_OPT_PREFIX_INFO_LEN / 8;      UIP_ND6_OPT_PREFIX_BUF->preflen = prefix->length;      UIP_ND6_OPT_PREFIX_BUF->flagsreserved1 = prefix->l_a_reserved;      UIP_ND6_OPT_PREFIX_BUF->validlt = uip_htonl(prefix->vlifetime);      UIP_ND6_OPT_PREFIX_BUF->preferredlt = uip_htonl(prefix->plifetime);      UIP_ND6_OPT_PREFIX_BUF->reserved2 = 0;      uip_ipaddr_copy(&(UIP_ND6_OPT_PREFIX_BUF->prefix), &(prefix->ipaddr));      nd6_opt_offset += UIP_ND6_OPT_PREFIX_INFO_LEN;      uip_len += UIP_ND6_OPT_PREFIX_INFO_LEN;    }  }#endif /* !UIP_CONF_ROUTER */  /* Source link-layer option */  create_llao((uint8_t *)UIP_ND6_OPT_HDR_BUF, UIP_ND6_OPT_SLLAO);  uip_len += UIP_ND6_OPT_LLAO_LEN;  nd6_opt_offset += UIP_ND6_OPT_LLAO_LEN;  /* MTU */  UIP_ND6_OPT_MTU_BUF->type = UIP_ND6_OPT_MTU;  UIP_ND6_OPT_MTU_BUF->len = UIP_ND6_OPT_MTU_LEN >> 3;  UIP_ND6_OPT_MTU_BUF->reserved = 0;  //UIP_ND6_OPT_MTU_BUF->mtu = uip_htonl(uip_ds6_if.link_mtu);  UIP_ND6_OPT_MTU_BUF->mtu = uip_htonl(1500);  uip_len += UIP_ND6_OPT_MTU_LEN;  nd6_opt_offset += UIP_ND6_OPT_MTU_LEN;  UIP_IP_BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8);  UIP_IP_BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);  /*ICMP checksum */  UIP_ICMP_BUF->icmpchksum = 0;  UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum();  UIP_STAT(++uip_stat.nd6.sent);  PRINTF("Sending RA to");  PRINT6ADDR(&UIP_IP_BUF->destipaddr);  PRINTF("from");  PRINT6ADDR(&UIP_IP_BUF->srcipaddr);  PRINTF("/n");  return;}
开发者ID:naguirre,项目名称:contiki,代码行数:86,


示例24: uip_nd6_io_ns_input

/*------------------------------------------------------------------*/void uip_nd6_io_ns_input(void){  PRINTF("Received NS from");  PRINT6ADDR(&UIP_IP_BUF->srcipaddr);  PRINTF("to");  PRINT6ADDR(&UIP_IP_BUF->destipaddr);  PRINTF("with target address");  PRINT6ADDR((uip_ipaddr_t *)(&UIP_ND6_NS_BUF->tgtipaddr));  PRINTF("/n");  UIP_STAT(++uip_stat.nd6.recv);   u8_t flags; #if UIP_CONF_IPV6_CHECKS  if((UIP_IP_BUF->ttl != UIP_ND6_HOP_LIMIT) ||     (uip_is_addr_mcast(&UIP_ND6_NS_BUF->tgtipaddr)) ||     (UIP_ICMP_BUF->icode != 0))  {    goto badpkt;  }#endif /* UIP_CONF_IPV6_CHECKS */     /* Options reading: we handle only SLLAO for now */  nd6_opt_llao = NULL;  nd6_opt_offset = UIP_ND6_NS_LEN;  while(uip_l3_icmp_hdr_len + nd6_opt_offset < uip_len) {#if UIP_CONF_IPV6_CHECKS    if(UIP_ND6_OPT_HDR_BUF->len == 0) {      goto badpkt;    }#endif /* UIP_CONF_IPV6_CHECKS */     switch(UIP_ND6_OPT_HDR_BUF->type) {      case UIP_ND6_OPT_SLLAO:        nd6_opt_llao = (struct uip_nd6_opt_llao *)UIP_ND6_OPT_HDR_BUF;        break;      default:        UIP_LOG("ND option not supported in NS");        break;    }    nd6_opt_offset += (UIP_ND6_OPT_HDR_BUF->len << 3);  }  /* Options processing: only SLLAO */  if(nd6_opt_llao != NULL) {#if UIP_CONF_IPV6_CHECKS    /* There must be NO option in a DAD NS */    if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {      goto badpkt;    } else {#endif /*UIP_CONF_IPV6_CHECKS*/      neighbor = uip_nd6_nbrcache_lookup(&UIP_IP_BUF->srcipaddr);      if(neighbor == NULL) {        /* we need to add the neighbor*/        uip_nd6_nbrcache_add(&UIP_IP_BUF->srcipaddr,                             &nd6_opt_llao->addr, 0, STALE);      } else {        /* If LL address changed, set neighbor state to stale */        if(memcmp(&nd6_opt_llao->addr, &neighbor->lladdr, UIP_LLADDR_LEN) != 0) {          memcpy(&neighbor->lladdr, &nd6_opt_llao->addr, UIP_LLADDR_LEN);          neighbor->state = STALE;        } else {          /* If neighbor state is INCOMPLETE, set to STALE */          if(neighbor->state == INCOMPLETE) {            neighbor->state = STALE;          }        }      }#if UIP_CONF_IPV6_CHECKS    }   #endif /*UIP_CONF_IPV6_CHECKS*/  }  /*    * Rest of NS processing: Depends on the purpose of the NS: NUD or DAD or   * Address Resolution    */  /** /note we use ifaddr to remember the target address */  ifaddr = uip_netif_addr_lookup(&UIP_ND6_NS_BUF->tgtipaddr, 128, 0);  if(ifaddr != NULL) {    if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)){      /* DAD CASE */#if UIP_CONF_IPV6_CHECKS       /* Dst address must be solicited node mcast address */      if(!uip_netif_is_addr_my_solicited(&UIP_IP_BUF->destipaddr)){        goto badpkt;      }#endif /* UIP_CONF_IPV6_CHECKS */       /*       * If my address is not tentative, then send a NA to all nodes with       * TLLAO flags are: override = yes.       */        if(ifaddr->state!=TENTATIVE) {          /*          * we need to send a NA, we set the src, dest, flags. tgt remains the         * same and the rest is done at "create_na"          */        uip_create_linklocal_allnodes_mcast(&UIP_IP_BUF->destipaddr);        uip_netif_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);//.........这里部分代码省略.........
开发者ID:EDAyele,项目名称:ptunes,代码行数:101,


示例25: ip64_4to6

//.........这里部分代码省略.........  case IP_PROTO_ICMPV4:    /* Allow only ICMPv4 ECHO_REQUESTS (ping packets) through to the       local IPv6 host. */    if(icmpv4hdr->type == ICMP_ECHO) {      PRINTF("ip64_4to6: translating ICMPv4 ECHO packet/n");      v6hdr->nxthdr = IP_PROTO_ICMPV6;      icmpv6hdr->type = ICMP6_ECHO;      ip64_addr_copy6(&v6hdr->destipaddr, &ipv6_local_address);    } else {      PRINTF("ip64_packet_4to6: ICMPv4 packet type %d not supported/n",	     icmpv4hdr->type);      return 0;    }    break;  default:    /* For protocol types that we do not support, we return 0 to       indicate that we failed to translate the packet to an IPv6       packet. */    PRINTF("ip64_packet_4to6: protocol type %d not supported/n",	   v4hdr->proto);    return 0;  }  /* Translate IPv4 broadcasts to IPv6 all-nodes multicasts. */  if(uip_ip4addr_cmp(&v4hdr->destipaddr, &ipv4_broadcast_addr) ||     (uip_ipaddr_maskcmp(&v4hdr->destipaddr, &ip64_hostaddr,			 &ip64_netmask) &&      ((v4hdr->destipaddr.u16[0] & (~ip64_netmask.u16[0])) ==       (ipv4_broadcast_addr.u16[0] & (~ip64_netmask.u16[0]))) &&      ((v4hdr->destipaddr.u16[1] & (~ip64_netmask.u16[1])) ==       (ipv4_broadcast_addr.u16[1] & (~ip64_netmask.u16[1]))))) {    uip_create_linklocal_allnodes_mcast(&v6hdr->destipaddr);  } else {    if(!ip64_hostaddr_configured) {      PRINTF("ip64_packet_4to6: no local IPv4 address configured, dropping incoming packet./n");      return 0;    }    if(!uip_ip4addr_cmp(&v4hdr->destipaddr, &ip64_hostaddr)) {      PRINTF("ip64_packet_4to6: the IPv4 destination address %d.%d.%d.%d did not match our IPv4 address %d.%d.%d.%d/n",	     uip_ipaddr_to_quad(&v4hdr->destipaddr),	     uip_ipaddr_to_quad(&ip64_hostaddr));      return 0;    }  /* Now we translate the transport layer port numbers. We assume that     the IPv4 packet is a response to a packet that has previously     been translated from IPv6 to IPv4. If this is the case, the tuple     (protocol, destport, srcport, srcaddress) corresponds to an address/port     pair in our mapping table. If we do not find a mapping, we return     0 to indicate that we could not translate the IPv4 packet to an     IPv6 packet. */  /* XXX treat a few ports differently: those ports should be let     through to the local host. For those ports, we set up an address     mapping that ensures that the local port number is retained. */    if((v4hdr->proto == IP_PROTO_TCP || v4hdr->proto == IP_PROTO_UDP)) {      if(uip_htons(tcphdr->destport) < EPHEMERAL_PORTRANGE) {	/* This packet should go to the local host. */	PRINTF("Port is in the non-ephemeral port range %d (%d)/n",	       tcphdr->destport, uip_htons(tcphdr->destport));
开发者ID:EmuxEvans,项目名称:Thingsquare-Contiki-O.S-Porting-STM32F4-Discovery,代码行数:67,


示例26: PROCESS_THREAD

//.........这里部分代码省略.........  SENSORS_ACTIVATE(button_sensor);  simple_udp_register(&broadcast_connection, UDP_PORT,                      NULL, UDP_PORT,                      receiver);  //etimer_set(&periodic_timer, SEND_INTERVAL);  while(1) {/*-----button pressed: generate a new profile-----*/   // PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer));    PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event && data == &button_sensor);   // etimer_reset(&periodic_timer);    etimer_set(&send_timer, SEND_TIME);    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&send_timer));            char buf[152];      int i;            entry_number++;      switch(entry_number){	case 1:       		for(i = 0; i < 152; i++){        		buf[i] = *(profile1++);      			printf("%c", *profile1);      		}	break;	case 2:       		for(i = 0; i < 152; i++){        		buf[i] = *(profile2++);      			printf("%c", *profile2);      		}	break;        case 3:       		for(i = 0; i < 152; i++){        		buf[i] = *(profile3++);      			printf("%c", *profile3);      		}	break;	case 4:       		for(i = 0; i < 152; i++){        		buf[i] = *(profile4++);      			printf("%c", *profile4);      		}	break;	case 5:       		for(i = 0; i < 152; i++){        		buf[i] = *(profile5++);      			printf("%c", *profile5);      		}	break;	case 6:       		for(i = 0; i < 152; i++){        		buf[i] = *(profile6++);      			printf("%c", *profile6);      		}	break;	case 7:       		for(i = 0; i < 152; i++){        		buf[i] = *(profile7++);      			printf("%c", *profile7);      		}	break;	case 8:       		for(i = 0; i < 152; i++){        		buf[i] = *(profile8++);      			printf("%c", *profile8);      		}	break;	case 9:       		for(i = 0; i < 152; i++){        		buf[i] = *(profile9++);      			printf("%c", *profile9);      		}	break;	case 10:       		for(i = 0; i < 152; i++){        		buf[i] = *(profile10++);      			printf("%c", *profile10);      		}	break;	default:		printf("No more profile./n");       		for(i = 0; i < 152; i++){        		buf[i] = *(profile_default++);      			printf("%c", *profile_default);      		}	break;      }    printf("Sending broadcast/n");    uip_create_linklocal_allnodes_mcast(&addr);    simple_udp_sendto(&broadcast_connection, buf, strlen(buf) + 1, &addr);    }  PROCESS_END();}
开发者ID:xytgeorge,项目名称:User-conflict-prevention-CLS,代码行数:101,


示例27: PROCESS_THREAD

/*---------------------------------------------------------------------------*/PROCESS_THREAD(check_sensor_status, ev, data){	uip_ipaddr_t addr;	static struct etimer periodic_timer;	int i=0;	char globalStatus=0;	PROCESS_BEGIN();	for(i=0;i<20;i++){		sensorsList[i].type = SENSOR_NONE;		sensorsList[i].status = STATUS_OK;		sensorsList[i].lastTime = 0;		sensorsList[i].failedTimeouts = 0;	}	sensorsList[0].type = SENSOR_PIR;	sensorsList[1].type = SENSOR_CHOCK;	sensorsList[2].type = SENSOR_PIR;	sensorsList[3].type = SENSOR_RFID;	DDRB = 0x00;	PORTB = 0x00;	//sensorsList[0].type = SENSOR_PIR;	//sensorsList[1].type = SENSOR_PIR;	//sensorsList[2].type = SENSOR_CHOCK;	//rs232_init(RS232_PORT_0, USART_BAUD_19200, USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);	//rs232_redirect_stdout(RS232_PORT_0);	//rs232_send(RS232_PORT_n, char c); // OR FOR STRINGS rs232_print(char *);	rs232_set_input(RS232_PORT_0, uart0_callback);	uart0_setLineCallback(baseReadyUART);	rs232_init(RS232_PORT_1, USART_BAUD_9600, USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);	rs232_set_input(RS232_PORT_1, uart1_callback);	uart1_setLineCallback(lineReadyUART1);	simple_udp_register(&broadcast_connection, UDP_PORT, NULL, UDP_PORT, receiver);	etimer_set(&periodic_timer, CHECK_INTERVAL);	while(1) {		PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer));		etimer_reset(&periodic_timer);		for(i=0;i<20;i++){			if(sensorsList[i].type != 0){				sensorsList[i].lastTime++;				if(sensorsList[i].lastTime == 11){ /* SECONDS / 2 => *0->11* 6 seconds without infos */					sensorsList[i].failedTimeouts++;					sensorsList[i].lastTime = 0;					uip_create_linklocal_allnodes_mcast(&addr);					sprintf(string6LOWPAN,"{/"cmd/":/"s/",/"id/":/"%d/"}",i);					simple_udp_sendto(&broadcast_connection, string6LOWPAN, strlen(string6LOWPAN), &addr);					if(sensorsList[i].failedTimeouts == 3){						sensorsList[i].failedTimeouts = 0;						sensorsList[i].status = STATUS_TIMEOUT;						printf("{/"cmd/":/"g/",/"id/":/"%d/",/"st/":/"%d/",/"ty/":/"%d/"}/n", i, sensorsList[i].status, sensorsList[i].type);					}				}			}		}	}	PROCESS_END();}
开发者ID:lomithrani,项目名称:E-protect,代码行数:75,



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


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