Skip to content
Permalink
Browse files

net: ppp: Add IPV6CP support

Initial version for PPP IPv6 Control Protocol.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
  • Loading branch information...
jukkar committed May 14, 2019
1 parent f95938d commit 02239a99a2a700ee3854dfb52fa5b9ec8f183566
@@ -31,8 +31,12 @@ extern "C" {
#ifdef CONFIG_NET_L2_IEEE802154
#define NET_LINK_ADDR_MAX_LENGTH 8
#else
#ifdef CONFIG_NET_L2_PPP
#define NET_LINK_ADDR_MAX_LENGTH 8
#else
#define NET_LINK_ADDR_MAX_LENGTH 6
#endif
#endif

/**
* Type of the link address. This indicates the network technology that this
@@ -33,6 +33,9 @@ extern "C" {
/** Max length of terminate description string */
#define PPP_MAX_TERMINATE_REASON_LEN 32

/** Length of network interface identifier */
#define PPP_INTERFACE_IDENTIFIER_LEN 8

/** PPP L2 API */
struct ppp_api {
/**
@@ -65,12 +68,13 @@ struct ppp_api {
* for details.
*/
enum ppp_protocol_type {
PPP_IP = 0x0021, /**< RFC 1332 */
PPP_IPV6 = 0x0057, /**< RFC 5072 */
PPP_IPCP = 0x8021, /**< RFC 1332 */
PPP_ECP = 0x8053, /**< RFC 1968 */
PPP_CCP = 0x80FD, /**< RFC 1962 */
PPP_LCP = 0xc021, /**< RFC 1661 */
PPP_IP = 0x0021, /**< RFC 1332 */
PPP_IPV6 = 0x0057, /**< RFC 5072 */
PPP_IPCP = 0x8021, /**< RFC 1332 */
PPP_ECP = 0x8053, /**< RFC 1968 */
PPP_IPV6CP = 0x8057, /**< RFC 5072 */
PPP_CCP = 0x80FD, /**< RFC 1962 */
PPP_LCP = 0xc021, /**< RFC 1661 */
};

/**
@@ -168,6 +172,16 @@ enum ipcp_option_type {
IPCP_OPTION_IP_ADDRESS = 3,
} __packed;

/**
* IPV6CP option types from RFC 5072
*/
enum ipv6cp_option_type {
IPV6CP_OPTION_RESERVED = 0,

/** Interface identifier */
IPV6CP_OPTION_INTERFACE_IDENTIFIER = 1,
} __packed;

/**
* Generic PPP Finite State Machine
*/
@@ -290,6 +304,7 @@ struct ppp_option_pkt {
union {
enum lcp_option_type lcp;
enum ipcp_option_type ipcp;
enum ipv6cp_option_type ipv6cp;
} type;

/** Option length */
@@ -329,6 +344,11 @@ struct ipcp_options {
struct in_addr address;
};

struct ipv6cp_options {
/** Interface identifier */
u8_t iid[PPP_INTERFACE_IDENTIFIER_LEN];
};

/** PPP L2 context specific to certain network interface */
struct ppp_context {
struct {
@@ -383,6 +403,25 @@ struct ppp_context {
} ipcp;
#endif

#if defined(CONFIG_NET_IPV6)
struct {
/** Finite state machine for IPV6CP */
struct ppp_fsm fsm;

/** Options that we want to request */
struct ipv6cp_options my_options;

/** Options that peer want to request */
struct ipv6cp_options peer_options;

/** Options that we accepted */
struct ipv6cp_options my_accepted;

/** Options that peer accepted */
struct ipv6cp_options peer_accepted;
} ipv6cp;
#endif

#if defined(CONFIG_NET_SHELL)
struct {
/** Used when waiting Echo-Reply */
@@ -428,6 +467,12 @@ struct ppp_context {

/** IPCP open status (open / closed) */
u16_t is_ipcp_open : 1;

/** IPV6CP status (up / down) */
u16_t is_ipv6cp_up : 1;

/** IPV6CP open status (open / closed) */
u16_t is_ipv6cp_open : 1;
};

/**
@@ -23,3 +23,7 @@ zephyr_library_sources_ifdef(CONFIG_NET_STATISTICS_PPP ppp_stats.c)
if(CONFIG_NET_IPV4)
zephyr_library_sources_ifdef(CONFIG_NET_L2_PPP ipcp.c)
endif()

if(CONFIG_NET_IPV6)
zephyr_library_sources_ifdef(CONFIG_NET_L2_PPP ipv6cp.c)
endif()
@@ -363,6 +363,11 @@ int ppp_send_pkt(struct ppp_fsm *fsm, struct net_if *iface,
#if defined(CONFIG_NET_IPV4)
} else if (fsm->protocol == PPP_IPCP) {
ctx = CONTAINER_OF(fsm, struct ppp_context, ipcp.fsm);
#endif
#if defined(CONFIG_NET_IPV6)
} else if (fsm->protocol == PPP_IPV6CP) {
ctx = CONTAINER_OF(fsm, struct ppp_context,
ipv6cp.fsm);
#endif
} else {
return -ENOENT;

0 comments on commit 02239a9

Please sign in to comment.
You can’t perform that action at this time.