Blame view

RIOT/sys/include/net/ipv6/ext.h 1.51 KB
fb11e647   vrobic   reseau statique a...
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
  /*
   * 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    IPv6 extension headers
   * @ingroup     net_ipv6
   * @brief       Provides IPv6 extension header definitions and helper functions.
   * @{
   *
   * @file
   * @brief   IPv6 extension header definitions.
   *
   * @author  Martine Lenders <mlenders@inf.fu-berlin.de>
   */
  #ifndef IPV6_EXT_H_
  #define IPV6_EXT_H_
  
  #include <stdint.h>
  
  #include "net/ipv6/ext/rh.h"
  
  #ifdef __cplusplus
  extern "C" {
  #endif
  
  #define IPV6_EXT_LEN_UNIT   (8U)    /**< Unit in byte for the extension header's
                                       *   length field */
  
  /**
   * @brief   IPv6 extension headers.
   *
   * @see <a href="https://tools.ietf.org/html/rfc2460#section-4">
   *          RFC 2460, section 4.1
   *      </a>
   */
  typedef struct __attribute__((packed)) {
      uint8_t nh;     /**< next header */
      uint8_t len;    /**< length in 8 octets without first octet */
  } ipv6_ext_t;
  
  /**
   * @brief   Gets the next extension header in a packet.
   *
   * @param[in] ext   The current extension header.
   *
   * @return  The next extension header.
   */
  static inline ipv6_ext_t *ipv6_ext_get_next(ipv6_ext_t *ext)
  {
      return (ipv6_ext_t *)((uint8_t *)(ext) + (ext->len * IPV6_EXT_LEN_UNIT) +
                            IPV6_EXT_LEN_UNIT);
  }
  
  #ifdef __cplusplus
  }
  #endif
  
  #endif /* IPV6_EXT_H_ */
  /** @} */