Visible to Intel only — GUID: mwh1416946959078
Ixiasoft
Visible to Intel only — GUID: mwh1416946959078
Ixiasoft
11.4.4. Calling the Sockets Interface
To create a new task that talks to the IP stack using the sockets API, you must use the function TK_NEWTASK(). The TK_NEWTASK() function is part of the NicheStack TCP/IP Stack operating system (OS) porting layer. TK_NEWTASK() calls the MicroC/OS-II OSTaskCreate() function to create a thread, and performs some other actions specific to the NicheStack TCP/IP Stack.
The prototype for TK_NEWTASK() is:
int TK_NEWTASK(struct inet_task_info* nettask);An Implementation of get_ip_addr()
#include
#include "includes.h" #include "ipport.h" #include "tcpport.h" int get_ip_addr(alt_iniche_dev* p_dev, ip_addr* ipaddr, ip_addr* netmask, ip_addr* gw, int* use_dhcp) { int ret_code = -1; /* * The name here is the device name defined in system.h */ if (!strcmp(p_dev->name, "/dev/" INICHE_DEFAULT_IF)) { /* The following is the default IP address if DHCP fails, or the static IP address if DHCP_CLIENT is undefined. */ IP4_ADDR(&ipaddr, 10, 1, 1 ,3); /* Assign the Default Gateway Address */ IP4_ADDR(&gw, 10, 1, 1, 254); /* Assign the Netmask */ IP4_ADDR(&netmask, 255, 255, 255, 0); #ifdef DHCP_CLIENT *use_dhcp = 1; #else *use_dhcp = 0; #endif /* DHCP_CLIENT */ ret_code = ERR_OK; } return ret_code; }
The prototype is defined in <iniche path>/src/nios2/osport.h. You can include this header file as follows:
#include "osport.h"
You can find other details of the OS porting layer in the osport.c file in the NicheStack TCP/IP Stack component directory, <iniche path>/src/nios2/.