Network Component  
MDK Middleware for IPv4 and IPv6 Networking
 
Loading...
Searching...
No Matches
Data Format

Structures of the Network Component. More...

Data Structures

struct  NET_ADDR
 Network Address IPv4/IPv6 capable. More...
 
struct  NET_ADDR4
 Network Address IPv4 only. More...
 

Description

Structures of the Network Component.


Data Structure Documentation

◆ NET_ADDR

struct NET_ADDR

Network Address IPv4/IPv6 capable.

NET_ADDR allows to store IPv4 and IPv6 addresses along with the Internet socket port number. addr_type indicates the IP address format for addr. addr contains the IP address in binary format, whereby the MSB is stored first.

Example:

IP Address (ASCII) addr_type addr
192.168.0.1 NET_ADDR_IP4 0xC0 0xA8 0x00 0x01
fe80:0000:0000:0000:1c30:6cff:fea2:455e NET_ADDR_IP6 0xFE 0x80 0x00 0x00 0x00 0x00 0x00 0x1C 0x30 0x6C 0xFF 0xFE 0xA2 0x45 0x5E
fe80::1c30:6cff:fea2:455e NET_ADDR_IP6 0xFE 0x80 0x00 0x00 0x00 0x00 0x00 0x1C 0x30 0x6C 0xFF 0xFE 0xA2 0x45 0x5E

The functions netIP_ntoa and netIP_aton can be used to convert IP addresses from ASCII to binary and vice versa.

Data Fields
uint8_t addr[NET_ADDR_IP6_LEN] IPv4 or IPv6 address (array 16 bytes, MSB first)
int16_t addr_type IP address type: NET_ADDR_IP4 or NET_ADDR_IP6.
uint16_t port Internet socket port number.

◆ NET_ADDR4

struct NET_ADDR4

Network Address IPv4 only.

NET_ADDR4 allows to store only IPv4 addresses along with the Internet socket port number. Use this struct if you only use IPv4 to save memory. addr_type indicates the IP address format for addr. addr contains the IP address in binary format, whereby the MSB is stored first. Since only IPv4 addresses can be stored, the value for addr_type should be set to NET_ADDR_IP4.

Data Fields
uint8_t addr[NET_ADDR_IP4_LEN] IPv4 address (array 4 bytes, MSB first)
int16_t addr_type IP address type: NET_ADDR_IP4.
uint16_t port Internet socket port number.