Skip to content

Commit

Permalink
net: ppp: Add IPV6CP support
Browse files Browse the repository at this point in the history
Initial version for PPP IPv6 Control Protocol.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
  • Loading branch information
jukkar committed Jul 29, 2019
1 parent f95938d commit 02239a9
Show file tree
Hide file tree
Showing 7 changed files with 650 additions and 6 deletions.
4 changes: 4 additions & 0 deletions include/net/net_linkaddr.h
Expand Up @@ -31,8 +31,12 @@ extern "C" {
#ifdef CONFIG_NET_L2_IEEE802154 #ifdef CONFIG_NET_L2_IEEE802154
#define NET_LINK_ADDR_MAX_LENGTH 8 #define NET_LINK_ADDR_MAX_LENGTH 8
#else #else
#ifdef CONFIG_NET_L2_PPP
#define NET_LINK_ADDR_MAX_LENGTH 8
#else
#define NET_LINK_ADDR_MAX_LENGTH 6 #define NET_LINK_ADDR_MAX_LENGTH 6
#endif #endif
#endif


/** /**
* Type of the link address. This indicates the network technology that this * Type of the link address. This indicates the network technology that this
Expand Down
57 changes: 51 additions & 6 deletions include/net/ppp.h
Expand Up @@ -33,6 +33,9 @@ extern "C" {
/** Max length of terminate description string */ /** Max length of terminate description string */
#define PPP_MAX_TERMINATE_REASON_LEN 32 #define PPP_MAX_TERMINATE_REASON_LEN 32


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

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


/** /**
Expand Down Expand Up @@ -168,6 +172,16 @@ enum ipcp_option_type {
IPCP_OPTION_IP_ADDRESS = 3, IPCP_OPTION_IP_ADDRESS = 3,
} __packed; } __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 * Generic PPP Finite State Machine
*/ */
Expand Down Expand Up @@ -290,6 +304,7 @@ struct ppp_option_pkt {
union { union {
enum lcp_option_type lcp; enum lcp_option_type lcp;
enum ipcp_option_type ipcp; enum ipcp_option_type ipcp;
enum ipv6cp_option_type ipv6cp;
} type; } type;


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


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

/** PPP L2 context specific to certain network interface */ /** PPP L2 context specific to certain network interface */
struct ppp_context { struct ppp_context {
struct { struct {
Expand Down Expand Up @@ -383,6 +403,25 @@ struct ppp_context {
} ipcp; } ipcp;
#endif #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) #if defined(CONFIG_NET_SHELL)
struct { struct {
/** Used when waiting Echo-Reply */ /** Used when waiting Echo-Reply */
Expand Down Expand Up @@ -428,6 +467,12 @@ struct ppp_context {


/** IPCP open status (open / closed) */ /** IPCP open status (open / closed) */
u16_t is_ipcp_open : 1; 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;
}; };


/** /**
Expand Down
4 changes: 4 additions & 0 deletions subsys/net/l2/ppp/CMakeLists.txt
Expand Up @@ -23,3 +23,7 @@ zephyr_library_sources_ifdef(CONFIG_NET_STATISTICS_PPP ppp_stats.c)
if(CONFIG_NET_IPV4) if(CONFIG_NET_IPV4)
zephyr_library_sources_ifdef(CONFIG_NET_L2_PPP ipcp.c) zephyr_library_sources_ifdef(CONFIG_NET_L2_PPP ipcp.c)
endif() endif()

if(CONFIG_NET_IPV6)
zephyr_library_sources_ifdef(CONFIG_NET_L2_PPP ipv6cp.c)
endif()
5 changes: 5 additions & 0 deletions subsys/net/l2/ppp/fsm.c
Expand Up @@ -363,6 +363,11 @@ int ppp_send_pkt(struct ppp_fsm *fsm, struct net_if *iface,
#if defined(CONFIG_NET_IPV4) #if defined(CONFIG_NET_IPV4)
} else if (fsm->protocol == PPP_IPCP) { } else if (fsm->protocol == PPP_IPCP) {
ctx = CONTAINER_OF(fsm, struct ppp_context, ipcp.fsm); 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 #endif
} else { } else {
return -ENOENT; return -ENOENT;
Expand Down

0 comments on commit 02239a9

Please sign in to comment.