Implementation of TCP/IP Protocol Stack on TI C6000DSP
[Copy link]
Development of network applications
If programmers are familiar with the use of SOCKET on the Windows platform, they can also easily develop network applications on the DSP platform, and they don't even need to understand the hardware structure, because the function names and functions of the NDK API and Windows SOCKET API are very similar. The following program uses the DHCP protocol to dynamically obtain IP and the UDP protocol to transmit data, as follows:
//Network initialization
NC_SystemOpen();
hCfg = CfgNew();
CfgAddEntry( hCfg,CFGTAG_SYSINFO,CFGITEM_DHCP_HOS
TNAME,0,strlen(HostName),(UINT8 *)HostName,0);
……
//Configure DHCP protocol to dynamically obtain IP
CI_SERVICE_DHCPC dhcpc;
bzero(&dhcpc, sizeof(dhcpc));
dhcpc.cisargs.Mode = CIS_FLG_IFIDXVALID;
dhcpc.cisargs.IfIdx = 1;
dhcpc.cisargs.pCbSrv = &ServiceReport;
CfgAddEntry(hCfg,CFGTAG_SERVICE,CFGITEM_SERVICE_D
HCPCLIENT,0,sizeof(dhcpc),(UINT8 *)&dhcpc,0);
……
//Configure SOCKET buffer size
rc = 8704;
CfgAddEntry(hCfg,CFGTAG_IP,CFGITEM_IP_SOCKBUFMAX,
CFG_ADDMODE_UNIQUE,sizeof(uint),(UINT8 *)&rc,0);
//Start network service
do
{rc = NC_NetStart(hCfg,NetworkOpen,NetworkClose,NetworkIPA
ddr);
} while(rc > 0);
……
//Configure application layer protocol, this program uses UDP
SOCKET s;
struct sockaddr_in sin1;
s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(bind(s,(PSA) &sin1, sizeof(sin1)) < 0)
|