void listen_init(void) { //80端口用于web页面 uip_listen(HTONS(8079)); //用于串口波特率设置 uip_listen(HTONS(8080)); //用于收发数据 uip_listen(HTONS(80)); /* http server */ }
/** * \brief Start listening to the specified port. Standard BSD listen() with internal name. * \param[in] desc socket descriptor to start listening on. * \param[in] maxcon is be the maximum TCP connections to accept on that socket. Unsued parameter with current implementation. * \details To accept connections, a socket is first created with socket(), a willingness to accept incoming connections is specified with listen(), and then the connections are accepted with accept(). The listen() call applies only to sockets of type \ref SOCK_STREAM (TCP). * \note Default maximum number of connections unknown? * \return On connection success, zero is returned. On error, -1 is returned. * \callgraph */ int _sys_sock_listen(int fd,int maxcon){ #if defined (__KERNEL_NET_IPSTACK) && defined (USE_UIP_CORE) pid_t pid; kernel_pthread_t* pthread_ptr; hsock_t hsock = 0; desc_t desc; // // if(!(pthread_ptr = kernel_pthread_self())){ __set_kernel_pthread_errno(ESRCH); return -1; } if((pid=pthread_ptr->pid)<=0){ __set_kernel_pthread_errno(ESRCH); return -1; } // if(fd<0){ __set_kernel_pthread_errno (EBADF); return -1; } // desc = process_lst[pid]->desc_tbl[fd]; if(desc<0){ __set_kernel_pthread_errno (EBADF); return -1; } if(!ofile_lst[desc].used){ __set_kernel_pthread_errno (EBADF); return -1; } if(! (hsock = ofile_lst[desc].p) ){ __set_kernel_pthread_errno (ENOTSOCK); return -1; } if(((socket_t*)hsock)->protocol!=IPPROTO_TCP){ __set_kernel_pthread_errno (EPROTONOSUPPORT); return -1; } //lock __lock_io(ofile_lst[desc].owner_pthread_ptr_write,desc,O_WRONLY); __lock_io(ofile_lst[desc].owner_pthread_ptr_read,desc,O_RDONLY); // ((socket_t*)hsock)->state = STATE_SOCKET_LISTEN; #if UIP_CONF_IPV6 uip_listen( (u16_t)( ((socket_t*)hsock)->addr_in.sin6_port) ); #else uip_listen( (u16_t)( ((socket_t*)hsock)->addr_in.sin_port) ); #endif //unlock __unlock_io(ofile_lst[desc].owner_pthread_ptr_write,desc,O_WRONLY); __unlock_io(ofile_lst[desc].owner_pthread_ptr_read,desc,O_RDONLY); // __set_kernel_pthread_errno (0); // return 0; #else return -1; #endif } //end of _sys_sock_listen()
void network_init(void) { uip_listen(HTONS(NETWORK_PORT_GCODE)); uip_listen(HTONS(NETWORK_PORT_DEBUG)); // Listen on a UDP port uip_ipaddr_t addr; struct uip_udp_conn *c; uip_ipaddr(&addr, 0,0,0,0); c = uip_udp_new(&addr, HTONS(0)); if(c != NULL) uip_udp_bind(c, HTONS(NETWORK_PORT_GCODE)); }
// Accept a connection on the given port, return its socket id (and the IP of the remote host by side effect) int elua_accept( u16 port, unsigned timer_id, u32 to_us, elua_net_ip* pfrom ) { u32 tmrstart = 0; int old_status; if( !elua_uip_configured ) return -1; #ifdef BUILD_CON_TCP if( port == ELUA_NET_TELNET_PORT ) return -1; #endif old_status = platform_cpu_set_global_interrupts( PLATFORM_CPU_DISABLE ); uip_unlisten( htons( port ) ); uip_listen( htons( port ) ); platform_cpu_set_global_interrupts( old_status ); elua_uip_accept_sock = -1; elua_uip_accept_request = 1; if( to_us > 0 ) tmrstart = platform_timer_op( timer_id, PLATFORM_TIMER_OP_START, 0 ); while( 1 ) { if( elua_uip_accept_request == 0 ) break; if( to_us > 0 && platform_timer_get_diff_us( timer_id, tmrstart, platform_timer_op( timer_id, PLATFORM_TIMER_OP_READ, 0 ) ) >= to_us ) { elua_uip_accept_request = 0; break; } } *pfrom = elua_uip_accept_remote; return elua_uip_accept_sock; }
void tpc_app_init(void) { tcp_client_reconnect(); //Only listen one time after get IP address uip_listen(HTONS(9090)); }
void web_init(void) { fls = newHashObject(); fls->addIndexString(fls, "/index.html", indexPage); uip_listen(HTONS(80)); }
/*---------------------------------------------------------------------------*/ void telnetd_init(void) { uip_listen(HTONS(23)); memb_init(&linemem); shell_init(); }
/*-----------------------------------------------------------------------------------*/ void httpd_init(void) { fs_init(); /* Listen to port 80. */ uip_listen(HTONS(80)); }
//port number must be in network order (use htons() ) bool socket_listen( unsigned short port, file_handle_t (*accept_callback)(u16_t local_port, u16_t *remote_address, u16_t remote_port) ) { int i = uip_listen( port ); if( i < 0 ) return false; listenports[i] = accept_callback; return true; }
/** Initialization function for the simple HTTP webserver. */ void HTTPServerApp_Init(void) { /* Listen on port 80 for HTTP connections from hosts */ uip_listen(HTONS(HTTP_SERVER_PORT)); /* Mount the dataflash disk via FatFS */ f_mount(0, &DiskFATState); }
//***************************************************************************** // // Initialize the web server. // // Starts to listen for incoming connection requests on TCP port 80. // //***************************************************************************** void httpd_init(void) { // // Listen to port 80. // uip_listen(HTONS(80)); }
void httpd_init(void) { uip_listen(HTONS(80)); PIN_UNUSED(j1[0]); PIN_UNUSED(j1[1]); // PB5 SETUP_PIN(j1[2], GPIO_PORTB_BASE, GPIO_PIN_0, CONFIG_INPUT); SETUP_PIN(j1[3], GPIO_PORTB_BASE, GPIO_PIN_1, CONFIG_INPUT); SETUP_PIN(j1[4], GPIO_PORTE_BASE, GPIO_PIN_4, CONFIG_INPUT); PIN_UNUSED(j1[5]); // PE5 PIN_UNUSED(j1[6]); // PB4 PIN_UNUSED(j1[7]); // PA5 SETUP_PIN(j1[8], GPIO_PORTA_BASE, GPIO_PIN_6, CONFIG_INPUT); SETUP_PIN(j1[9], GPIO_PORTA_BASE, GPIO_PIN_7, CONFIG_INPUT); PIN_UNUSED(j2[0]); // GND SETUP_PIN(j2[1], GPIO_PORTB_BASE, GPIO_PIN_2, CONFIG_INPUT); SETUP_PIN(j2[2], GPIO_PORTE_BASE, GPIO_PIN_0, CONFIG_INPUT); PIN_UNUSED(j2[3]); // PF0 -- not used PIN_UNUSED(j2[4]); // RESET PIN_UNUSED(j2[5]); // PB7 -- used by SSI2 PIN_UNUSED(j2[6]); // PB6 -- used by SSI2 SETUP_PIN(j2[7], GPIO_PORTA_BASE, GPIO_PIN_4, CONFIG_INPUT); SETUP_PIN(j2[8], GPIO_PORTA_BASE, GPIO_PIN_3, CONFIG_INPUT); SETUP_PIN(j2[9], GPIO_PORTA_BASE, GPIO_PIN_2, CONFIG_INPUT); PIN_UNUSED(j3[0]); // 5.0V PIN_UNUSED(j3[1]); // GND SETUP_PIN(j3[2], GPIO_PORTD_BASE, GPIO_PIN_0, CONFIG_INPUT); SETUP_PIN(j3[3], GPIO_PORTD_BASE, GPIO_PIN_1, CONFIG_INPUT); SETUP_PIN(j3[4], GPIO_PORTD_BASE, GPIO_PIN_2, CONFIG_INPUT); SETUP_PIN(j3[5], GPIO_PORTD_BASE, GPIO_PIN_3, CONFIG_INPUT); SETUP_PIN(j3[6], GPIO_PORTE_BASE, GPIO_PIN_1, CONFIG_INPUT); SETUP_PIN(j3[7], GPIO_PORTE_BASE, GPIO_PIN_2, CONFIG_INPUT); SETUP_PIN(j3[8], GPIO_PORTE_BASE, GPIO_PIN_3, CONFIG_INPUT); SETUP_PIN(j3[9], GPIO_PORTF_BASE, GPIO_PIN_1, CONFIG_OUTPUT); SETUP_PIN(j4[0], GPIO_PORTF_BASE, GPIO_PIN_2, CONFIG_OUTPUT); SETUP_PIN(j4[1], GPIO_PORTF_BASE, GPIO_PIN_3, CONFIG_OUTPUT); SETUP_PIN(j4[2], GPIO_PORTB_BASE, GPIO_PIN_3, CONFIG_INPUT); SETUP_PIN(j4[3], GPIO_PORTC_BASE, GPIO_PIN_4, CONFIG_INPUT); SETUP_PIN(j4[4], GPIO_PORTC_BASE, GPIO_PIN_5, CONFIG_INPUT); SETUP_PIN(j4[5], GPIO_PORTC_BASE, GPIO_PIN_6, CONFIG_INPUT); SETUP_PIN(j4[6], GPIO_PORTC_BASE, GPIO_PIN_7, CONFIG_INPUT); SETUP_PIN(j4[7], GPIO_PORTD_BASE, GPIO_PIN_6, CONFIG_INPUT); SETUP_PIN(j4[8], GPIO_PORTD_BASE, GPIO_PIN_7, CONFIG_INPUT); SETUP_PIN(j4[9], GPIO_PORTF_BASE, GPIO_PIN_4, CONFIG_INPUT); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); configure_pins(j1, HEADER_SIZE); configure_pins(j2, HEADER_SIZE); configure_pins(j3, HEADER_SIZE); configure_pins(j4, HEADER_SIZE); }
void srv_listen(uint16_t port) { // Check if a listening point was already open for(U8 i=0;i<MAX_SOCK_NUM;i++) if(uip_listenports[i] == HTONS(port)) return; // Start listening uip_listen(HTONS(port)); }
/* * The initialization function. We must explicitly call this function * from the system initialization code, some time after uip_init() is * called. */ void iot_tcp_app_init(void) { /* We start to listen for connections on TCP port 7681. */ uip_listen(HTONS(IoTpAd.ComCfg.Local_TCP_Srv_Port)); #if CFG_SUPPORT_TCPIP_ROBUST_TEST uip_listen(HTONS(7684)); #endif #if UIP_HTTP_CLIENT_SUPPORT //http client setting //webclient_get("192.168.1.100", HTTP_SERVER_DEFAULT_PORT, "/MT7681_sta_header.bin"); webclient_get("192.168.2.1", HTTP_SERVER_DEFAULT_PORT, "/index.html"); //printf_high("http client port:%d\n", http_clientPort); uip_listen(HTONS(http_clientPort)); #endif #if TCP_CLI_APP1_ENABLE tcp_cli_app1_init(); #endif #if TCP_SRV_APP1_ENABLE uip_listen(HTONS(TCP_SRV_APP1_LOCAL_PORT)); #endif #if MY_TCP_SRV_APP_ENABLE uip_listen(HTONS(MY_TCP_SRV_APP_LOCAL_PORT)); #endif #if UIP_CLOUD_SERVER_SUPPORT uip_listen(HTONS(CLOUD_TCP_SERVER_PORT)); cloud_para_check_connect(); #endif }
void xtcpd_listen(int linknum, int port_number, xtcp_protocol_t p) { if (p == XTCP_PROTOCOL_TCP) { register_listener(tcp_listeners, linknum, port_number, NUM_TCP_LISTENERS); uip_listen(HTONS(port_number)); } else { register_listener(udp_listeners, linknum, port_number, NUM_UDP_LISTENERS); uip_udp_listen(HTONS(port_number)); } return; }
void netSockListen(UosFile* file) { P_ASSERT("netSockListen", file->fs->cf == &netFSConf); NetSock* sock = (NetSock*)file->fsPriv; posMutexLock(sock->mutex); sock->state = NET_SOCK_LISTENING; posMutexUnlock(sock->mutex); posMutexLock(uipMutex); uip_listen(sock->port); posMutexUnlock(uipMutex); }
/** * \brief Initialize the web server * * This function initializes the web server and should be * called at system boot-up. */ void httpd_init(void) { #if PORT_APP_MAPPER uint8_t index = 0; while (index < HTTPD_MAX_CONNECTIONS) { httpd_state_list[index].state = STATE_UNUSED; index++; } #endif uip_listen(HTONS(80)); }
/* * The initialization function. We must explicitly call this function * from the system initialization code, after uip_init() is called. */ void ftpd_init(void) { u16_t i; // Initialise the ftp daemons for (i = 0; i < NUM_FTP_DAEMONS; i++) { ftpd_state[i].state = FTP_UNUSED; ftpd_state[i].pasvport = PASV_PORT_OFFSET + i; } /* We start to listen for connections on the FTP control port. */ uip_listen(HTONS(FTPD_CONTROL_PORT)); }
/** Initialization function for the DHCP server. */ void DHCPServerApp_Init(void) { /* Listen on port 67 for DHCP server connections from hosts */ uip_listen(HTONS(DHCP_SERVER_PORT)); /* Create a new UDP connection to the DHCP server port for the DHCP solicitation */ struct uip_udp_conn* BroadcastConnection = uip_udp_new(&uip_broadcast_addr, HTONS(DHCP_CLIENT_PORT)); /* If the connection was successfully created, bind it to the local DHCP client port */ if (BroadcastConnection != NULL) uip_udp_bind(BroadcastConnection, HTONS(DHCP_SERVER_PORT)); /* Set all IP addresses as unleased */ memset(LeasedIPs, 0x00, sizeof(LeasedIPs)); }
/*---------------------------------------------------------------------------*/ void tcp_listen(uint16_t port, uint8_t conn_id) { static unsigned char i; struct listenport *l; l = s.listenports; for(i = 0; i < UIP_LISTENPORTS; ++i) { if(l->port == 0) { l->port = port; l->conn_id = conn_id; uip_listen(port); break; } ++l; } }
static void setup_servers() { if (webserver_enabled) { // Initialize the HTTP server, listen to port 80. httpd_init(); printf("Webserver initialized\n"); } if (telnet_enabled) { // Initialize the telnet server Telnetd::init(); printf("Telnetd initialized\n"); } // sftpd service, which is lazily created on reciept of first packet uip_listen(HTONS(115)); }
/*---------------------------------------------------------------------------*/ void tcp_listen(u16_t port, uip_app_handle_t p) { static unsigned char i; struct listenport *l; l = s.listenports; for(i = 0; i < UIP_LISTENPORTS; ++i) { if(l->port == 0) { l->port = port; l->p = p; uip_listen(port); break; } ++l; } }
/*---------------------------------------------------------------------------*/ void tcp_listen(uint16_t port) { static unsigned char i; struct listenport *l; l = s.listenports; for(i = 0; i < UIP_LISTENPORTS; ++i) { if(l->port == 0) { l->port = port; l->p = PROCESS_CURRENT(); uip_listen(port); break; } ++l; } }
/** * @brief Configure Network * @param None * @retval None */ void Network_Configuration(void) { struct uip_eth_addr mac = {{ 0xeb, 0xa0, 0x00, 0x00, 0x00, 0x00 }}; enc28j60_init(mac.addr); uip_init(); uip_arp_init(); uip_setethaddr(mac); uip_ipaddr_t ipaddr; uip_ipaddr(ipaddr, 192, 168, 0, 100); uip_sethostaddr(ipaddr); uip_ipaddr(ipaddr, 255, 255, 255, 0); uip_setnetmask(ipaddr); uip_ipaddr(ipaddr, 192, 168, 0, 1); uip_setdraddr(ipaddr); uip_listen(HTONS(4000)); }
void TcpIpInit(void) { uint8_t IpAddress[4]; uint8_t NetMask[4]; uint8_t RouterIp[4]; /* Set up the network interface */ UserIoIpSettingsGet(IpAddress, NetMask, RouterIp); nic_init(); uip_init(IpAddress, NetMask, RouterIp); uip_arp_init(); uip_listen(HTONS(ETH_LOC_BUFFER_BUFFER_TCP_PORT)); TcpIpUipTimerCounter = 0; TcpIpUipArpTimerCounter = 0; TCCR0B = (1 << CS01) | (1<<CS00); TIMSK0 |= (1<<TOIE0); }
/* -------------------------------------------------------------------------- */ void xtcpd_listen(int linknum, int port_number, xtcp_protocol_t p) { switch(p){ case XTCP_PROTOCOL_TCP: register_listener(tcp_listeners, linknum, port_number, NUM_TCP_LISTENERS); uip_listen(HTONS(port_number)); break; case XTCP_PROTOCOL_UDP: register_listener(udp_listeners, linknum, port_number, NUM_UDP_LISTENERS); uip_udp_listen(HTONS(port_number)); break; default: PRINTF("xtcpd_listen: Unknown protocol."); break; } return; }
/* ----------------------- Begin implementation -----------------------------*/ BOOL xMBTCPPortInit( USHORT usTCPPort ) { BOOL bOkay = FALSE; USHORT usPort; if( usTCPPort == 0 ) { usPort = MB_TCP_DEFAULT_PORT; } else { usPort = (USHORT)usTCPPort; } // 侦听端口 502端口 uip_listen(HTONS(usPort)); bOkay = TRUE; return bOkay; }
// Init application void elua_uip_init( const struct uip_eth_addr *paddr ) { // Set hardware address uip_setethaddr( (*paddr) ); // Initialize the uIP TCP/IP stack. uip_init(); uip_arp_init(); #ifdef BUILD_DHCPC dhcpc_init( paddr->addr, sizeof( *paddr ) ); dhcpc_request(); #else elua_uip_conf_static(); #endif resolv_init(); #ifdef BUILD_CON_TCP uip_listen( HTONS( ELUA_NET_TELNET_PORT ) ); #endif }
void Server::init(pageServingFunction function) { // WiShield init zg_init(); #ifdef USE_DIG0_INTR attachInterrupt(0, zg_isr, LOW); #endif #ifdef USE_DIG8_INTR // set digital pin 8 on Arduino // as ZG interrupt pin PCICR |= (1<<PCIE0); PCMSK0 |= (1<<PCINT0); #endif while(zg_get_conn_state() != 1) { zg_drv_process(); } // Start the stack stack_init(); // Store the callback function for serving pages // and start listening for connections on port 80 if // the function is non-null callbackFunc = function; if (callbackFunc) { // Listen for server requests on port 80 uip_listen(HTONS(80)); } #ifdef DEBUG verbose = true; Serial.println("WiServer init called"); #endif // DEBUG }
void httpd_init(void) { uip_listen(HTONS(HTTPD_PORT), httpd_main); uip_listen(HTONS(HTTPD_ALTERNATE_PORT), httpd_main); }