当前位置: 首页>>代码示例>>C++>>正文


C++ UIP_HTONS函数代码示例

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


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

示例1: PROCESS_THREAD

/*---------------------------------------------------------------------*/
PROCESS_THREAD(codeprop_process, ev, data)
{
  PROCESS_BEGIN();

  elfloader_init();

  s.id = 0/*random_rand()*/;

  send_time = CLOCK_SECOND/4;

  PT_INIT(&s.udpthread_pt);
  PT_INIT(&s.recv_udpthread_pt);

  tcp_listen(UIP_HTONS(CODEPROP_DATA_PORT));

  udp_conn = udp_broadcast_new(UIP_HTONS(CODEPROP_DATA_PORT), NULL);

  s.state = STATE_NONE;
  s.received = 0;
  s.addr = 0;
  s.len = 0;

  fd = cfs_open("codeprop-image", CFS_READ | CFS_WRITE);

  while(1) {

    PROCESS_YIELD();

    if(ev == tcpip_event) {
      uipcall(data);
    } else if(ev == PROCESS_EVENT_TIMER) {
      tcpip_poll_udp(udp_conn);
    }
  }

  PROCESS_END();
}
开发者ID:13416795,项目名称:contiki,代码行数:38,代码来源:codeprop-otf.c

示例2: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_server_process, ev, data)
{
#if UIP_CONF_ROUTER
  uip_ipaddr_t ipaddr;
#endif /* UIP_CONF_ROUTER */

  PROCESS_BEGIN();
  PRINTF("UDP server started\n");

#if RESOLV_CONF_SUPPORTS_MDNS
  resolv_set_hostname("contiki-udp-server");
#endif

#if UIP_CONF_ROUTER
  uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
  uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
  uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
#endif /* UIP_CONF_ROUTER */

  print_local_addresses();

#if SERVER_RPL_ROOT
  create_dag();
#endif
  server_conn = udp_new(NULL, UIP_HTONS(0), NULL);
  udp_bind(server_conn, UIP_HTONS(3000));
PRINTF("Listen port: 3000, TTL=%u\n\r", server_conn->ttl);

  while(1) {
    PROCESS_YIELD();
    if(ev == tcpip_event) {
      tcpip_handler();
    }
  }

  PROCESS_END();
}
开发者ID:tchen600,项目名称:contiki,代码行数:38,代码来源:udp-server.c

示例3: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_client_process, ev, data)
{
  static struct etimer et;
  uip_ipaddr_t ipaddr;

  PROCESS_BEGIN();
  PRINTF("UDP client process started\n");

  uip_ip6addr(&ipaddr, 0xfe80, 0, 0, 0, 0x0215, 0x2000, 0x0002, 0x2145);
  /* new connection with remote host */
  l_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL);
  if(!l_conn) {
    PRINTF("udp_new l_conn error.\n");
  }
  udp_bind(l_conn, UIP_HTONS(LOCAL_CONN_PORT));

  PRINTF("Link-Local connection with ");
  PRINT6ADDR(&l_conn->ripaddr);
  PRINTF(" local/remote port %u/%u\n",
         UIP_HTONS(l_conn->lport), UIP_HTONS(l_conn->rport));

  uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0x0215, 0x2000, 0x0002, 0x2145);
  g_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL);
  if(!g_conn) {
    PRINTF("udp_new g_conn error.\n");
  }
  udp_bind(g_conn, UIP_HTONS(GLOBAL_CONN_PORT));

  PRINTF("Global connection with ");
  PRINT6ADDR(&g_conn->ripaddr);
  PRINTF(" local/remote port %u/%u\n",
         UIP_HTONS(g_conn->lport), UIP_HTONS(g_conn->rport));

  etimer_set(&et, SEND_INTERVAL);

  while(1) {
    PROCESS_YIELD();
    if(etimer_expired(&et)) {
      timeout_handler();
      etimer_restart(&et);
    } else if(ev == tcpip_event) {
      tcpip_handler();
    }
  }

  PROCESS_END();
}
开发者ID:1847123212,项目名称:ampm_contiki_wisun,代码行数:48,代码来源:client.c

