#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT && PPPOL2TP_SUPPORT
#ifndef PPPOL2TP_H
#define PPPOL2TP_H
#include "ppp.h"
#ifdef __cplusplus
extern "C" {
#endif
#define PPPOL2TP_CONTROL_TIMEOUT (5*1000)
#define PPPOL2TP_SLOW_RETRY (60*1000)
#define PPPOL2TP_MAXSCCRQ 4
#define PPPOL2TP_MAXICRQ 4
#define PPPOL2TP_MAXICCN 4
#define PPPOL2TP_HEADERFLAG_CONTROL 0x8000
#define PPPOL2TP_HEADERFLAG_LENGTH 0x4000
#define PPPOL2TP_HEADERFLAG_SEQUENCE 0x0800
#define PPPOL2TP_HEADERFLAG_OFFSET 0x0200
#define PPPOL2TP_HEADERFLAG_PRIORITY 0x0100
#define PPPOL2TP_HEADERFLAG_VERSION 0x0002
#define PPPOL2TP_HEADERFLAG_CONTROL_MANDATORY (PPPOL2TP_HEADERFLAG_CONTROL|PPPOL2TP_HEADERFLAG_LENGTH|PPPOL2TP_HEADERFLAG_SEQUENCE|PPPOL2TP_HEADERFLAG_VERSION)
#define PPPOL2TP_HEADERFLAG_CONTROL_FORBIDDEN (PPPOL2TP_HEADERFLAG_OFFSET|PPPOL2TP_HEADERFLAG_PRIORITY)
#define PPPOL2TP_HEADERFLAG_DATA_MANDATORY (PPPOL2TP_HEADERFLAG_VERSION)
#define PPPOL2TP_AVPHEADERFLAG_MANDATORY 0x8000
#define PPPOL2TP_AVPHEADERFLAG_HIDDEN 0x4000
#define PPPOL2TP_AVPHEADERFLAG_LENGTHMASK 0x03ff
#define PPPOL2TP_AVPTYPE_MESSAGE 0
#define PPPOL2TP_MESSAGETYPE_SCCRQ 1
#define PPPOL2TP_MESSAGETYPE_SCCRP 2
#define PPPOL2TP_MESSAGETYPE_SCCCN 3
#define PPPOL2TP_MESSAGETYPE_STOPCCN 4
#define PPPOL2TP_MESSAGETYPE_HELLO 6
#define PPPOL2TP_MESSAGETYPE_OCRQ 7
#define PPPOL2TP_MESSAGETYPE_OCRP 8
#define PPPOL2TP_MESSAGETYPE_OCCN 9
#define PPPOL2TP_MESSAGETYPE_ICRQ 10
#define PPPOL2TP_MESSAGETYPE_ICRP 11
#define PPPOL2TP_MESSAGETYPE_ICCN 12
#define PPPOL2TP_MESSAGETYPE_CDN 14
#define PPPOL2TP_MESSAGETYPE_WEN 15
#define PPPOL2TP_MESSAGETYPE_SLI 16
#define PPPOL2TP_AVPTYPE_RESULTCODE 1
#define PPPOL2TP_RESULTCODE 1
#define PPPOL2TP_AVPTYPE_VERSION 2
#define PPPOL2TP_VERSION 0x0100
#define PPPOL2TP_AVPTYPE_FRAMINGCAPABILITIES 3
#define PPPOL2TP_FRAMINGCAPABILITIES 0x00000003
#define PPPOL2TP_AVPTYPE_BEARERCAPABILITIES 4
#define PPPOL2TP_BEARERCAPABILITIES 0x00000003
#define PPPOL2TP_AVPTYPE_TIEBREAKER 5
#define PPPOL2TP_AVPTYPE_HOSTNAME 7
#define PPPOL2TP_HOSTNAME "lwIP"
#define PPPOL2TP_AVPTYPE_VENDORNAME 8
#define PPPOL2TP_VENDORNAME "lwIP"
#define PPPOL2TP_AVPTYPE_TUNNELID 9
#define PPPOL2TP_AVPTYPE_RECEIVEWINDOWSIZE 10
#define PPPOL2TP_RECEIVEWINDOWSIZE 8
#define PPPOL2TP_AVPTYPE_CHALLENGE 11
#define PPPOL2TP_AVPTYPE_CAUSECODE 12
#define PPPOL2TP_AVPTYPE_CHALLENGERESPONSE 13
#define PPPOL2TP_AVPTYPE_CHALLENGERESPONSE_SIZE 16
#define PPPOL2TP_AVPTYPE_SESSIONID 14
#define PPPOL2TP_AVPTYPE_CALLSERIALNUMBER 15
#define PPPOL2TP_AVPTYPE_FRAMINGTYPE 19
#define PPPOL2TP_FRAMINGTYPE 0x00000001
#define PPPOL2TP_AVPTYPE_TXCONNECTSPEED 24
#define PPPOL2TP_TXCONNECTSPEED 100000000
#define PPPOL2TP_STATE_INITIAL 0
#define PPPOL2TP_STATE_SCCRQ_SENT 1
#define PPPOL2TP_STATE_ICRQ_SENT 2
#define PPPOL2TP_STATE_ICCN_SENT 3
#define PPPOL2TP_STATE_DATA 4
#define PPPOL2TP_OUTPUT_DATA_HEADER_LEN 6
typedef struct pppol2tp_pcb_s pppol2tp_pcb;
struct pppol2tp_pcb_s {
ppp_pcb *ppp;
u8_t phase;
struct udp_pcb *udp;
struct netif *netif;
ip_addr_t remote_ip;
u16_t remote_port;
#if PPPOL2TP_AUTH_SUPPORT
const u8_t *secret;
u8_t secret_len;
u8_t secret_rv[16];
u8_t challenge_hash[16];
u8_t send_challenge;
#endif
u16_t tunnel_port;
u16_t our_ns;
u16_t peer_nr;
u16_t peer_ns;
u16_t source_tunnel_id;
u16_t remote_tunnel_id;
u16_t source_session_id;
u16_t remote_session_id;
u8_t sccrq_retried;
u8_t icrq_retried;
u8_t iccn_retried;
};
ppp_pcb *pppol2tp_create(struct netif *pppif,
struct netif *netif, const ip_addr_t *ipaddr, u16_t port,
const u8_t *secret, u8_t secret_len,
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
#ifdef __cplusplus
}
#endif
#endif
#endif