-
Notifications
You must be signed in to change notification settings - Fork 2.1k
ipv6/rpl: add hop-by-hop extension handling #7231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,13 +145,14 @@ kernel_pid_t gnrc_ipv6_init(void); | |
| * This situation may happen when the packet has a source routing extension | ||
| * header (RFC 6554), and the packet is forwarded from an interface to another. | ||
| * | ||
| * @param[in] netif The receiving interface. | ||
| * @param[in] current A snip to process. | ||
| * @param[in] pkt A packet. | ||
| * @param[in] nh A protocol number (see @ref net_protnum) of the current snip. | ||
| * @param[in] netif The receiving interface. | ||
| * @param[in] current A snip to process. | ||
| * @param[in] pkt A packet. | ||
| * @param[in] nh A protocol number (see @ref net_protnum) of the current snip. | ||
| * @param[in] is_for_me Indicates if we are the destination of the packet. | ||
| */ | ||
| void gnrc_ipv6_demux(gnrc_netif_t *netif, gnrc_pktsnip_t *current, | ||
| gnrc_pktsnip_t *pkt, uint8_t nh); | ||
| gnrc_pktsnip_t *pkt, uint8_t nh, bool is_for_me); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have some refactoring work regarding extension headers laying around (not even pushed yet) that would make this additional parameter most likely unnecessary. This would however throw back this PR again... So I think it makes more sense to merge this first and then clean it up with my refactoring ^^.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a lot of weird stuff happening with the extension headers at the moment that can be implemented much more straight forward, that is what the refactoring is for ;-)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be great to merge this aged PR finally.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know :-/, but I also finally wanted to clean-up IPv6 reception. I can help you to adapt it to the refactoring!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Then someone else of course needs to help reviewing)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I'm convinced that it doesn't make sense to merge this PR now. |
||
|
|
||
| /** | ||
| * @brief Get the IPv6 header from a given list of @ref gnrc_pktsnip_t | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| /* | ||
| * Copyright (C) 2017 Martin Landsmann <[email protected]> | ||
| * | ||
| * 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_gnrc_rpl_hop RPL Hop-by-Hop header extension | ||
| * @ingroup net_gnrc_rpl | ||
| * @brief Implementation of RPL Hop-by-Hop extension headers | ||
| * @see <a href="https://tools.ietf.org/html/rfc6553"> | ||
| * RFC 6553 | ||
| * </a> | ||
| * @{ | ||
| * | ||
| * @file | ||
| * @brief Definitions for Carrying RPL Information in Data-Plane Datagrams | ||
| * | ||
| * @author Martin Landsmann <[email protected]> | ||
| */ | ||
| #ifndef NET_GNRC_RPL_HOP_H | ||
| #define NET_GNRC_RPL_HOP_H | ||
|
|
||
| #include "net/ipv6/hdr.h" | ||
| #include "net/ipv6/addr.h" | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| /** | ||
| * @brief Type of the Hop-by-Hop Option. | ||
| * | ||
| * @see <a href="https://tools.ietf.org/html/rfc6553#section-6"> | ||
| * RFC6553, section 6 | ||
| * </a> | ||
| */ | ||
| #define GNRC_RPL_HOP_OPT_TYPE (0x63) | ||
|
|
||
| /** | ||
| * @name Return types used in processing a hop-by-hop option | ||
| * | ||
| * @{ | ||
| */ | ||
| #define HOP_OPT_SUCCESS (0) | ||
| #define HOP_OPT_ERR_HEADER_LENGTH (-1) | ||
| #define HOP_OPT_ERR_INCONSISTENCY (-2) | ||
| #define HOP_OPT_ERR_FLAG_R_SET (-3) | ||
| #define HOP_OPT_ERR_FLAG_F_SET (-4) | ||
| #define HOP_OPT_ERR_NOT_FOR_ME (-5) | ||
| /** @} */ | ||
|
|
||
| /** | ||
| * @name Option flags | ||
| * @see <a href="https://tools.ietf.org/html/rfc6553#section-3"> | ||
| * RFC6553, section 3 | ||
| * </a> | ||
| * @{ | ||
| */ | ||
| #define GNRC_RPL_HOP_OPT_FLAG_O (1 << 0) | ||
| #define GNRC_RPL_HOP_OPT_FLAG_R (1 << 1) | ||
| #define GNRC_RPL_HOP_OPT_FLAG_F (1 << 2) | ||
| /** @} */ | ||
|
|
||
| /** | ||
| * @brief The RPL Hop-by-Hop header extension. | ||
| * | ||
| * @see <a href="https://tools.ietf.org/html/rfc6553#section-3"> | ||
| * RFC 6553 | ||
| * </a> | ||
| */ | ||
| typedef struct __attribute__((packed)) { | ||
| uint8_t nh; /**< the option type of the next extension */ | ||
| uint8_t hbh_len; /**< the hbh length without the first octet */ | ||
| uint8_t type; /**< option identifier (0x63) */ | ||
| uint8_t len; /**< length in 8 octets without first octet */ | ||
| uint8_t ORF_flags; /**< O|R|F flags followed by 5 unused bits */ | ||
| uint8_t instance_id; /**< id of the instance */ | ||
| uint16_t sender_rank; /**< rank of the sender */ | ||
| } gnrc_rpl_hop_opt_t; | ||
miri64 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| /** | ||
| * @brief parse the given hop-by-hop option, check for inconsistencies, | ||
| * adjust the option for further processing and return the result. | ||
| * | ||
| * @param[in,out] hop pointer to the hop-by-hop header option | ||
| * | ||
| * @returns HOP_OPT_SUCCESS on success | ||
| * HOP_OPT_ERR_HEADER_LENGTH if there was a header length mismatch | ||
| * HOP_OPT_ERR_INCONSISTENCY if the F flag was already set | ||
| * HOP_OPT_ERR_FLAG_R_SET if we set the R flag | ||
| * HOP_OPT_ERR_FLAG_F_SET if we set the F flag | ||
| * HOP_OPT_ERR_NOT_FOR_ME if the content is not for us | ||
| */ | ||
| int gnrc_rpl_hop_opt_process(gnrc_rpl_hop_opt_t *hop); | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif /* NET_GNRC_RPL_HOP_H */ | ||
| /** @} */ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,8 @@ | |
| #include <stdint.h> | ||
|
|
||
| #include "net/ipv6/ext/rh.h" | ||
| #include "net/gnrc/netif.h" | ||
| #include "net/gnrc/pkt.h" | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
|
|
@@ -31,6 +33,19 @@ extern "C" { | |
| #define IPV6_EXT_LEN_UNIT (8U) /**< Unit in byte for the extension header's | ||
| * length field */ | ||
|
|
||
| /** @brief Message type to reply IPv6 that a next header has been processed */ | ||
| #define GNRC_IPV6_EXT_HANDLE_NEXT_HDR (0x0399) | ||
|
|
||
| /** | ||
| * @brief Message content container to process extension headers sequentially. | ||
| */ | ||
| typedef struct { | ||
| gnrc_netif_t *netif; /**< The interface we received the packet */ | ||
| gnrc_pktsnip_t *current; /**< The snip of the IP6 header */ | ||
| gnrc_pktsnip_t *next_hdr; /**< The next header to be processed */ | ||
| uint8_t nh_type; /**< The type of the next header */ | ||
| } gnrc_ipv6_ext_hdr_handle_t; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this however by its very name should go into GNRC not
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (not just the name, also the fact that you are using GNRC-specific types here)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't know, its purpose is only to enable the sequential iteration of extension headers for IPv6 packets.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @BytesGalore before you do anything, have a look at my refactoring work first of the past few weeks. It also should very much simplify the handling of the hop-by-hop-header, as it is now treated separately (which we can do, because they always MUST come first according to RFC8200; see #10244). You should now be able to just hook into the according switch-branch with |
||
|
|
||
| /** | ||
| * @brief IPv6 extension headers. | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -553,6 +553,18 @@ typedef enum { | |
| * incoming frames until unset. | ||
| */ | ||
| NETOPT_PHY_BUSY, | ||
| /** | ||
| * @brief Type for sequiential processing of IPv6 extension headers | ||
| * | ||
| * On GET it requests a thread to provide an extension header | ||
| * and prepends it to the given payload of the given (IPv6) packet. | ||
| * On SET it always returns -ENOTSUP. | ||
| * | ||
| * When the header is done the thread replies to the call. | ||
| * The result is the pktsnip_t with the extension header | ||
| * The result is NULL if no extension header is passed. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You hand over a pointer (not a pointer of a pointer) below, so this should be impossible. Why not use the numeric return-value of NETAPI_GET (which is returned by
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
true, it would require some wrapping. |
||
| */ | ||
| NETOPT_IPV6_EXT_HDR, | ||
|
|
||
| /* add more options if needed */ | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please adjust the dependencies for
gnrc_rpl_hopto includegnrc_ipv6_extautomagically