示例4: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(fixed_process, ev, data)
{
  static struct etimer et;
  static uip_ipaddr_t ipaddr;
  PROCESS_BEGIN();

  conn = udp_new(NULL, UIP_HTONS(0), NULL);
  udp_bind(conn, UIP_HTONS(3000));
  memset(history,0,sizeof(history));

  etimer_set(&et, SEND_INTERVAL);
  cur_time = 1;
  while(1) {
    PROCESS_YIELD();
    if(etimer_expired(&et)) {
      timeout_handler();
      etimer_restart(&et);
    } else if(ev == tcpip_event) {
      tcpip_handler();
    }
  }

  PROCESS_END();
}
开发者ID:vitorqa,项目名称:CC2530_Contiki,代码行数:25,代码来源:fixo.c

示例5: tcpip_handler

/*--------------------------------------------------------------------------------------------*/
 void tcpip_handler(struct udp_tx *udp_tx_info){
	 if(uip_newdata()){
		 ((char *)uip_appdata)[uip_datalen()] = 0;
		 		PRINTF("Server received: '%s' from [", (char *)uip_appdata);
		 		PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
		 		PRINTF("]:%u",UIP_HTONS(UIP_UDP_BUF->srcport));
		 		PRINTF("\n");
		 		uip_ipaddr_copy(&server_conn->ripaddr, &UIP_IP_BUF->srcipaddr);
		 		server_conn->rport=uip_htons(3007);

		 		PRINTF("Responding with message: ");

		 		udp_data_handler(uip_appdata,udp_tx_info);
	 }
 }
开发者ID:notank,项目名称:contiki,代码行数:16,代码来源:web-sensor.c

示例6: PROCESS_THREAD

PROCESS_THREAD(coap_app_client, ev, data)
{
  PROCESS_BEGIN();

  uip_ip6addr_u8(&server_ipaddr,0xfe,0x80,0,0,0,0,0,0,0xc0,0xa0,0x08,0x39,0xd1,0xe4,0x02,0x05);
  /* new connection with server */
  client_conn = udp_new(&server_ipaddr, UIP_HTONS(REMOTE_PORT), NULL);
  udp_bind(client_conn, UIP_HTONS(LOCAL_PORT));

 // UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport));

  while(1) {
    PROCESS_YIELD();
    if (ev == PROCESS_EVENT_CONTINUE) { 
      send_data();
    } else if (ev == tcpip_event) {
    	sprintf(outStr_buf,"\r\nPacket received\r\n\r\n");
		sendData_inBackground((uint8_t*)outStr_buf,strlen(outStr_buf),1,0);
      //handle_incoming_data();
    }
  }

  PROCESS_END();
}
开发者ID:serflosa,项目名称:torrija_gateway,代码行数:24,代码来源:coap_app_client.c

示例7: udp_socket_connect

/*---------------------------------------------------------------------------*/
int
udp_socket_connect(struct udp_socket *c,
                   uip_ipaddr_t *remote_addr,
                   uint16_t remote_port)
{
  if(c == NULL || c->udp_conn == NULL) {
    return -1;
  }

  if(remote_addr != NULL) {
    uip_ipaddr_copy(&c->udp_conn->ripaddr, remote_addr);
  }
  c->udp_conn->rport = UIP_HTONS(remote_port);
  return 1;
}
开发者ID:hudkmr,项目名称:zephyr,代码行数:16,代码来源:udp-socket.c

示例8: PROCESS_THREAD

