Provides UHCP (micro host configuration protocol) More...

Detailed Description

Files

file  uhcp.h
 UHCP header.
 

Data Structures

struct  uhcp_hdr_t
 UHCP packet header struct. More...
 
struct  uhcp_req_t
 struct for request packets More...
 
struct  uhcp_push_t
 struct for push packets More...
 

Macros

#define UHCP_MAGIC   (0x55484350) /* "UHCP" in hex */
 UHCP magic number.
 
#define UHCP_VER   (0)
 UHCP version of this header.
 
#define UHCP_PORT   (12345U)
 UHCP port number.
 
#define UHCP_PORT_STR   "12345"
 UHCP port number (as string for e.g., getaddrinfo() service arg.
 

Typedefs

typedef unsigned uhcp_iface_t
 typedef for interface handle
 

Enumerations

enum  uhcp_type_t { UHCP_REQ, UHCP_PUSH }
 Enum containing possible UHCP packet types. More...
 

Functions

void uhcp_handle_udp (uint8_t *buf, size_t len, uint8_t *src, uint16_t port, uhcp_iface_t iface)
 handle incoming UDP packet More...
 
void uhcp_handle_req (uhcp_req_t *req, uint8_t *src, uint16_t port, uhcp_iface_t iface)
 handle incoming UHCP request packet More...
 
void uhcp_handle_push (uhcp_push_t *req, uint8_t *src, uint16_t port, uhcp_iface_t iface)
 handle incoming UHCP push packet More...
 
void uhcp_handle_prefix (uint8_t *prefix, uint8_t prefix_len, uint16_t lifetime, uint8_t *src, uhcp_iface_t iface)
 handle incoming prefix (as parsed from push packet) More...
 
static void uhcp_hdr_set (uhcp_hdr_t *hdr, uhcp_type_t type)
 function to set constant values in UHCP header
 
int udp_sendto (uint8_t *buf, size_t len, uint8_t *dst, uint16_t dst_port, uhcp_iface_t dst_iface)
 UDP send function used by UHCP client / server. More...
 

Enumeration Type Documentation

◆ uhcp_type_t

Enumerator
UHCP_REQ 

packet is a request packet

UHCP_PUSH 

packet is a push / answer packet

Definition at line 45 of file uhcp.h.

Function Documentation

◆ udp_sendto()

int udp_sendto ( uint8_t *  buf,
size_t  len,
uint8_t *  dst,
uint16_t  dst_port,
uhcp_iface_t  dst_iface 
)

Supposed to be implemented by UHCP clients.

Parameters
[in]bufbuffer to send
[in]lenlength of buf
[in]dstptr to IPv6 destination address
[in]dst_portdestination port
[in]dst_ifaceinterface number of destination interface

◆ uhcp_handle_prefix()

void uhcp_handle_prefix ( uint8_t *  prefix,
uint8_t  prefix_len,
uint16_t  lifetime,
uint8_t *  src,
uhcp_iface_t  iface 
)

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
[in]prefixptr to assigned prefix
[in]prefix_lenlength of assigned prefix
[in]lifetimelifetime of prefix
[in]srcptr to IPv6 source address
[in]ifacenumber of interface the packet came in

◆ uhcp_handle_push()

void uhcp_handle_push ( uhcp_push_t req,
uint8_t *  src,
uint16_t  port,
uhcp_iface_t  iface 
)

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

◆ uhcp_handle_req()

void uhcp_handle_req ( uhcp_req_t req,
uint8_t *  src,
uint16_t  port,
uhcp_iface_t  iface 
)

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

◆ uhcp_handle_udp()

void uhcp_handle_udp ( uint8_t *  buf,
size_t  len,
uint8_t *  src,
uint16_t  port,
uhcp_iface_t  iface 
)

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

Parameters
[in]bufbuffer containing UDP packet
[in]lenlength of buf
[in]srcptr to IPv6 source address
[in]portsource port of packet
[in]ifaceinterface number of incoming packet