/** * This function must be called before any of the * stack or its component routines be used. * * Side Affect: Stack and its componentns are initialized */ void StackInit(void) { smStack = SM_STACK_IDLE; #if defined(STACK_USE_IP_GLEANING) || defined(STACK_USE_DHCP) /* * If DHCP or IP Gleaning is enabled, * startup in Config Mode. */ stackFlags.bits.bInConfigMode = TRUE; #endif MACInit(); ARPInit(); #if defined(STACK_USE_UDP) UDPInit(); #endif #if defined(STACK_USE_TCP) TCPInit(); #endif //MODIFIED DHCP BEGIN #if defined(STACK_USE_DHCP) if(!STACK_IS_DHCP_ENABLED) { DHCPDisable(); } #endif //MODIFIED DHCP END }
/** * This function must be called before any of the * stack or its component routines be used. * * Side Affect: Stack and its componentns are initialized */ void StackInit(void) { smStack = SM_STACK_IDLE; #if defined(STACK_USE_IP_GLEANING) || defined(STACK_USE_DHCP) /* * If DHCP or IP Gleaning is enabled, * startup in Config Mode. */ stackFlags.bits.bInConfigMode = TRUE; #endif MACInit(); ARPInit(); #if defined(STACK_USE_UDP) UDPInit(); #endif #if defined(STACK_USE_TCP) TCPInit(); #endif }
int main(int ac, char *av[]) { char rpath[MAX_NAME_LEN]; int status, *jstatus; simplequeue_t *outputQ, *workQ, *qtoa; pthread_t IGMP_broadcast_thread; // create separate thread for broadcasting IGMP group query messages pthread_create(&IGMP_broadcast_thread, NULL, IGMPBroadcast, NULL); // setup the program properties setupProgram(ac, av); // creates a PID file under router_name.pid in the current directory status = makePIDFile(rconfig.router_name, rpath); // shutdown the router on receiving SIGUSR1 or SIGUSR2 redefineSignalHandler(SIGUSR1, shutdownRouter); redefineSignalHandler(SIGUSR2, shutdownRouter); outputQ = createSimpleQueue("outputQueue", INFINITE_Q_SIZE, 0, 1); workQ = createSimpleQueue("work Queue", INFINITE_Q_SIZE, 0, 1); GNETInit(&(rconfig.ghandler), rconfig.config_dir, rconfig.router_name, outputQ); ARPInit(); IPInit(); classifier = createClassifier(); filter = createFilter(classifier, 0); pcore = createPacketCore(rconfig.router_name, outputQ, workQ); // add a default Queue.. the createClassifier has already added a rule with "default" tag // char *qname, char *dqisc, double qweight, double delay_us, int nslots); addPktCoreQueue(pcore, "default", "taildrop", 1.0, 2.0, 0); rconfig.scheduler = PktCoreSchedulerInit(pcore); rconfig.worker = PktCoreWorkerInit(pcore); infoInit(rconfig.config_dir, rconfig.router_name); addTarget("Output Queue", outputQ); qtoa = getCoreQueue(pcore, "default"); if (qtoa != NULL) addTarget("Default Queue", qtoa); else printf("Error .. found null queue for default\n"); // start the CLI.. CLIInit(&(rconfig)); wait4thread(rconfig.scheduler); wait4thread(rconfig.worker); wait4thread(rconfig.ghandler); wait4thread(IGMP_broadcast_thread); }
void EthernetInit(void) { // Initialize hardware InitBoard(); // Initialize stack-related hardware components that may be // required by the UART configuration routines TickInit(); // Initialize Stack and application related NV variables into AppConfig. InitAppConfig(); // Seed the LFSRRand() function. LFSRSeedRand(GenerateRandomDWORD()); // Initialize the MAC library. MACInit(); // Initialize the ARP library. ARPInit(); // Initialize UDP. UDPInit(); // Open up a socket for our UDP server. localServerSocket = UDPOpenEx(NULL, UDP_OPEN_SERVER, UDP_SERVER_PORT, UDP_SERVER_PORT); if (localServerSocket == INVALID_UDP_SOCKET) { FATAL_ERROR(); } // Open up a socket for our UDP client. remoteServerSocket = UDPOpenEx(NULL, UDP_OPEN_IP_ADDRESS, UDP_CLIENT_PORT, UDP_CLIENT_PORT); if (remoteServerSocket == INVALID_UDP_SOCKET) { FATAL_ERROR(); } }
/********************************************************************* * Function: void StackInit(void) * * PreCondition: None * * Input: None * * Output: Stack and its componets are initialized * * Side Effects: None * * Note: This function must be called before any of the * stack or its component routines are used. * ********************************************************************/ void StackInit(void) { smStack = SM_STACK_IDLE; #if defined(STACK_USE_IP_GLEANING) || defined(STACK_USE_DHCP_CLIENT) /* * If DHCP or IP Gleaning is enabled, * startup in Config Mode. */ AppConfig.Flags.bInConfigMode = TRUE; #endif // Seed the LFSRRand() function LFSRSeedRand(GenerateRandomDWORD()); MACInit(); #if defined(WF_CS_TRIS) && defined(STACK_USE_EZ_CONFIG) && !defined(__18CXX) WFEasyConfigInit(); #endif ARPInit(); #if defined(STACK_USE_UDP) UDPInit(); #endif #if defined(STACK_USE_TCP) TCPInit(); #endif #if defined(STACK_USE_BERKELEY_API) BerkeleySocketInit(); #endif #if defined(STACK_USE_HTTP2_SERVER) HTTPInit(); #endif #if defined(STACK_USE_RSA) RSAInit(); #endif #if defined(STACK_USE_SSL) SSLInit(); #endif #if defined(STACK_USE_FTP_SERVER) && defined(STACK_USE_MPFS2) FTPInit(); #endif #if defined(STACK_USE_SNMP_SERVER) SNMPInit(); #endif #if defined(STACK_USE_DHCP_CLIENT) DHCPInit(0); if(!AppConfig.Flags.bIsDHCPEnabled) { DHCPDisable(0); } #endif #if defined(STACK_USE_AUTO_IP) AutoIPInit(0); #endif #if defined(STACK_USE_DYNAMICDNS_CLIENT) DDNSInit(); #endif #if defined(STACK_USE_RANDOM) RandomInit(); #endif }
/********************************************************************* * Function: void StackInit(void) * * PreCondition: None * * Input: None * * Output: Stack and its componets are initialized * * Side Effects: None * * Note: This function must be called before any of the * stack or its component routines are used. * ********************************************************************/ void StackInit(void) { smStack = SM_STACK_IDLE; #if defined(STACK_USE_IP_GLEANING) || defined(STACK_USE_DHCP_CLIENT) /* * If DHCP or IP Gleaning is enabled, * startup in Config Mode. */ AppConfig.Flags.bInConfigMode = TRUE; #endif // Seed the rand() function srand(GenerateRandomDWORD()); MACInit(); #if defined( ZG_CS_TRIS ) #if defined(ZG_CONFIG_LINKMGRII) ZGLibInitialize(); ZGLinkMgrInit(); #endif #endif ARPInit(); #if defined(STACK_USE_UDP) UDPInit(); #endif #if defined(STACK_USE_TCP) TCPInit(); #endif #if defined(STACK_USE_BERKELEY_API) BerkeleySocketInit(); #endif #if defined(STACK_USE_HTTP_SERVER) || defined(STACK_USE_HTTP2_SERVER) HTTPInit(); #endif #if defined(STACK_USE_RSA) RSAInit(); #endif #if defined(STACK_USE_SSL) SSLInit(); #endif #if defined(STACK_USE_FTP_SERVER) && defined(STACK_USE_MPFS) FTPInit(); #endif #if defined(STACK_USE_SNMP_SERVER) SNMPInit(); #endif #if defined(STACK_USE_DHCP_CLIENT) DHCPInit(0); if(!AppConfig.Flags.bIsDHCPEnabled) { DHCPDisable(0); } #endif #if defined(STACK_USE_DYNAMICDNS_CLIENT) DDNSInit(); #endif }
/********************************************************************* * Function: void StackInit(void) * * PreCondition: None * * Input: None * * Output: Stack and its componets are initialized * * Side Effects: None * * Note: This function must be called before any of the * stack or its component routines are used. * ********************************************************************/ void StackInit(void) { static BOOL once = FALSE; smStack = SM_STACK_IDLE; #if defined(STACK_USE_IP_GLEANING) || defined(STACK_USE_DHCP_CLIENT) /* * If DHCP or IP Gleaning is enabled, * startup in Config Mode. */ AppConfig.Flags.bInConfigMode = TRUE; #endif #if defined (WF_CS_TRIS) && defined (STACK_USE_DHCP_CLIENT) g_DhcpRenew = FALSE; g_DhcpRetryTimer = 0; #endif if (!once) { // Seed the LFSRRand() function LFSRSeedRand(GenerateRandomDWORD()); once = TRUE; } MACInit(); #if defined (WF_AGGRESSIVE_PS) && defined (WF_CS_TRIS) WFEnableAggressivePowerSave(); #endif #if defined(WF_CS_TRIS) && defined(STACK_USE_EZ_CONFIG) && !defined(__18CXX) WFEasyConfigInit(); #endif ARPInit(); #if defined(STACK_USE_UDP) UDPInit(); #endif #if defined(STACK_USE_TCP) TCPInit(); #endif #if defined(STACK_USE_BERKELEY_API) BerkeleySocketInit(); #endif #if defined(STACK_USE_HTTP2_SERVER) HTTPInit(); #endif #if defined(STACK_USE_RSA) RSAInit(); #endif #if defined(STACK_USE_SSL) SSLInit(); #endif #if defined(STACK_USE_FTP_SERVER) && defined(STACK_USE_MPFS2) FTPInit(); #endif #if defined(STACK_USE_SNMP_SERVER) SNMPInit(); #endif #if defined(STACK_USE_DHCP_CLIENT) DHCPInit(0); if(!AppConfig.Flags.bIsDHCPEnabled) { DHCPDisable(0); } #endif #if defined(STACK_USE_AUTO_IP) AutoIPInit(0); #endif #if defined(STACK_USE_DYNAMICDNS_CLIENT) DDNSInit(); #endif #if defined(STACK_USE_RANDOM) RandomInit(); #endif #if defined(STACK_USE_CCS_SMTP) SMTPInit(); #endif #if defined(STACK_USE_CCS_SNTP_CLIENT) NTPInit(); #endif #if defined(STACK_USE_CCS_GRATUITOUS_ARP) GratArpInit(); #endif #if defined(STACK_USE_CCS_HTTP1_SERVER) || defined(STACK_USE_CCS_HTTP2_SERVER) HTTPInit(); #endif #if defined(STACK_USE_CCS_TFTP_SERVER) TFTPSInit(); #endif }
/********************************************************************* * Function: void StackInit(void) * * PreCondition: None * * Input: None * * Output: Stack and its componets are initialized * * Side Effects: None * * Note: This function must be called before any of the * stack or its component routines are used. * ********************************************************************/ void StackInit(void) { static bool once = false; smStack = SM_STACK_IDLE; #if defined(STACK_USE_IP_GLEANING) || defined(STACK_USE_DHCP_CLIENT) /* * If DHCP or IP Gleaning is enabled, * startup in Config Mode. */ AppConfig.Flags.bInConfigMode = true; #endif #if defined (WF_CS_TRIS) && defined (STACK_USE_DHCP_CLIENT) g_DhcpRenew = false; g_DhcpRetryTimer = 0; #endif if (!once) { // Seed the LFSRRand() function LFSRSeedRand(GenerateRandomDWORD()); once = true; } MACInit(); #if defined(WF_CS_TRIS) && defined(STACK_USE_EZ_CONFIG) && !defined(__XC8) WFEasyConfigInit(); #endif ARPInit(); #if defined(STACK_USE_ANNOUNCE) AnnounceInit(); #endif #if defined(STACK_USE_UDP) UDPInit(); #endif #if defined(STACK_USE_TCP) TCPInit(); #endif #if defined(STACK_USE_BERKELEY_API) BerkeleySocketInit(); #endif #if defined(STACK_USE_HTTP2_SERVER) HTTPInit(); #endif #if defined(STACK_USE_RSA) RSAInit(); #endif #if defined(STACK_USE_SSL) SSLInit(); #endif #if defined(STACK_USE_FTP_SERVER) && defined(STACK_USE_MPFS2) FTPInit(); #endif #if defined(STACK_USE_DHCP_CLIENT) DHCPInit(0); if(!AppConfig.Flags.bIsDHCPEnabled) { DHCPDisable(0); } #endif #if defined(STACK_USE_AUTO_IP) AutoIPInit(0); #endif #if defined(STACK_USE_DYNAMICDNS_CLIENT) DDNSInit(); #endif #if defined(STACK_USE_RANDOM) RandomInit(); #endif #if defined(STACK_USE_NBNS) NBNSInit(); #endif }
int main(int ac, char *av[]) { char rpath[MAX_NAME_LEN]; int status, *jstatus; simplequeue_t *outputQ, *workQ, *qtoa; // setup the program properties setupProgram(ac, av); // creates a PID file under router_name.pid in the current directory status = makePIDFile(rconfig.router_name, rpath); // shutdown the router on receiving SIGUSR1 or SIGUSR2 redefineSignalHandler(SIGUSR1, shutdownRouter); redefineSignalHandler(SIGUSR2, shutdownRouter); outputQ = createSimpleQueue("outputQueue", INFINITE_Q_SIZE, 0, 1); workQ = createSimpleQueue("work Queue", INFINITE_Q_SIZE, 0, 1); GNETInit(&(rconfig.ghandler), rconfig.config_dir, rconfig.router_name, outputQ); ARPInit(); IPInit(); init_ports(); init_tcp(); /*uint32_t dest_ip = 12319800; uint16_t dest_port = 123; uint16_t src_port = 456; char *data = "Hello"; int len = 6; send_udp(dest_ip,dest_port,src_port,data,len);*/ /* *Test udp_recv * */ /*open_port(1, UDP_PROTOCOL); gpacket_t *packet = (gpacket_t *) malloc(sizeof(gpacket_t)); ip_packet_t *ipPacket = (ip_packet_t *)(packet->data.data); ipPacket->ip_src = {0x1,0x1,0x1,0x1}; ipPacket->ip_dst = {0x2,0x2,0x2,0x2}; ipPacket->ip_cksum = 65535; ipPacket->ip_pkt_len = ipPacket->ip_hdr_len; udphdr_t *udpHeader = (udphdr_t *)((uchar *)ipPacket + ipPacket->ip_hdr_len*4); udpHeader->source = 0; // ports udpHeader->dest = 1; udpHeader->len = 0; // length of data in octets udpHeader->check = 65535; udp_recv(packet); free(packet); free(ipPacket); free(udpHeader);*/ /* * * * End test udp_recv * */ printf("dis router"); classifier = createClassifier(); filter = createFilter(classifier, 0); pcore = createPacketCore(rconfig.router_name, outputQ, workQ); // add a default Queue.. the createClassifier has already added a rule with "default" tag // char *qname, char *dqisc, double qweight, double delay_us, int nslots); addPktCoreQueue(pcore, "default", "taildrop", 1.0, 2.0, 0); rconfig.scheduler = PktCoreSchedulerInit(pcore); rconfig.worker = PktCoreWorkerInit(pcore); infoInit(rconfig.config_dir, rconfig.router_name); addTarget("Output Queue", outputQ); qtoa = getCoreQueue(pcore, "default"); if (qtoa != NULL) addTarget("Default Queue", qtoa); else printf("Error .. found null queue for default\n"); // start the CLI.. CLIInit(&(rconfig)); wait4thread(rconfig.scheduler); wait4thread(rconfig.worker); wait4thread(rconfig.ghandler); }