PROCESS_THREAD(httpd_process, ev, data)
{
  PROCESS_BEGIN();

  tcp_listen(UIP_HTONS(nvm_data.webserver_port));
  LOG6LBR_INFO("Starting webserver on port %d\n", nvm_data.webserver_port);
  memb_init(&conns);

  while(1) {
    PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);
    httpd_appcall(data);
  }

  PROCESS_END();
}
开发者ID:Ayesha-N,项目名称:6lbr,代码行数:15,代码来源:httpd.c

示例9: send_packet

/*---------------------------------------------------------------------------*/
static void
send_packet(void *ptr)
{
  static int seq_id;
  char buf[MAX_PAYLOAD_LEN];

  seq_id++;
clock_time_t start_time = clock_time();
  PRINTF("DATA send to %d 'Msg %d'\n",
         server_ipaddr.u8[sizeof(server_ipaddr.u8) - 1], seq_id);

  sprintf(buf, "%lu", (unsigned long)start_time);
  uip_udp_packet_sendto(client_conn, buf, strlen(buf),
                        &server_ipaddr, UIP_HTONS(UDP_SERVER_PORT));
}
开发者ID:PseudoAj,项目名称:IoTCodeRecipes,代码行数:16,代码来源:anchore_mote.c

示例10: udp_socket_sendto

/*---------------------------------------------------------------------------*/
int
udp_socket_sendto(struct net_buf *buf, struct udp_socket *c,
                  const void *data, uint16_t datalen,
                  const uip_ipaddr_t *to,
                  uint16_t port)
{
  if(c == NULL || c->udp_conn == NULL) {
    return -1;
  }

  if(c->udp_conn != NULL) {
    return uip_udp_packet_sendto(buf, c->udp_conn, data, datalen,
                          to, UIP_HTONS(port));
  }
  return -1;
}
开发者ID:hudkmr,项目名称:zephyr,代码行数:17,代码来源:udp-socket.c

示例11: PROCESS_THREAD

/*
 * Here we implement the process. The process is run whenever an event
 * occurs, and the parameters "ev" and "data" will we set to the event
 * type and any data that may be passed along with the event.
 */
PROCESS_THREAD(announce_process, ev, data)
{
  static struct uip_udp_conn *c;
  unsigned short sz = 0;
  uip_ipaddr_t addr;
  
  PROCESS_BEGIN();
  c = udp_broadcast_new(UIP_HTONS(4321), NULL);
  
   while(1) {

    
    // wake up periodically every second. 
    
    etimer_set(&timer, 4*CLOCK_SECOND);
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer));

    /*
     * To send a UDP packet request the uIP TCP/IP stack process call
     * us back with the buffer
     */
    tcpip_poll_udp(c);
    PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);

	uip_gethostaddr(&addr);
	// str = makebyte(addr->u8[0], str);
	
    // send our packet.
	sz = snprintf((char *)uip_appdata, uip_mss() - sz,
         "HELLO %s ETH %02x:%02x:%02x:%02x:%02x:%02x IP %d.%d.%d.%d RTC ",
         version,
         eth_mac_addr[0], eth_mac_addr[1], eth_mac_addr[2], 
         eth_mac_addr[3], eth_mac_addr[4], eth_mac_addr[5], 
		addr.u8[0],
		addr.u8[1],
		addr.u8[2],
		addr.u8[3]);
	sz += printRTCTime((char*) uip_appdata+sz );
	sz += snprintf((char *)uip_appdata+sz, uip_mss() - sz, "\n" );
	
    uip_send(uip_appdata, sz);

  }

  PROCESS_END();
}
开发者ID:Paulholland,项目名称:contiki-dspic,代码行数:51,代码来源:pdebug.c

示例12: TCPIP_Connect

bool TCPIP_Connect(void)
{
	// Connect to the remote machine (www.example.com)
	uip_ipaddr(&RemoteIPAddress, 192, 0, 32, 10);	
	TCPConnection = uip_connect(&RemoteIPAddress, UIP_HTONS(80));

	if (TCPConnection != NULL)
	{
		Debug_Print("Connecting to host\r\n");
		return true;
	}
	else
	{
		Debug_Print("Failed to Connect\r\n");
		return false;
	}
}
开发者ID:disengaged,项目名称:avrusbmodem,代码行数:17,代码来源:TCPIP.c

