These functions can be used for converting between different data formats used by uIP.
Macros | |
#define | UIP_HTONL(n) (n) |
#define | UIP_HTONS(n) |
Convert 16-bit quantity from host byte order to network byte order. More... | |
#define | uip_ip4addr_cmp(addr1, addr2) |
Compare two IP addresses. More... | |
#define | uip_ip4addr_copy(dest, src) (*(dest) = *(src)) |
#define | uip_ip6addr(addr, addr0, addr1, addr2, addr3, addr4, addr5, addr6, addr7) |
Construct an IPv6 address from eight 16-bit words. More... | |
#define | uip_ip6addr_cmp(addr1, addr2) (memcmp(addr1, addr2, sizeof(uip_ip6addr_t)) == 0) |
#define | uip_ip6addr_copy(dest, src) (*(dest) = *(src)) |
#define | uip_ip6addr_u8(addr, addr0, addr1, addr2, addr3, addr4, addr5, addr6, addr7, addr8, addr9, addr10, addr11, addr12, addr13, addr14, addr15) |
Construct an IPv6 address from sixteen 8-bit words. More... | |
#define | uip_ipaddr(addr, addr0, addr1, addr2, addr3) |
Construct an IP address from four bytes. More... | |
#define | uip_ipaddr1(addr) |
Pick the first octet of an IP address. More... | |
#define | uip_ipaddr2(addr) |
Pick the second octet of an IP address. More... | |
#define | uip_ipaddr3(addr) |
Pick the third octet of an IP address. More... | |
#define | uip_ipaddr4(addr) |
Pick the fourth octet of an IP address. More... | |
#define | uip_ipaddr_cmp(addr1, addr2) uip_ip6addr_cmp(addr1, addr2) |
#define | uip_ipaddr_copy(dest, src) |
Copy an IP address from one place to another. More... | |
#define | uip_ipaddr_mask(dest, src, mask) |
Check if an address is a broadcast address for a network. More... | |
#define | uip_ipaddr_maskcmp(addr1, addr2, mask) |
Compare two IP addresses with netmasks. More... | |
#define | uip_ipaddr_prefixcmp(addr1, addr2, length) (memcmp(addr1, addr2, length>>3) == 0) |
#define | uip_ipaddr_to_quad(a) |
Convert an IP address to four bytes separated by commas. More... | |
#define | uip_ntohl uip_htonl |
#define | uip_ntohs uip_htons |
#define | uiplib_ipaddrconv uiplib_ip6addrconv |
Convert a textual representation of an IP address to a numerical representation. More... | |
Functions | |
CCIF uint32_t | uip_htonl (uint32_t val) |
CCIF uint16_t | uip_htons (uint16_t val) |
Convert a 16-bit quantity from host byte order to network byte order. More... | |
CCIF int | uiplib_ip4addrconv (const char *addrstr, uip_ip4addr_t *addr) |
CCIF int | uiplib_ip6addrconv (const char *addrstr, uip_ip6addr_t *addr) |
Referenced by send_rrep(), and uip_htonl().
#define UIP_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 uip_htons() function instead.
Referenced by cbcmac_calc(), cbcmac_verify(), compress_hdr_hc06(), compress_hdr_hc1(), create_msg(), ctr_mic(), ctr_next_ctr_block(), dhcpc_init(), httpd_init(), ip64_6to4(), ip64_arp_arp_input(), ip64_arp_create_arp_request(), ip64_arp_create_ethhdr(), ip64_dhcpc_init(), ip64_eth_interface_input(), PROCESS_THREAD(), simple_udp_register(), simple_udp_send(), simple_udp_sendto(), simple_udp_sendto_port(), udp_socket_bind(), udp_socket_connect(), udp_socket_sendto(), uip_arp_arpin(), uip_arp_out(), uip_fw_forward(), uip_htons(), uip_process(), uncompress_hdr_hc06(), and uncompress_hdr_hc1().
#define uip_ip4addr_cmp | ( | addr1, | |
addr2 | |||
) |
Compare two IP addresses.
Compares two IP addresses.
Example:
addr1 | The first IP address. |
addr2 | The second IP address. |
Referenced by arp_update(), ip64_4to6(), ip64_6to4(), ip64_addrmap_lookup(), ip64_arp_arp_input(), ip64_arp_check_cache(), ip64_arp_create_ethhdr(), and ip64_arp_timer().
#define uip_ip4addr_copy | ( | dest, | |
src | |||
) | (*(dest) = *(src)) |
#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.
Referenced by create_rpl_dag(), main(), rpl_link_neighbor_callback(), set_global_address(), simple_rpl_init_dag_immediately(), and uncompress_hdr_hc1().
#define uip_ip6addr_cmp | ( | addr1, | |
addr2 | |||
) | (memcmp(addr1, addr2, sizeof(uip_ip6addr_t)) == 0) |
Referenced by ip64_addrmap_lookup().
#define uip_ip6addr_copy | ( | dest, | |
src | |||
) | (*(dest) = *(src)) |
Referenced by ip64_addrmap_create().
#define uip_ip6addr_u8 | ( | addr, | |
addr0, | |||
addr1, | |||
addr2, | |||
addr3, | |||
addr4, | |||
addr5, | |||
addr6, | |||
addr7, | |||
addr8, | |||
addr9, | |||
addr10, | |||
addr11, | |||
addr12, | |||
addr13, | |||
addr14, | |||
addr15 | |||
) |
Construct an IPv6 address from sixteen 8-bit words.
This function constructs an IPv6 address.
#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:
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. |
Referenced by dhcpc_init(), dhcpc_request(), ip64_arp_check_cache(), ip64_arp_create_ethhdr(), ip64_dhcpc_init(), ip64_dhcpc_request(), and ip64_init().
#define uip_ipaddr1 | ( | addr | ) |
Pick the first octet of an IP address.
Picks out the first octet of an IP address.
Example:
In the example above, the variable "octet" will contain the value 1.
#define uip_ipaddr2 | ( | addr | ) |
Pick the second octet of an IP address.
Picks out the second octet of an IP address.
Example:
In the example above, the variable "octet" will contain the value 2.
#define uip_ipaddr3 | ( | addr | ) |
Pick the third octet of an IP address.
Picks out the third octet of an IP address.
Example:
In the example above, the variable "octet" will contain the value 3.
#define uip_ipaddr4 | ( | addr | ) |
Pick the fourth octet of an IP address.
Picks out the fourth octet of an IP address.
Example:
In the example above, the variable "octet" will contain the value 4.
#define uip_ipaddr_cmp | ( | addr1, | |
addr2 | |||
) | uip_ip6addr_cmp(addr1, addr2) |
Referenced by create_dag_callback(), dao_input(), find_entry(), fwc_lookup(), get_dag(), get_pingconn(), handle_incoming_rerr(), handle_incoming_rrep(), handle_incoming_rreq(), output(), rpl_remove_routes_by_nexthop(), uaodv_rt_lookup_any(), uip_arp_arpin(), uip_arp_out(), uip_arp_timer(), uip_arp_update(), uip_ds6_defrt_choose(), uip_ds6_defrt_lookup(), uip_ds6_nbr_lookup(), uip_ds6_route_rm(), uip_fw_forward(), uip_fw_output(), uip_neighbor_add(), and uip_process().
#define uip_ipaddr_copy | ( | dest, | |
src | |||
) |
Copy an IP address from one place to another.
Copies an IP address from one place to another.
Example:
dest | The destination for the copy. |
src | The source from where to copy. |
Referenced by allocate_pingconn(), dao_input(), dio_input(), echo_reply_input(), echo_request_input(), fwc_add(), fwcache_register(), handle_incoming_reg(), handle_incoming_rreq(), input_callback(), ns_input(), ra_input(), rpl_purge_routes(), send_rerr(), send_rrep(), send_rreq(), send_udp_packet(), sendto(), servreg_hack_register(), simple_udp_register(), time_exceeded(), uaodv_bad_dest(), uaodv_request_route_to(), uaodv_rt_add(), udp_socket_connect(), uip_arp_arpin(), uip_arp_out(), uip_arp_update(), uip_ds6_aaddr_add(), uip_ds6_addr_add(), uip_ds6_defrt_add(), uip_ds6_maddr_add(), uip_ds6_nbr_add(), uip_ds6_prefix_add(), uip_ds6_route_add(), uip_ds6_select_src(), uip_icmp6_error_output(), uip_nd6_ns_output(), uip_neighbor_add(), uip_over_mesh_set_net(), uip_process(), and uip_udp_packet_sendto().
#define uip_ipaddr_mask | ( | dest, | |
src, | |||
mask | |||
) |
Check if an address is a broadcast address for a network.
Checks if an address is the broadcast address for a network. The network is defined by an IP address that is on the network and the network's netmask.
addr | The IP address. |
netaddr | The network's IP address. |
netmask | The network's netmask. 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:
In the example above, the variable "ipaddr2" will contain the IP address 192.168.1.0.
dest | Where the result is to be placed. |
src | The IP address. |
mask | The netmask. |
#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:
addr1 | The first IP address. |
addr2 | The second IP address. |
mask | The netmask. |
Referenced by ip64_4to6(), ip64_arp_check_cache(), ip64_arp_create_arp_request(), ip64_arp_create_ethhdr(), recv_data(), uip_arp_out(), and uip_over_mesh_send().
#define uip_ipaddr_to_quad | ( | a | ) |
Convert an IP address to four bytes separated by commas.
Example:
a | A pointer to a uip_ipaddr_t. |
Referenced by handle_incoming_rerr(), handle_incoming_rrep(), handle_incoming_rreq(), httpd_sprint_ip4(), ip64_4to6(), ip64_arp_check_cache(), send_rerr(), send_rrep(), send_rreq(), and uip_over_mesh_send().
#define uip_ntohl uip_htonl |
Referenced by handle_incoming_rerr(), handle_incoming_rrep(), handle_incoming_rreq(), ra_input(), and uaodv_rt_add().
#define uip_ntohs uip_htons |
Referenced by httpd_sprint_ip6(), if(), ip64_4to6(), ip64_6to4(), and ra_input().
#define uiplib_ipaddrconv uiplib_ip6addrconv |
Convert a textual representation of an IP address to a numerical representation.
This function takes a textual representation of an IP address in the form a.b.c.d for IPv4 or a:b:c:d:e:f:g:h for IPv6 and converts it into a numeric IP address representation that can be used by other uIP functions.
addrstr | A pointer to a string containing the IP address in textual form. |
addr | A pointer to a uip_ip4addr_t that will be filled in with the numerical representation of the address. |
0 | If the IP address could not be parsed. |
Non-zero | If the IP address was parsed. |
CCIF uint32_t uip_htonl | ( | uint32_t | val | ) |
References UIP_HTONL.
Referenced by handle_incoming_rerr(), handle_incoming_rrep(), handle_incoming_rreq(), last_known_seqno(), send_rreq(), uaodv_bad_dest(), and uip_icmp6_error_output().
CCIF uint16_t uip_htons | ( | uint16_t | val | ) |
Convert a 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 UIP_HTONS() macro instead.
References UIP_HTONS.
Referenced by appcall(), ip64_4to6(), ip64_6to4(), ip64_addrmap_lookup(), ipv4_checksum(), ipv4_transport_checksum(), ipv6_transport_checksum(), make_tcp_stats(), PROCESS_THREAD(), receiver(), send_msg(), tcp_socket_connect(), tcp_socket_listen(), tcp_socket_unlisten(), uip_chksum(), uip_ipchksum(), upper_layer_chksum(), and websocket_http_client_get().
CCIF int uiplib_ip4addrconv | ( | const char * | addrstr, |
uip_ip4addr_t * | addr | ||
) |
References c, i, j, and uip_ip4addr_t::u8.
Referenced by start_get(), start_request(), and websocket_http_client_get().
CCIF int uiplib_ip6addrconv | ( | const char * | addrstr, |
uip_ip6addr_t * | addr | ||
) |
References c, len, PRINTF, and uip_ip6addr_t::u8.
Referenced by start_get(), start_request(), and websocket_http_client_get().