void udp_apps_appcall(void) { #ifdef UIP_DHCP switch(uip_udp_conn->lport) { case UIP_HTONS(IP_PORT_DHCP_SERVER): case UIP_HTONS(IP_PORT_DHCP_CLIENT): dhcpc_appcall(); break; // case UIP_HTONS(IP_PORT_NTP): // ntpd_appcall(); break; default: break; } if( stimer_expired(&dhcpc_state.stimer) ) { dhcpc_state.state = DHCP_STATE_INITIAL; dhcpc_unconfigured(&dhcpc_state); dhcpc_appcall(); } #endif // UIP_DHCP }
// this function maps the current packet against the mappings // pointed to by the param void uip_port_app_mapper(struct port_appcall_map* cur_map) { #ifdef __DHCPC_H__ // if dhcpc is enabled and running we want our ip ASAP so skip all others if(dhcpc_running && uip_poll()) { dhcpc_appcall(); base_conn = NULL; return; } #endif // yes this will walk the entire list which is up to 4 items at the moment while ((base_conn != NULL) && (cur_map->an_appcall != NULL)) { // Now match the app to the packet. // local AND/OR remote ports match // firs check remote port matches and local may or may not // then check local port matches // can't do it in one statement due to the l & r ports could both be zero and match all apps. if (((base_conn->rport == HTONS(cur_map->rport)) && ((cur_map->lport == 0) || (base_conn->lport == HTONS(cur_map->lport)))) || ((base_conn->lport == HTONS(cur_map->lport)) && ((cur_map->rport == 0) || (base_conn->rport == HTONS(cur_map->rport))))) { cur_map->an_appcall(); base_conn = NULL; break; } cur_map++; } }
///////////////////////////////////////////////////////////////////////////// // Called by UDP handler of uIP ///////////////////////////////////////////////////////////////////////////// s32 UIP_TASK_UDP_AppCall(void) { // DHCP client if( uip_udp_conn->rport == HTONS(DHCPC_SERVER_PORT) || uip_udp_conn->rport == HTONS(DHCPC_CLIENT_PORT) ) { dhcpc_appcall(); } return 0; // no error }
void udp_protocol_switcher_appcall(void) { if( uip_udp_conn->rport == HTONS(DNS_SERVER_PORT) ) { // DNS resolver port resolv_appcall(); return; } if( uip_udp_conn->rport == HTONS(DHCP_SERVER_PORT) ) { // DHCP port dhcpc_appcall(); return; } udp_frame_appcall(); }
void dispatch_udp_appcall (void) { #ifdef CFG_SNTP if (uip_udp_conn->rport == HTONS (123)) sntp_appcall (); else #endif #ifdef CFG_DHCP if (uip_udp_conn->rport == HTONS (DHCPC_SERVER_PORT)) dhcpc_appcall (); #endif }
/***************************************************************************** 函 数 名 : my_udp_app 功能描述 : the uip for udp application function 输入参数 : void 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2017年4月17日 作 者 : QSWWD 修改内容 : 新生成函数 *****************************************************************************/ void my_udp_app(void) { printf("my_udp_app...\n\r"); switch(uip_udp_conn->rport) { case HTONS(8899): udp_8899_app(); break; case HTONS(67): dhcpc_appcall(); break; case HTONS(68): dhcpc_appcall(); break; case HTONS(53): resolv_appcall(); break; default: udp_default_app(); break; } }
///////////////////////////////////////////////////////////////////////////// // Called by UDP handler of uIP ///////////////////////////////////////////////////////////////////////////// s32 UIP_TASK_UDP_AppCall(void) { // DHCP client if( uip_udp_conn->rport == HTONS(DHCPC_SERVER_PORT) || uip_udp_conn->rport == HTONS(DHCPC_CLIENT_PORT) ) { dhcpc_appcall(); // monitor option if( udp_monitor_level >= UDP_MONITOR_LEVEL_4_ALL ) UIP_TASK_UDP_MonitorPacket(UDP_MONITOR_RECEIVED, "DHCP"); // should we differ between send/receive? } else { // OSC Server checks for IP/port locally OSC_SERVER_AppCall(); // MonitorPacket called from OSC_SERVER } return 0; // no error }
void route_appcalls() { resolv_appcall(); dhcpc_appcall(); }
/*-----------------------------------------------------------------------------------*/ PROCESS_THREAD(dhcp_process, ev, data) { PROCESS_BEGIN(); ctk_window_new(&window, 29, 14, "DHCP client"); CTK_WIDGET_ADD(&window, &requestbutton); CTK_WIDGET_ADD(&window, &statuslabel); CTK_WIDGET_ADD(&window, &ipaddrlabel); CTK_WIDGET_ADD(&window, &ipaddrtextentry); CTK_WIDGET_ADD(&window, &netmasklabel); CTK_WIDGET_ADD(&window, &netmasktextentry); CTK_WIDGET_ADD(&window, &gatewaylabel); CTK_WIDGET_ADD(&window, &gatewaytextentry); #if WITH_DNS CTK_WIDGET_ADD(&window, &dnsserverlabel); CTK_WIDGET_ADD(&window, &dnsservertextentry); #endif /* WITH_DNS */ CTK_WIDGET_ADD(&window, &savebutton); CTK_WIDGET_ADD(&window, &cancelbutton); CTK_WIDGET_FOCUS(&window, &requestbutton); ctk_window_open(&window); /* Allow resolver to set DNS server address. */ process_post(PROCESS_CURRENT(), PROCESS_EVENT_MSG, NULL); dhcpc_init(uip_ethaddr.addr, sizeof(uip_ethaddr.addr)); while(1) { PROCESS_WAIT_EVENT(); if(ev == PROCESS_EVENT_MSG) { makestrings(); ctk_window_redraw(&window); } else if(ev == tcpip_event) { dhcpc_appcall(ev, data); } else if(ev == ctk_signal_button_activate) { if(data == (process_data_t)&requestbutton) { dhcpc_request(); set_statustext("Requesting..."); } if(data == (process_data_t)&savebutton) { apply_tcpipconfig(); app_quit(); } if(data == (process_data_t)&cancelbutton) { app_quit(); } } else if( #if CTK_CONF_WINDOWCLOSE ev == ctk_signal_window_close || #endif ev == PROCESS_EVENT_EXIT) { app_quit(); } } PROCESS_END(); }
void elua_uip_udp_appcall() { resolv_appcall(); dhcpc_appcall(); }
/* ----------------------------------------------------------------------------- * xtcpd_appcall * * this function is called, when a package comes in for an upper layer * application. * -------------------------------------------------------------------------- */ void xtcpd_appcall(void) { xtcpd_state_t *s; /* --------------- DHCP (v4) --------------- */ if (uip_udpconnection() && (uip_udp_conn->lport == HTONS(DHCPC_CLIENT_PORT) || uip_udp_conn->lport == HTONS(DHCPC_SERVER_PORT))) { #if UIP_USE_DHCP dhcpc_appcall(); #endif return; } /* --------- set up a new connection ---------- */ if (uip_udpconnection()){ s = (xtcpd_state_t *) &(uip_udp_conn->appstate); if (uip_newdata()) { // Set remote port to upper layer state s->conn.remote_port = HTONS(UDPBUF->srcport); uip_ipaddr_copy(s->conn.remote_addr.u8, BUF->srcipaddr.u8); } } else if (uip_conn == NULL) { // dodgy uip_conn return; } else { s = (xtcpd_state_t *) &(uip_conn->appstate); } /* ------ passing new connection event up to the upper xtcp layer ---- */ if (uip_connected()) { if (!uip_udpconnection()) { init_xtcpd_state(s, XTCP_PROTOCOL_TCP, *((xtcp_ipaddr_t *) (&uip_conn->ripaddr)), uip_conn->lport, uip_conn->rport, uip_conn); xtcpd_event(XTCP_NEW_CONNECTION, s); } else { init_xtcpd_state(s, XTCP_PROTOCOL_UDP, *((xtcp_ipaddr_t *) (&uip_udp_conn->ripaddr)), uip_udp_conn->lport, uip_udp_conn->rport, uip_udp_conn); xtcpd_event(XTCP_NEW_CONNECTION, s); } } /* --------------- new data event to deliver --------------- */ if (uip_newdata() && uip_len > 0) { if (s->linknum != -1) { xtcpd_service_clients_until_ready(s->linknum, xtcp_cons.links, xtcp_cons.nr); xtcpd_recv(xtcp_cons.links, s->linknum, xtcp_cons.nr, s, uip_appdata, uip_datalen()); if (!uip_udpconnection() && s->s.ack_recv_mode) { uip_stop(); } } } else if (uip_aborted()) { xtcpd_event(XTCP_ABORTED, s); return; } else if (uip_timedout()) { xtcpd_event(XTCP_TIMED_OUT, s); return; } /* ------------ passing acknowleg event to upper layer ------------- */ if (uip_acked()) { int len; if (s->linknum != -1) { len = do_xtcpd_send(xtcp_cons.links[s->linknum], XTCP_SENT_DATA, s, uip_appdata, uip_udpconnection() ? XTCP_CLIENT_BUF_SIZE : uip_mss()); uip_send(uip_appdata, len); } } /* -------------- retransmit the last package -------------- */ if (uip_rexmit()) { int len; if (s->linknum != -1) { xtcpd_service_clients_until_ready(s->linknum, xtcp_cons.links, xtcp_cons.nr); #ifdef XTCP_ENABLE_PARTIAL_PACKET_ACK s->conn.outstanding = 0; #endif len = xtcpd_send(xtcp_cons.links[s->linknum], XTCP_RESEND_DATA, s, uip_appdata, uip_udpconnection() ? XTCP_CLIENT_BUF_SIZE : uip_mss()); if (len != 0) uip_send(uip_appdata, len); } } /* --------------- poll a connection --------------- */ if (uip_poll()) { uip_xtcpd_handle_poll(s); } #if XTCP_ENABLE_PUSH_FLAG_NOTIFICATION if (uip_tcp_push()) { xtcpd_event(XTCP_PUSH_DATA, s); } #endif /* ------------- connection close event ------------ */ if (uip_closed()) { if (!s->s.closed){ s->s.closed = 1; xtcpd_event(XTCP_CLOSED, s); } return; } }
void xtcpd_appcall(void) { xtcpd_state_t *s; if (uip_udpconnection() && (uip_udp_conn->lport == HTONS(DHCPC_CLIENT_PORT) || uip_udp_conn->lport == HTONS(DHCPC_SERVER_PORT))) { #if UIP_USE_DHCP dhcpc_appcall(); #endif return; } if (uip_udpconnection()) { s = (xtcpd_state_t *) &(uip_udp_conn->appstate); if (uip_newdata()) { s->conn.remote_port = HTONS(UDPBUF->srcport); uip_ipaddr_copy(s->conn.remote_addr, BUF->srcipaddr); } } else if (uip_conn == NULL) { // dodgy uip_conn return; } else s = (xtcpd_state_t *) &(uip_conn->appstate); // if (!uip_udpconnection() && uip_connected()) { if (uip_connected()) { if (!uip_udpconnection()) { xtcpd_init_state(s, XTCP_PROTOCOL_TCP, (unsigned char *) uip_conn->ripaddr, uip_conn->lport, uip_conn->rport, uip_conn); xtcpd_event(XTCP_NEW_CONNECTION, s); } else { xtcpd_init_state(s, XTCP_PROTOCOL_UDP, (unsigned char *) uip_udp_conn->ripaddr, uip_udp_conn->lport, uip_udp_conn->rport, uip_udp_conn); xtcpd_event(XTCP_NEW_CONNECTION, s); } } if (uip_acked()) { int len; if (s->linknum != -1) { xtcpd_service_clients_until_ready(s->linknum, xtcp_links, xtcp_num); len = xtcpd_send(xtcp_links[s->linknum], XTCP_SENT_DATA, s, uip_appdata, uip_udpconnection() ? XTCP_CLIENT_BUF_SIZE : uip_mss()); if (len != 0) uip_send(uip_appdata, len); } } if (uip_newdata() && uip_len > 0) { if (s->linknum != -1) { if (!uip_udpconnection() && s->s.ack_recv_mode) { uip_stop(); } xtcpd_service_clients_until_ready(s->linknum, xtcp_links, xtcp_num); xtcpd_recv(xtcp_links, s->linknum, xtcp_num, s, uip_appdata, uip_datalen()); } } else if (uip_aborted()) { xtcpd_event(XTCP_ABORTED, s); return; } else if (uip_timedout()) { xtcpd_event(XTCP_TIMED_OUT, s); return; } if (uip_rexmit()) { int len; if (s->linknum != -1) { xtcpd_service_clients_until_ready(s->linknum, xtcp_links, xtcp_num); len = xtcpd_send(xtcp_links[s->linknum], XTCP_RESEND_DATA, s, uip_appdata, uip_udpconnection() ? XTCP_CLIENT_BUF_SIZE : uip_mss()); if (len != 0) uip_send(uip_appdata, len); } } if (uip_poll()) { uip_xtcpd_handle_poll(s); } if (uip_closed()) { if (!s->s.closed) { s->s.closed = 1; xtcpd_event(XTCP_CLOSED, s); } return; } }