示例13: _demo_udp_sendMsg

/*----------------------------------------------------------------------------*/
static void _demo_udp_sendMsg(uint32_t seqID)
{
	char 		pc_buf[MAX_S_PAYLOAD_LEN];
	int			i;
	i = sprintf(pc_buf, "%lu | ", seqID);
	if (seqID != 0)
		l_expSeqID++;
	LOG_INFO("Lost packets (%lu)\n\r", l_expSeqID - seqID);
    rpl_dag_t *dag = rpl_get_any_dag();
    if(dag && dag->instance->def_route) {
    	_demo_add_ipaddr(pc_buf + i, &dag->instance->def_route->ipaddr);
    } else {
      sprintf(pc_buf + i, "(null)");
    }
    LOG_INFO("Send message: %s\n\r",pc_buf);
	uip_udp_packet_sendto(pst_conn, pc_buf, strlen(pc_buf),&un_server_ipaddr,UIP_HTONS(__SERVER_PORT));
} /* _demo_udp_sendMsg */
开发者ID:kamejoko80,项目名称:emb6,代码行数:18,代码来源:demo_udp_cli.c

示例14: send_actuator_command

void send_actuator_command(int channelID){
	ChannelState * state = get_channel_state(channelID);
	if (state == NULL){
		printf("Device disconnected\n");
		return;
	}
	DataPayload *new_dp = &(state->packet);
	clean_packet(new_dp);
	new_dp->hdr.cmd = CMD;
	new_dp->hdr.src_chan_num = state->chan_num;
	new_dp->hdr.dst_chan_num = state->remote_chan_num;
	new_dp->dhdr.tlen = UIP_HTONS(0);
	send_on_knot_channel(state, new_dp);
	state->ticks = 10;
	state->state = STATE_COMMANDED;

}
开发者ID:fergul,项目名称:KNoT,代码行数:17,代码来源:knot-controller.c

示例15: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(ntpd_process, ev, data)
{
  static struct etimer et;
  static uip_ipaddr_t ipaddr;

  PROCESS_BEGIN();
  PRINTF("ntpd process started\n");

  set_connection_address(&ipaddr);

  /* find the IP of router */
  //etimer_set(&et, CLOCK_SECOND);
  //while(1){
  //  if(uip_ds6_defrt_choose()){
  //    uip_ipaddr_copy(&ipaddr, uip_ds6_defrt_choose());
  //    break;
  //  }
  //  etimer_set(&et, CLOCK_SECOND);
  //  PROCESS_YIELD_UNTIL(etimer_expired(&et));
  //}

  /* new connection with remote host */
  ntp_conn = udp_new(&ipaddr, UIP_HTONS(NTPD_PORT), NULL);

  etimer_set(&et, SEND_INTERVAL * CLOCK_SECOND);
  while(1) {
    PROCESS_YIELD();
    if(etimer_expired(&et)) {
      timeout_handler();
      
      if((clock_seconds() > 4294967290U) || (clock_seconds() < 20)){
	SEND_INTERVAL = 2 * CLOCK_SECOND;
	etimer_set(&et, SEND_INTERVAL);
      } else {
	if(SEND_INTERVAL <= 512 && (getCurrTime() != 0)) {
	  SEND_INTERVAL = 2 * SEND_INTERVAL;
	}
	etimer_set(&et, SEND_INTERVAL * CLOCK_SECOND);
      }
    } else if(ev == tcpip_event) {
      tcpip_handler();
    }
  }

  PROCESS_END();
}
开发者ID:anhquang,项目名称:app-sync,代码行数:47,代码来源:ntpd.c


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