Loading...
Searching...
No Matches

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

Detailed Description

Provides UHCP (micro host configuration protocol)

UHCP (micro host configuration protocol) is a RIOT-proprietary protocol that was developed to have a simple drop-in replacement for DHCPv6 prefix delegation (which was not implemented when UHCP was introduced).

If you have root access on your host machine or access to a DHCPv6 server providing prefix delegation, DHCPv6 is preferred over UHCP.

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
 
void uhcp_handle_req (uhcp_req_t *req, uint8_t *src, uint16_t port, uhcp_iface_t iface)
 handle incoming UHCP request packet
 
void uhcp_handle_push (uhcp_push_t *req, uint8_t *src, uint16_t port, uhcp_iface_t iface)
 handle incoming UHCP push packet
 
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)
 
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.
 

Macro Definition Documentation

◆ UHCP_MAGIC

#define UHCP_MAGIC   (0x55484350) /* "UHCP" in hex */

UHCP magic number.

Definition at line 42 of file uhcp.h.

◆ UHCP_PORT

#define UHCP_PORT   (12345U)

UHCP port number.

Definition at line 48 of file uhcp.h.

◆ UHCP_PORT_STR

#define UHCP_PORT_STR   "12345"

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

Definition at line 51 of file uhcp.h.

◆ UHCP_VER

#define UHCP_VER   (0)

UHCP version of this header.

Definition at line 45 of file uhcp.h.

Typedef Documentation

◆ uhcp_iface_t

typedef unsigned uhcp_iface_t

typedef for interface handle

Definition at line 91 of file uhcp.h.

Enumeration Type Documentation

◆ uhcp_type_t

Enum containing possible UHCP packet types.

Enumerator
UHCP_REQ 

packet is a request packet

UHCP_PUSH 

packet is a push / answer packet

Definition at line 54 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 
)

UDP send function used by UHCP client / server.

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 
)

handle incoming prefix (as parsed from push packet)

Supposed to be implemented by UHCP client implementations for the network stack.

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 
)

handle incoming UHCP push packet

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 
)

handle incoming UHCP request packet

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 
)

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
[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

◆ uhcp_hdr_set()

static void uhcp_hdr_set ( uhcp_hdr_t hdr,
uhcp_type_t  type 
)
inlinestatic

function to set constant values in UHCP header

Definition at line 165 of file uhcp.h.