UHCP

Provides UHCP (micro host configuration protocol)

enum uhcp_type_t
UHCP_REQ
packet is a request packet
UHCP_PUSH
packet is a push / answer packet
unsigned uhcp_iface_t

typedef for interface handle

void uhcp_handle_udp(uint8_t * buf, msp430_types.h::size_t len, uint8_t * src, uint16_t port, uhcp.h::uhcp_iface_t iface)

handle incoming UDP packet

This function should be called by UHCP server/client network code for every incoming UDP packet destined to UCHP_PORT.

Parameters

buf:buffer containing UDP packet
len:length of buf
src:ptr to IPv6 source address
port:source port of packet
iface:interface number of incoming packet

void uhcp_handle_req(uhcp_req_t * req, uint8_t * src, uint16_t port, uhcp.h::uhcp_iface_t iface)

handle incoming UHCP request packet

This function will be called by uhcp.h::uhcp_handle_udp() for incoming request packet.

void uhcp_handle_push(uhcp_push_t * req, uint8_t * src, uint16_t port, uhcp.h::uhcp_iface_t iface)

handle incoming UHCP push packet

This function will be called by uhcp.h::uhcp_handle_udp() for incoming push packet.

void uhcp_handle_prefix(uint8_t * prefix, uint8_t prefix_len, uint16_t lifetime, uint8_t * src, uhcp.h::uhcp_iface_t iface)

handle incoming prefix (as parsed from push packet)

Supposed to be implemented by UHCP client implementations.

The function might be called with an already configured prefix. In that case, the lifetime MUST be updated.

If the function is called with a different prefix than before, the old prefix MUST be considered obsolete.

Parameters

prefix:ptr to assigned prefix
prefix_len:length of assigned prefix
lifetime:lifetime of prefix
src:ptr to IPv6 source address
iface:number of interface the packet came in

void uhcp_hdr_set(uhcp_hdr_t * hdr, uhcp.h::uhcp_type_t type)

function to set constant values in UHCP header

int udp_sendto(uint8_t * buf, msp430_types.h::size_t len, uint8_t * dst, uint16_t dst_port, uhcp.h::uhcp_iface_t dst_iface)

UDP send function used by UHCP client / server.

Supposed to be implemented by UHCP clients.

Parameters

buf:buffer to send
len:length of buf
dst:ptr to IPv6 destination address
dst_port:destination port
dst_iface:interface number of destination interface

UHCP_MAGIC

UHCP magic number.

1
(0x55484350) /* "UHCP" in hex */
UHCP_VER

UHCP version of this header.

1
(0)
UHCP_PORT

UHCP port number.

1
(12345U)
UHCP_PORT_STR

UHCP port number (as string for e.g., getaddrinfo() service arg.

1
"12345"
struct uhcp_hdr_t

UHCP packet header struct.

uint32_t uhcp_magic

always contains UHCP in hex

uint8_t ver_type

four bits version number, four bits packet type (see uchp_type_t)

struct uhcp_req_t

struct for request packets

uhcp_hdr_t hdr

member holding parent type

uint8_t prefix_len

contains the requested prefix length

struct uhcp_push_t

struct for push packets

uhcp_hdr_t hdr

member holding parent type

uint8_t prefix_len

contains the prefix length of assigned prefix

uint8_t prefix()

contains the assigned prefix