uIP conversion functions
[The uIP TCP/IP stack]


Detailed Description

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


Defines

#define uip_ipaddr(addr, addr0, addr1, addr2, addr3)
 Construct an IP address from four bytes.
#define uip_ip6addr(addr, addr0, addr1, addr2, addr3, addr4, addr5, addr6, addr7)
 Construct an IPv6 address from eight 16-bit words.
#define uip_ipaddr_copy(dest, src)
 Copy an IP address to another IP address.
#define uip_ipaddr_cmp(addr1, addr2)
 Compare two IP addresses.
#define uip_ipaddr_maskcmp(addr1, addr2, mask)
 Compare two IP addresses with netmasks.
#define uip_ipaddr_mask(dest, src, mask)
 Mask out the network part of an IP address.
#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 HTONS(n)
 Convert 16-bit quantity from host byte order to network byte order.
#define ntohs   htons

Functions

u16_t htons (u16_t val)
 Convert 16-bit quantity from host byte order to network byte order.


Define Documentation

#define HTONS  ) 
 

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:
dhcpc.c, hello-world.c, resolv.c, smtp.c, and telnetd.c.

Definition at line 1070 of file uip.h.

Referenced by hello_world_init(), htons(), httpd_init(), resolv_appcall(), resolv_conf(), smtp_send(), uip_arp_arpin(), and uip_process().

#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.

Definition at line 852 of file uip.h.

#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:
addr A pointer to a uip_ipaddr_t variable that will be filled in with the IP address.
addr0 The first octet of the IP address.
addr1 The second octet of the IP address.
addr2 The third octet of the IP address.
addr3 The forth octet of the IP address.
Examples:
dhcpc.c, example-mainloop-with-arp.c, and example-mainloop-without-arp.c.

Definition at line 840 of file uip.h.

#define uip_ipaddr1 addr   ) 
 

Pick the first octet of an IP address.

Picks out the first octet of an IP address.

Example:

 uip_ipaddr_t ipaddr;
 u8_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.

Examples:
dhcpc.c.

Definition at line 995 of file uip.h.

#define uip_ipaddr2 addr   ) 
 

Pick the second octet of an IP address.

Picks out the second octet of an IP address.

Example:

 uip_ipaddr_t ipaddr;
 u8_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.

Examples:
dhcpc.c.

Definition at line 1015 of file uip.h.

#define uip_ipaddr3 addr   ) 
 

Pick the third octet of an IP address.

Picks out the third octet of an IP address.

Example:

 uip_ipaddr_t ipaddr;
 u8_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.

Examples:
dhcpc.c.

Definition at line 1035 of file uip.h.

#define uip_ipaddr4 addr   ) 
 

Pick the fourth octet of an IP address.

Picks out the fourth octet of an IP address.

Example:

 uip_ipaddr_t ipaddr;
 u8_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.

Examples:
dhcpc.c.

Definition at line 1055 of file uip.h.

#define uip_ipaddr_cmp addr1,
addr2   ) 
 

Compare two IP addresses.

Compares two IP addresses.

Example:

 uip_ipaddr_t ipaddr1, ipaddr2;

 uip_ipaddr(&ipaddr1, 192,16,1,2);
 if(uip_ipaddr_cmp(&ipaddr2, &ipaddr1)) {
    printf("They are the same");
 }

Parameters:
addr1 The first IP address.
addr2 The second IP address.

Definition at line 911 of file uip.h.

Referenced by uip_arp_arpin(), uip_arp_out(), and uip_process().

#define uip_ipaddr_copy dest,
src   ) 
 

Copy an IP address to another IP address.

Copies an IP address from one place to another.

Example:

 uip_ipaddr_t ipaddr1, ipaddr2;

 uip_ipaddr(&ipaddr1, 192,16,1,2);
 uip_ipaddr_copy(&ipaddr2, &ipaddr1);

Parameters:
dest The destination for the copy.
src The source from where to copy.
Examples:
smtp.c.

Definition at line 882 of file uip.h.

Referenced by smtp_configure(), uip_arp_out(), and uip_process().

#define uip_ipaddr_mask dest,
src,
mask   ) 
 

Mask out the network part of an IP address.

Masks out the network part of an IP address, given the address and the netmask.

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:
dest Where the result is to be placed.
src The IP address.
mask The netmask.

Definition at line 972 of file uip.h.

#define uip_ipaddr_maskcmp addr1,
addr2,
mask   ) 
 

Compare two IP addresses with netmasks.

Compares two IP addresses with netmasks. The masks are used to mask out the bits that are to be compared.

Example:

 uip_ipaddr_t ipaddr1, ipaddr2, mask;

 uip_ipaddr(&mask, 255,255,255,0);
 uip_ipaddr(&ipaddr1, 192,16,1,2);
 uip_ipaddr(&ipaddr2, 192,16,1,3);
 if(uip_ipaddr_maskcmp(&ipaddr1, &ipaddr2, &mask)) {
    printf("They are the same");
 }

Parameters:
addr1 The first IP address.
addr2 The second IP address.
mask The netmask.

Definition at line 941 of file uip.h.

Referenced by uip_arp_out().


Function Documentation

u16_t htons u16_t  val  ) 
 

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

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

Examples:
example-mainloop-with-arp.c, resolv.c, and webclient.c.

Definition at line 1882 of file uip.c.

References HTONS.

Referenced by uip_chksum(), uip_connect(), uip_ipchksum(), uip_udp_new(), and webclient_get().


Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by  doxygen 1.4.6