weAut_01 / weAutSys    R 2.2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Defines
uIP conversion functions
+ + uIP -- Adam Dunkels' TCP/IP stack + +

Overview

These functions can be used for converting between different data formats used by uIP.

Defines

#define HTONS(n)
 Convert 16-bit quantity from host byte order to network byte order.
#define uip_ip6addr(addr, addr0, addr1, addr2, addr3, addr4, addr5, addr6, addr7)
 Construct an IPv6 address from eight 16-bit words.
#define uip_ipaddr(addr, addr0, addr1, addr2, addr3)
 Construct an IP address from four bytes.
#define uip_ipaddr1(addr)
 Pick the first octet of an IP address.
#define uip_ipaddr2(addr)
 Pick the second octet of an IP address.
#define uip_ipaddr3(addr)
 Pick the third octet of an IP address.
#define uip_ipaddr4(addr)
 Pick the fourth octet of an IP address.
#define uip_ipaddr_cmp(addr1, addr2)
 Compare two IP addresses.
#define uip_ipaddr_copy(dest, src)
 Copy an IP address to another IP address.
#define uip_ipaddr_mask(dest, src, mask)
 Mask out the network part of an IP address.
#define uip_ipaddr_maskcmp(addr1, addr2, mask)
 Compare two IP addresses with netmasks.

Define Documentation

#define uip_ipaddr (   addr,
  addr0,
  addr1,
  addr2,
  addr3 
)

Construct an IP address from four bytes.

This function constructs an IP address of the type that uIP handles internally from four bytes. The function is handy for specifying IP addresses to use with e.g. the uip_connect() function.

Example:

 uip_ipaddr_t ipaddr;
 struct uip_conn *c;
 
 uip_ipaddr(&ipaddr, 192,168,1,2);
 c = uip_connect(&ipaddr, HTONS(80));
Parameters:
addrA pointer to a uip_ipaddr_t variable that will be filled in with the IP address.
addr0The first octet of the IP address.
addr1The second octet of the IP address.
addr2The third octet of the IP address.
addr3The forth octet of the IP address.
#define uip_ip6addr (   addr,
  addr0,
  addr1,
  addr2,
  addr3,
  addr4,
  addr5,
  addr6,
  addr7 
)

Construct an IPv6 address from eight 16-bit words.

This function constructs an IPv6 address.

#define uip_ipaddr_copy (   dest,
  src 
)

Copy an IP address to another IP address.

This is just a copy of 4 Bytes in the (default) case of IP V4 and 8 bytes in the case of IP V6 from src to dest.

No endianess is changed. The content of a type uip_ipaddr_t variable is considered to be in network byte order.

Example:

 uip_ipaddr_t ipaddr1, ipaddr2;

 uip_ipaddr(&ipaddr1, 192,16,1,2);
 uip_ipaddr_copy(&ipaddr2, &ipaddr1);
Parameters:
destpointer to the destination to copy to
srcpointer to the source where to copy from
#define uip_ipaddr_cmp (   addr1,
  addr2 
)

Compare two IP addresses.

Parameters:
addr1The first IP address.
addr2The second IP address.
#define uip_ipaddr_maskcmp (   addr1,
  addr2,
  mask 
)

Compare two IP addresses with netmasks.

The masks are used to mask out the bits that are to be compared.

Parameters:
addr1The first IP address.
addr2The second IP address.
maskThe netmask.
#define uip_ipaddr_mask (   dest,
  src,
  mask 
)

Mask out the network part of an IP address.

Example:

 uip_ipaddr_t ipaddr1, ipaddr2, netmask;

 uip_ipaddr(&ipaddr1, 192,16,1,2);
 uip_ipaddr(&netmask, 255,255,255,0);
 uip_ipaddr_mask(&ipaddr2, &ipaddr1, &netmask);

In the example above, the variable "ipaddr2" will contain the IP address 192.168.1.0.

Parameters:
destWhere the result is to be placed.
srcThe IP address.
maskThe netmask.
#define uip_ipaddr1 (   addr)

Pick the first octet of an IP address.

Example:

 uip_ipaddr_t ipaddr;
 uint8_t octet;

 uip_ipaddr(&ipaddr, 1,2,3,4);
 octet = uip_ipaddr1(&ipaddr);

In the example above, the variable "octet" will contain the value 1.

#define uip_ipaddr2 (   addr)

Pick the second octet of an IP address.

Example:

 uip_ipaddr_t ipaddr;
 uint8_t octet;

 uip_ipaddr(&ipaddr, 1,2,3,4);
 octet = uip_ipaddr2(&ipaddr);

In the example above, the variable "octet" will contain the value 2.

#define uip_ipaddr3 (   addr)

Pick the third octet of an IP address.

Example:

 uip_ipaddr_t ipaddr;
 uint8_t octet;

 uip_ipaddr(&ipaddr, 1,2,3,4);
 octet = uip_ipaddr3(&ipaddr);

In the example above, the variable "octet" will contain the value 3.

#define uip_ipaddr4 (   addr)

Pick the fourth octet of an IP address.

Example:

 uip_ipaddr_t ipaddr;
 uint8_t octet;

 uip_ipaddr(&ipaddr, 1,2,3,4);
 octet = uip_ipaddr4(&ipaddr);

In the example above, the variable "octet" will contain the value 4.

#define HTONS (   n)

Convert 16-bit quantity from host byte order to network byte order.

This macro is primarily used for converting constants from host byte order to network byte order. For converting variables to network byte order, use the htons() function instead.

Examples:
main.c.