Miscellaneous

Functions

uint32_t net_set_gateway (char *ip, char *sub_mask)
 Configure a gateway. More...
 
char * get_netlib_ver (char *buffer)
 Retrieve netlib revision string. More...
 
char * net_allocate_aligned_buffer (int32_t size)
 Allocate a data buffer, aligned to the processors cache line size. More...
 
addr_typeget_address_offset (uint16_t dev_nr)
 Get current offset of MAC + IP address structure. More...
 
uint32_t get_ip_address (uint16_t dev_nr)
 Get configured IP address. More...
 
uint32_t set_ip_address (uint16_t dev_nr, char *addr_str)
 Set IP address. More...
 
uint32_t get_mac_address (uint16_t dev_nr, uint16_t *dest)
 Get MAC address. More...
 
void net_print_stat (uint16_t dev_nr, tpOutputFunc pLog)
 Print statistic TCP stack information. More...
 

Variables

const char netlib_ver []
 

Detailed Description

Function Documentation

uint32_t net_set_gateway ( char *  ip,
char *  sub_mask 
)
Parameters
ip- Gateway IP address
sub_mask- Subnet Mask
Returns
always TRUE (1)

This function is only required in manually administered networks, a DHCP server automatically provides this information. The subnet mask defines the address range of the local subnet, e.g. "255.255.255.0". This mask is bit-wise ANDed with the destination IP address any time a message is sent. If the result is not equal to zero, the destination is outside the local subnet, and the data will be transmitted via the specified gateway.

Library:
net.lib
Prototype:
net.h
net_set_gateway ("192.168.168.1", "255.255.255.0");
char * get_netlib_ver ( char *  buffer)
Parameters
buffer- buffer to hold string
Returns
pointer to buffer

Returns the netlib revision string. The buffer must be large enough to hold up to 6 characters including the terminating zero.

Library:
net.lib
Prototype:
net.h
char version[6]; // for netlib version string
printf ("netlib revision: %s\r\n", get_netlib_ver (version));
Note
This function is deprecated. Use char array netlib_ver[] instead
See also
netlib_ver[]
int8_t * net_allocate_aligned_buffer ( int32_t  size)
Note
C6x only
Parameters
sizeto allocate
Returns
  • NULL out of memory
  • >0 success

Allocate a cache-line aligned buffer from the heap. Useful for dynamic buffers that must be DMA accessible while the cache is activated.

Library:
net.lib
Prototype:
net.h
addr_type* get_address_offset ( uint16_t  dev_nr)
Parameters
dev_nr- adapter number ( always 0 for DSK)
Returns
pointer to address structure
uint32_t get_ip_address ( uint16_t  dev_nr)
Parameters
dev_nr- adapter number ( always 0 for DSK)
Returns
assigned IP address

Obtain configured IP address. The returned address is in network-byteorder. For readable printout it must be converted with function inet_ntoa().

Library:
net.lib
Prototype:
net.h
char buffer[20]; // small buffer for ip-address conversion
ip = get_ip_address (0);
printf ("demo running on address %s\r\n", inet_ntoa (ip, buffer));
Examples:
Blocksend.c, BoardSpecific.c, DHCPTest.c, DNSTest.c, Echo.c, NetTest.c, Ping2.c, Send.c, and SMTP.c.
uint32_t set_ip_address ( uint16_t  dev_nr,
char *  addr_str 
)
Parameters
dev_nr- adapter number ( always 0 for DSK)
addr_str- new IP address
Returns
assigned IP address

Change own IP address on demand. If address "0.0.0.0" is specified, the own IP address is cleared and re-assigned with the first valid received IP packet.

Library:
net.lib
Prototype:
net.h
set_ip_address(0,"192.168.168.123");
Examples:
BoardSpecific.c.
uint32_t get_mac_address ( uint16_t  dev_nr,
uint16_t dest 
)
Parameters
dev_nr- adapter number ( always 0 for DSK)
dest- destination buffer to hold MAC address string
Returns
MAC address

Obtain own MAC address. Destination buffer must be large enough to hold up to 6 characters.

Library:
net.lib
Prototype:
net.h
uint16_t mac[3];
printf ("\r\n DSP MAC address: \r\n");
printf ("%02x-%02x-%02x-%02x-%02x-%02x\r\n",
mac[0] & 0xff, mac[0] >> 8 , mac[1] & 0xff,
mac[1] >> 8 , mac[2] & 0xff, mac[2] >> 8);
Examples:
BoardSpecific.c.
void net_print_stat ( uint16_t  dev_nr,
tpOutputFunc  pLog 
)
Parameters
dev_nr- device number
pLog- pointer to printf function
Examples:
BoardSpecific.c.

Variable Documentation

netlib_ver[]

netlib revision string

Use with printf:

CPrintf (" | netlib revision: %s |\r\n", netlib_ver );
See also
get_netlib_ver()