rh.h
1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup net_ipv6_ext_rh IPv6 routing header extension
* @ingroup net_ipv6_ext
* @brief Implementation of IPv6 routing header extension.
* @{
*
* @file
* @brief Routing extension header definitions.
*
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
*/
#ifndef NET_IPV6_EXT_RH_H
#define NET_IPV6_EXT_RH_H
#include <stdint.h>
#include "net/ipv6/addr.h"
#include "net/ipv6/ext.h"
#include "net/ipv6/hdr.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name Return codes for routing header processing
* @{
*/
#define EXT_RH_CODE_ERROR (-1)
#define EXT_RH_CODE_FORWARD (0)
#define EXT_RH_CODE_OK (1)
/**
* @}
*/
/**
* @brief IPv6 routing extension header.
*
* @see <a href="https://tools.ietf.org/html/rfc2460#section-4.4">
* RFC 2460, section 4.4
* </a>
*
* @extends ipv6_ext_t
*/
typedef struct __attribute__((packed)) {
uint8_t nh; /**< next header */
uint8_t len; /**< length in 8 octets without first octet */
uint8_t type; /**< identifier of a particular routing header type */
uint8_t seg_left; /**< number of route segments remaining */
} ipv6_ext_rh_t;
/**
* @brief Process the routing header of an IPv6 packet.
*
* @param[in, out] ipv6 An IPv6 packet.
* @param[in] ext A routing header of @p ipv6.
*
* @return EXT_RH_CODE_ERROR
* @return EXT_RH_CODE_FORWARD
* @return EXT_RH_CODE_OK
*/
int ipv6_ext_rh_process(ipv6_hdr_t *ipv6, ipv6_ext_rh_t *ext);
#ifdef __cplusplus
}
#endif
#endif /* NET_IPV6_EXT_RH_H */
/** @} */