686 lines
22 KiB
C
686 lines
22 KiB
C
/*
|
|
******************************************************************************
|
|
* HEADER FILE
|
|
*
|
|
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipppp_h.h,v $ $Revision: 1.23.10.4 $
|
|
* $Source: /home/interpeak/CVSRoot/ipppp/src/ipppp_h.h,v $
|
|
* $Author: qsun $ $Date: 2014-06-23 13:08:14 $
|
|
* $State: Exp $ $Locker: $
|
|
*
|
|
* INTERPEAK_COPYRIGHT_STRING
|
|
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
|
******************************************************************************
|
|
*/
|
|
#ifndef IPPPP_H_H
|
|
#define IPPPP_H_H
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 1 DESCRIPTION
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 2 CONFIGURATION
|
|
****************************************************************************
|
|
*/
|
|
|
|
#include "ipppp_config.h"
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 3 INCLUDE FILES
|
|
****************************************************************************
|
|
*/
|
|
|
|
#include "ipppp.h"
|
|
#include "ipppp_ipstack.h"
|
|
|
|
#include <ipcom_os.h>
|
|
#include <ipcom_netif.h>
|
|
#ifdef IPPPP_USE_AUTH
|
|
#include <ipcom_auth.h>
|
|
#endif
|
|
#if defined(IPPPP_USE_AUTH_CHAP) || defined(IPPPP_PPPOE_USE_MD5)
|
|
#ifdef IPMCRYPTO
|
|
#include <ip/openssl/md5.h>
|
|
#else
|
|
#include <openssl/md5.h>
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 4 DEFINES
|
|
****************************************************************************
|
|
*/
|
|
#define IPPPP_INITFCS16 0xffff /* Initial FCS value */
|
|
#define IPPPP_GOODFCS16 0xf0b8 /* Good final FCS value */
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* STACK APIs
|
|
*===========================================================================
|
|
*/
|
|
|
|
/* IPLITE stack */
|
|
#ifdef IPLITE
|
|
#include "iplite_h.h"
|
|
#include "iplite_netif.h"
|
|
#include "iplite_eth.h"
|
|
#define ipstack (&iplite)
|
|
#define Ipstack_netif Iplite_netif
|
|
#define Ipstack_netif_eth Iplite_netif_eth
|
|
|
|
/* IPNET stack */
|
|
#else
|
|
#include "ipnet_h.h"
|
|
#include "ipnet_netif.h"
|
|
#include "ipnet_eth.h"
|
|
#define ipstack ipnet
|
|
#define Ipstack_netif Ipnet_netif
|
|
#define Ipstack_netif_eth Ipnet_netif_eth
|
|
#endif
|
|
|
|
#ifdef IPCOM_SYSLOG_PRIORITY
|
|
#undef IPCOM_SYSLOG_PRIORITY
|
|
#endif
|
|
#ifdef IPCOM_SYSLOG_FACILITY
|
|
#undef IPCOM_SYSLOG_FACILITY
|
|
#endif
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* PPP macros
|
|
*===========================================================================
|
|
*/
|
|
/* ppp timer types */
|
|
#define IPPPP_TIMER_STOPPED 0
|
|
#define IPPPP_TIMER_CONFREQ 1
|
|
#define IPPPP_TIMER_TERMREQ 2
|
|
#define IPPPP_TIMER_ECHOREQ 3
|
|
#define IPPPP_TIMER_AUTH 4
|
|
|
|
#define IPPPP_TIMER_REASON_AUTO 0
|
|
#define IPPPP_TIMER_REASON_DOWN 1
|
|
#define IPPPP_TIMER_REASON_UP 2
|
|
#define IPPPP_TIMER_REASON_EVENTDOWN 3
|
|
#define IPPPP_TIMER_REASON_FIN 4
|
|
#define IPPPP_TIMER_REASON_TIMEOUT 5
|
|
|
|
|
|
/* IPCOM packet flags: */
|
|
#define IPCOM_PKT_FLAG_DEFCONF IPCOM_PKT_FLAG_LINK1
|
|
|
|
/* PPP states: */
|
|
#define IPPPP_STATE_INITIAL 0
|
|
#define IPPPP_STATE_STARTING 1
|
|
#define IPPPP_STATE_CLOSED 2
|
|
#define IPPPP_STATE_STOPPED 3
|
|
#define IPPPP_STATE_CLOSING 4
|
|
#define IPPPP_STATE_STOPPING 5
|
|
#define IPPPP_STATE_REQSENT 6
|
|
#define IPPPP_STATE_ACKRCVD 7
|
|
#define IPPPP_STATE_ACKSENT 8
|
|
#define IPPPP_STATE_OPENED 9
|
|
|
|
|
|
/* PPP address and control field: */
|
|
#define IPPPP_ADDRESS 0xff
|
|
#define IPPPP_CONTROL 0x03
|
|
|
|
/* PPP byte-stuffing control octets: */
|
|
#define IPPPP_TERMINATOR 0x7e /* Flag Sequence octet */
|
|
#define IPPPP_ESCAPE 0x7d /* Control Escape octet */
|
|
|
|
#define IPPPP_BIT_GET(xmask,xbit) (IP_BIT_ISSET((xmask),(Ip_u32)IP_BIT_VAL((xbit))) ? 1 : 0)
|
|
#define IPPPP_MUST_ESCAPE_SND(b) (b == IPPPP_TERMINATOR || \
|
|
b == IPPPP_ESCAPE || \
|
|
(b < 0x20 && IPPPP_BIT_GET(snd_accm,b)))
|
|
|
|
/* PPP codes: */
|
|
#define IPPPP_CODE_CONFREQ 1
|
|
#define IPPPP_CODE_CONFACK 2
|
|
#define IPPPP_CODE_CONFNAK 3
|
|
#define IPPPP_CODE_CONFREJ 4
|
|
#define IPPPP_CODE_TERMREQ 5
|
|
#define IPPPP_CODE_TERMACK 6
|
|
#define IPPPP_CODE_CODEREJ 7
|
|
#define IPPPP_CODE_PROTREJ 8
|
|
#define IPPPP_CODE_ECHOREQ 9
|
|
#define IPPPP_CODE_ECHOREP 10
|
|
#define IPPPP_CODE_DISCREQ 11
|
|
#define IPPPP_CODE_IDENT 12
|
|
#define IPPPP_CODE_TIME_REMAIN 13
|
|
#define IPPPP_CODE_MAX 14 /* one larger than max used. */
|
|
|
|
/* If escaped, return decoded byte (always less than 0x20), otherwise return 0xff */
|
|
#define IPPPP_BYTE_ESCAPED(p,n) (p[n] == IPPPP_ESCAPE ? ((p[n+1] - 0x20)) : 0xff)
|
|
|
|
/* Standard PPP pkt size (must be enough for all PPP LCP/IPCP/AUTH packets. */
|
|
#define IPPPP_PKTSIZE 100
|
|
|
|
/* AUTH stuff: */
|
|
#define IPPPP_DOING_AUTH(link) (link->data.auth_peer_prot || link->data.auth_local_prot)
|
|
|
|
#define IPPPP_HDR_SIZE 4 /* PPP header size. */
|
|
#define IPPPP_IP_HDR_SIZE 20
|
|
|
|
#define IPPPP_ETH_HDR_SIZE 14
|
|
#define IPPPP_PPPOE_HDR_SIZE 6
|
|
|
|
#ifdef IPPPP_USE_PPPMP
|
|
#define IPPPP_PPPMP_HDR_SIZE 6
|
|
#endif
|
|
|
|
/*
|
|
*===========================================================================
|
|
* syslog
|
|
*===========================================================================
|
|
*/
|
|
#if defined(_WRS_CONFIG_IPPPP_SYSLOG_PRIORITY)
|
|
#define IPCOM_SYSLOG_PRIORITY _WRS_CONFIG_IPPPP_SYSLOG_PRIORITY
|
|
#else
|
|
#define IPCOM_SYSLOG_PRIORITY IPPPP_SYSLOG_PRIORITY
|
|
#endif
|
|
#define IPCOM_SYSLOG_FACILITY IPCOM_LOG_IPPPP
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 5 PUBLIC TYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 6 INTERNAL TYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
*===========================================================================
|
|
* Ipppp_phase
|
|
*===========================================================================
|
|
*/
|
|
struct Ipppp_link_struct;
|
|
|
|
typedef struct Ipppp_phase_struct
|
|
{
|
|
Ipcom_netif *netif;
|
|
struct Ipppp_link_struct *link; /* link back-pointer. */
|
|
void *tmo_handle;
|
|
|
|
Ip_u8 pindex; /* phase index, IPPPP_PHASE_XXX below */
|
|
Ip_u8 state;
|
|
Ip_u8 id; /* CONFREQ and TERMREQ LCP id. */
|
|
|
|
/* Timeout data. */
|
|
Ip_u8 tmo_type;
|
|
Ip_u8 restart_counter;
|
|
Ip_u8 pad[3];
|
|
}
|
|
Ipppp_phase;
|
|
|
|
/* PPP phases: */
|
|
#define IPPPP_PHASE_LINK 0
|
|
#define IPPPP_PHASE_LCP 1
|
|
#define IPPPP_PHASE_AUTH 2
|
|
#define IPPPP_PHASE_IPCP 3
|
|
#define IPPPP_PHASE_IPV6CP 4
|
|
#define IPPPP_PHASE_MAX 5 /*! keep updated, one larger than used. */
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* Ipppp_link_data
|
|
*===========================================================================
|
|
* Session temporary PPP link data.
|
|
*/
|
|
typedef struct Ipppp_link_data_struct
|
|
{
|
|
Ip_u32 flags; /* Link flags. */
|
|
|
|
int lcp_echo_interval; /* LCP EchoReq output interval in seconds. <= 0 disabled. Default 60 */
|
|
int lcp_echo_failure; /* Max EchoReq failures before link termination. Default 5 */
|
|
Ip_u32 lcp_peer_magic; /* peer 32-bit magic number. */
|
|
Ip_u32 lcp_local_magic; /* local 32-bit magic number. */
|
|
|
|
Ip_u8 loop_failure; /* # loop backed packets received. */
|
|
Ip_u8 nak_failure; /* # NAK sent without ACK sent. */
|
|
Ip_u8 auth_peer_id; /* Last seen peer ID (PAP request, CHAP response) */
|
|
Ip_u8 pad;
|
|
|
|
#ifdef IPPPP_USE_RFC1877_CLIENT
|
|
Ip_u32 ipcp_pri_dnsaddr_n;
|
|
Ip_u32 ipcp_pri_nbnsaddr_n;
|
|
Ip_u32 ipcp_sec_dnsaddr_n;
|
|
Ip_u32 ipcp_sec_nbnsaddr_n;
|
|
#endif
|
|
|
|
#ifdef IPCOM_USE_AUTH
|
|
char peer_username[IPCOM_AUTH_USERNAME_MAX];
|
|
Ip_u16 auth_peer_prot; /* Request peer to authenticate using prot. */
|
|
Ip_u16 auth_local_prot; /* Peer require us to login using prot. */
|
|
#endif
|
|
|
|
#ifdef IPPPP_USE_AUTH_CHAP
|
|
int chap_challenge_size;
|
|
Ip_u8 chap_challenge[48];
|
|
|
|
Ip_u8 peer_chap_challenge[48];
|
|
Ip_u8 peer_chap_challenge_size;
|
|
Ip_u8 peer_chap_challenge_id;
|
|
Ip_u8 local_chap_challenge_id;
|
|
Ip_u8 pad2;
|
|
#endif
|
|
|
|
#ifdef IPPPP_USE_PPPOE
|
|
Ip_u32 pppoe_session_id;
|
|
#endif
|
|
|
|
#ifdef IPPPP_USE_VJCOMP
|
|
void *vjcomp_in_cookie;
|
|
void *vjcomp_out_cookie;
|
|
#endif /* IPPPP_USE_VJCOMP */
|
|
}
|
|
Ipppp_link_data;
|
|
|
|
/* Dont negotiate flags (peer rejected our confreq option). */
|
|
#define IPPPP_LINKFLAG_UP 0x00000001 /* READ ONLY. */
|
|
#define IPPPP_LINKFLAG_DONTNEG_ACCOMP 0x00000002
|
|
#define IPPPP_LINKFLAG_DONTNEG_ACCM 0x00000004
|
|
#define IPPPP_LINKFLAG_DONTNEG_MRU 0x00000008
|
|
#define IPPPP_LINKFLAG_DONTNEG_MAGIC 0x00000010
|
|
#define IPPPP_LINKFLAG_DONTNEG_IPADDRESS 0x00000020 /* IPCP */
|
|
#define IPPPP_LINKFLAG_DONTNEG_IDENTIFIER 0x00000040 /* IPv6 */
|
|
#define IPPPP_LINKFLAG_DONTSNDAC 0x00000080 /* do not send initial 0xff 0x03. */
|
|
#define IPPPP_LINKFLAG_DONTNEG_PRI_DNSADDR 0x00000100 /* IPCP */
|
|
#define IPPPP_LINKFLAG_DONTNEG_PRI_NBNSADDR 0x00000200 /* IPCP */
|
|
#define IPPPP_LINKFLAG_DONTNEG_SEC_DNSADDR 0x00000400 /* IPCP */
|
|
#define IPPPP_LINKFLAG_DONTNEG_SEC_NBNSADDR 0x00000800 /* IPCP */
|
|
#define IPPPP_LINKFLAG_WINCOMPAT 0x00001000 /* wincompat enabled */
|
|
#define IPPPP_LINKFLAG_AUTHENTICATED 0x00002000 /* authenticated at startup */
|
|
#define IPPPP_LINKFLAG_DONTNEG_PCOMP 0x00010000
|
|
|
|
#ifdef IPPPP_USE_PPPMP
|
|
|
|
#define IPPPP_LINKFLAG_DONTNEG_MRRU 0x00004000 /* Controls multilink */
|
|
#define IPPPP_LINKFLAG_DONTNEG_SSN 0x00008000 /* Short Sequence Number negotiation flag*/
|
|
#define IPPPP_PPPMP_MAX_FRAGMENTS 128
|
|
|
|
/* Bit definitions for the MP header */
|
|
#define IPPPP_MPHEADER_FIRST_FRAGMENT 0x8000 /* This is the first fragment */
|
|
#define IPPPP_MPHEADER_LAST_FRAGMENT 0x4000 /* This is the last fragment */
|
|
#define IPPPP_MPHEADER_ONLY_FRAGMENT 0xC000 /* This is the only fragment */
|
|
#define IPPPP_MPFRAGMENT_ISFIRST(xflag) ((xflag) & IPPPP_MPHEADER_FIRST_FRAGMENT)
|
|
#define IPPPP_MPFRAGMENT_ISLAST(xflag) ((xflag) & IPPPP_MPHEADER_LAST_FRAGMENT)
|
|
#define IPPPP_MPFRAGMENT_ISONLY(xflag) (((xflag) & IPPPP_MPHEADER_ONLY_FRAGMENT) == IPPPP_MPHEADER_ONLY_FRAGMENT)
|
|
|
|
#define IPPPP_MPFRAGMENT_COMPLETE(xflag) (((xflag) & IPPPP_PPPIF_FLAG_HAVE_FIRST_FRAG) && ((xflag) & IPPPP_PPPIF_ML_HAVE_LAST_FRAG))
|
|
|
|
/* Fragements types: must be ine of the following: */
|
|
#define IPPPP_MPFRAGMENT_FIRST 1
|
|
#define IPPPP_MPFRAGMENT_LAST 2
|
|
#define IPPPP_MPFRAGMENT_ONLY 3
|
|
#define IPPPP_MPFRAGMENT_MIDSTREAM 4
|
|
|
|
/* Flags for the pkt fragment structure */
|
|
#define IPPPP_PPPMP_BEGFRAG_RCVD 0x00000001 /* */
|
|
#define IPPPP_PPPMP_ENDFRAG_RCVD 0x00000002 /* */
|
|
|
|
typedef struct Ipppp_pppmp_pkt_frags_struct
|
|
{
|
|
Ipcom_pkt * frags[IPPPP_PPPMP_MAX_FRAGMENTS*2];
|
|
Ip_u32 flags[IPPPP_PPPMP_MAX_FRAGMENTS*2];
|
|
}
|
|
Ipppp_pppmp_pkt_frags;
|
|
|
|
#endif /* IPPPP_USE_PPPMP */
|
|
|
|
#ifdef IPPPP_USE_VJCOMP
|
|
#define IPPPP_LINKFLAG_DONTNEG_VJCOMP 0x00008000 /* IPCP */
|
|
|
|
/* The following definitions match values defined locally to rfc1144,
|
|
* for indicating to uncompress the packet type. Do not change
|
|
* these values.
|
|
*/
|
|
#define IPPPP_VJCOMP_PKT_TYPE_ERROR 0x00
|
|
#define IPPPP_VJCOMP_PKT_TYPE_COMPR_TCP 0x80
|
|
#define IPPPP_VJCOMP_PKT_TYPE_UNCOMPR_TCP 0x70
|
|
|
|
#endif /* IPPPP_USE_VJCOMP */
|
|
|
|
/*
|
|
*===========================================================================
|
|
* Ipppp_link
|
|
*===========================================================================
|
|
*/
|
|
typedef struct Ipppp_link_struct
|
|
{
|
|
Ip_u32 link_index; /* Link index. */
|
|
Ip_u32 ppp_flags; /* PPP flags, see ipppp.h. */
|
|
Ipppp_action_cb action_cb;
|
|
|
|
/***** PPP CONFIGURATION *****/
|
|
Ipcom_ppp_conf ppp;
|
|
|
|
/***** AUTH CONFIGURATION *****/
|
|
#ifdef IPPPP_USE_AUTH
|
|
char local_username[IPCOM_AUTH_USERNAME_MAX];
|
|
char local_password[IPCOM_AUTH_PASSWORD_MAX];
|
|
#endif
|
|
|
|
/***** PPP DRIVER CONFIGURATION *****/
|
|
Ipcom_ppp_drvconf def_drv; /* Default driver configuration. */
|
|
Ipcom_ppp_drvconf drv;
|
|
|
|
/***** INTERNAL DATA *****/
|
|
Ipppp_link_data data; /* Data, cleared for each new conn. */
|
|
|
|
/* LINK, LCP, PAP/CHAP, IPCP and IPV6CP */
|
|
Ipppp_phase phases[IPPPP_PHASE_MAX];
|
|
|
|
#ifdef IPPPP_USE_PPPMP
|
|
Ipcom_netif *bundle_netif;
|
|
Ipcom_netif *member_netif;
|
|
int bundle_link_index;
|
|
int member_link_index;
|
|
#endif /* IPPPP_USE_PPPMP */
|
|
}
|
|
Ipppp_link;
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* Ipppp_netif_data
|
|
*===========================================================================
|
|
* Session temporary PPP interface data.
|
|
*/
|
|
typedef struct Ipppp_netif_data_struct
|
|
{
|
|
#ifdef IPNET_USE_AUTH
|
|
struct Ipppp_netif_auth_data_struct
|
|
{
|
|
|
|
} auth;
|
|
#endif
|
|
|
|
struct Ipppp_netif_lcp_data_struct
|
|
{
|
|
#ifdef IPCOM_USE_AUTH_RADIUS
|
|
Ip_u32 radius_framed_ip_address;
|
|
#ifdef IPPPP_NOTYET
|
|
Ip_u32 radius_framed_ip_netmask;
|
|
#endif
|
|
#else
|
|
Ip_u32 dummy;
|
|
#endif
|
|
} lcp;
|
|
|
|
#ifdef IPCOM_USE_INET
|
|
struct Ipppp_netif_ipcp_data_struct
|
|
{
|
|
int status; /* -1 disabled, 0 enabled but down, 1 up. */
|
|
Ip_u32 local_addr_n;
|
|
Ip_u32 peer_addr_n;
|
|
} ipcp;
|
|
#endif
|
|
|
|
#ifdef IPCOM_USE_INET6
|
|
struct Ipppp_netif_ipv6cp_data_struct
|
|
{
|
|
int status; /* -1 disabled, 0 enabled but down, 1 up. */
|
|
struct Ip_in6_addr local_addr;
|
|
struct Ip_in6_addr peer_addr;
|
|
} ipv6cp;
|
|
|
|
/* RFC 2472/5072 requires tracking of two consecutive Configure-Requests to see if the
|
|
* Interface-Identifier option is present or not.
|
|
*/
|
|
Ip_bool no_inf_id_opt; /* IP_TRUE if no Interface-Identifier option is present, IP_FALSE otherwise */
|
|
#endif
|
|
|
|
#ifdef IPPPP_USE_PPPMP
|
|
struct Ipppp_netif_mp_data_struct
|
|
{
|
|
Ipppp_pppmp_pkt_frags *pkt_frags;
|
|
|
|
int mp_links; /* Requested number of links in bundle */
|
|
int open_links; /* Number of actual links currently open */
|
|
int member_links; /* Links that are bundled on a different netif */
|
|
int current_link; /* Index of last link sent to */
|
|
int min_mtu; /* Lowest MTU of all open links */
|
|
|
|
Ip_u32 send_seqnum;
|
|
|
|
Ip_u16 local_mrru; /* Largest reconstructed packet I can receive */
|
|
Ip_u16 peer_mrru; /* Largest reconstructed packet the peer can receive */
|
|
Ip_u8 ssn; /* Short Sequence Number option negotiation proposed (1) or not (0)*/
|
|
Ip_u8 frag_disable; /* Disable(1) / Enable (0) PPP MP PDU Fragmentation */
|
|
|
|
Ip_u8 local_epd_data[IPPPPMP_EPD_DATA_MAX]; /* Default 20 (from RFC 1990) */
|
|
Ip_u8 peer_epd_data[IPPPPMP_EPD_DATA_MAX];
|
|
|
|
Ip_u8 local_epd_class;
|
|
Ip_u8 local_epd_datalen;
|
|
|
|
Ip_u8 peer_epd_class;
|
|
Ip_u8 peer_epd_datalen;
|
|
#ifdef IPPPP_PPPMP_FRAGMENT_TIMER
|
|
Ipcom_list tmo_list;
|
|
Ipcom_once_t tmo_list_once;
|
|
#endif
|
|
} mp;
|
|
#endif /* IPPPP_USE_PPPMP */
|
|
}
|
|
Ipppp_netif_data;
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* Ipppp_netif
|
|
*===========================================================================
|
|
*/
|
|
typedef struct Ipppp_netif_struct
|
|
{
|
|
int pppflags;
|
|
int num_ncp_up;
|
|
int num_ncp_open;
|
|
|
|
Ipppp_netif_data data; /* Data, cleared for each new conn. */
|
|
|
|
#ifdef IPCOM_USE_INET
|
|
int inet_up;
|
|
Ip_u32 ipcp_conf_local_addr_n; /* Default local IPv4 address. */
|
|
Ip_u32 ipcp_conf_peer_addr_n; /* Default peer IPv4 address. */
|
|
#endif
|
|
|
|
#ifdef IPCOM_USE_INET6
|
|
int inet6_up;
|
|
#endif
|
|
|
|
#ifdef IPPPP_USE_PPPOE
|
|
Ip_u32 pppoe_eth_ifindex;
|
|
Ip_u16 pppoe_peer_session_id_n;
|
|
Ip_u8 pppoe_peer_eth_addr[6];
|
|
#endif
|
|
|
|
Ipppp_link link[IPPPP_MAX_LINKS];
|
|
}
|
|
Ipppp_netif;
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* Ipppp_stats
|
|
*===========================================================================
|
|
* IPPPP debug statistics useful for debugging the stack if things go wrong.
|
|
*/
|
|
#if defined(IP_DEBUG) || defined(IPPPP_STATISTICS)
|
|
typedef struct Ipppp_stats_struct
|
|
{
|
|
int input;
|
|
int input_discard;
|
|
int input_err_notrunning;
|
|
int input_err_linkdown;
|
|
int input_err_short;
|
|
int input_err_long;
|
|
int input_err_noctrl;
|
|
int input_err_badfcs;
|
|
int input_err_esc_enomem;
|
|
int input_err_truncated;
|
|
int input_err_noproto;
|
|
int input_err_lcp;
|
|
int input_err_ipcp;
|
|
int input_err_ipv6cp;
|
|
int input_err_chap;
|
|
int input_err_pap;
|
|
int input_lcpdown;
|
|
int input_ipcpdown;
|
|
int input_ipv6cpdown;
|
|
int input_authdown;
|
|
|
|
Ip_u32 ipv4_out_discard_small;
|
|
Ip_u32 ipv4_out_discard_down;
|
|
|
|
Ip_u32 ipv6_out_discard_small;
|
|
Ip_u32 ipv6_out_discard_down;
|
|
|
|
Ip_u32 outputd_discard_linkdown;
|
|
Ip_u32 outputd_discard_netifdown;
|
|
Ip_u32 outputd_discard_drvfail;
|
|
}
|
|
Ipppp_stats;
|
|
|
|
#define IPPPP_STATS(xvar) ipppp.stats.xvar
|
|
#else
|
|
#define IPPPP_STATS(xvar) IP_NOOP
|
|
#endif
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* Ipppp_pppoe_data
|
|
*===========================================================================
|
|
*/
|
|
|
|
/* Secret size. */
|
|
#define IPPPP_PPPOE_SECRET_SIZE 16
|
|
|
|
typedef struct Ipppp_pppoe_data_struct
|
|
{
|
|
int num_sessions;
|
|
|
|
#ifdef IPPPP_PPPOE_USE_MD5
|
|
Ip_u8 secret[IPPPP_PPPOE_SECRET_SIZE];
|
|
Ip_u8 gen_cookie[MD5_DIGEST_LENGTH];
|
|
#endif
|
|
}
|
|
Ipppp_pppoe_data;
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* Ippp_data
|
|
*===========================================================================
|
|
*/
|
|
typedef struct Ipppp_data_struct
|
|
{
|
|
Ip_u8 zero[8];
|
|
|
|
Ip_u32 xticks_per_sec;
|
|
Ip_u32 xseconds;
|
|
|
|
Ip_u16 name_index;
|
|
Ip_u16 pad;
|
|
|
|
#ifdef IPPPP_USE_PPPOE
|
|
Ipppp_pppoe_data pppoe;
|
|
#endif
|
|
|
|
#if defined(IP_DEBUG) || defined(IPPPP_STATISTICS)
|
|
Ipppp_stats stats;
|
|
#endif
|
|
|
|
char buf[128];
|
|
|
|
#ifdef IPPPP_USE_PPPMP
|
|
Ip_u8 epd_data[IPPPPMP_EPD_DATA_MAX]; /* Default 20 (from RFC 1990) */
|
|
Ip_u8 epd_class;
|
|
Ip_u8 epd_datalen;
|
|
#endif
|
|
|
|
}
|
|
Ipppp_data;
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 7 FUNCTION PROTOTYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
IP_GLOBAL void ipppp_lock(void);
|
|
IP_GLOBAL void ipppp_unlock(void);
|
|
|
|
IP_GLOBAL int
|
|
ipppp_pppoe_input(Ipcom_netif *ethif, Ipcom_pkt *pkt);
|
|
|
|
IP_GLOBAL int
|
|
ipppp_pppoe_create(struct Ip_ifreq *ifreq);
|
|
|
|
IP_GLOBAL void
|
|
ipppp_log(Ip_u32 prio, Ipcom_netif *netif, Ipppp_phase *phase, const char *format, ...);
|
|
|
|
IP_GLOBAL Ipcom_pkt *ipppp_pkt_malloc(Ip_u8 code, Ip_u8 id, Ipppp_phase *phase);
|
|
IP_GLOBAL int ipppp_prot_input(Ipcom_netif *netif, Ipcom_pkt *pkt, Ipppp_link *link, Ipppp_phase *phase);
|
|
#ifdef IPPPP_USE_AUTH_CHAP
|
|
IP_GLOBAL int ipppp_chap_input(Ipcom_netif *netif, Ipcom_pkt *pkt, Ipppp_link *link, Ipppp_phase *phase);
|
|
#endif
|
|
#ifdef IPPPP_USE_AUTH_PAP
|
|
IP_GLOBAL int ipppp_pap_input(Ipcom_netif *netif, Ipcom_pkt *pkt, Ipppp_link *link, Ipppp_phase *phase);
|
|
#endif
|
|
IP_GLOBAL int ipppp_output(Ipcom_netif *netif, Ipcom_pkt *pkt, Ipppp_link *link);
|
|
IP_GLOBAL int ipppp_event_open(Ipcom_netif *netif, Ipppp_link *link, Ipppp_phase *phase);
|
|
IP_GLOBAL void ipppp_event_close(Ipcom_netif *netif, Ipppp_link *link, Ipppp_phase *phase);
|
|
IP_GLOBAL void ipppp_drv_wincompat(Ipcom_netif *netif, Ipppp_link *link, int enable);
|
|
IP_GLOBAL void ipppp_action_lcp_close(Ipcom_netif *netif, Ipppp_link *link);
|
|
#ifdef IPPPP_USE_PPPMP
|
|
IP_GLOBAL void ipppp_pppmp_ifclean(Ipcom_netif *netif);
|
|
IP_GLOBAL void ipppp_pppmp_epd_init (Ip_u8 *epd_class, Ip_u8 *epd_data, Ip_u8 *epd_datalen);
|
|
IP_GLOBAL int ipppp_pppmp_open(Ipcom_netif *netif, int link_index);
|
|
IP_GLOBAL int ipppp_pppmp_link_add(Ipcom_netif *netif, Ipppp_link *link);
|
|
IP_GLOBAL void ipppp_pppmp_link_clear(Ipcom_netif *netif, Ipppp_link *link);
|
|
IP_GLOBAL int ipppp_pppmp_link_remove(Ipcom_netif *netif, Ipppp_link *link);
|
|
IP_GLOBAL int ipppp_pppmp_input(Ipcom_netif *netif, Ipcom_pkt *pkt);
|
|
IP_GLOBAL int ipppp_pppmp_output(Ipcom_netif *netif, Ipcom_pkt *pkt, Ipppp_link *link, Ip_u16 protocol);
|
|
#endif /* IPPPP_USE_PPPMP */
|
|
IP_GLOBAL void ipppp_action_irc(Ipcom_netif *netif, Ipppp_phase *phase, int type);
|
|
IP_GLOBAL void ipppp_termreq_output(Ipcom_netif *netif, Ipppp_phase *phase, Ipppp_link *link);
|
|
|
|
#ifdef IPPPP_USE_VJCOMP
|
|
IP_GLOBAL void *ipppp_vjcomp_init (void **comp_cookie);
|
|
IP_GLOBAL int ipppp_vjcomp_compress (Ipcom_pkt * pkt, void *comp_cookie);
|
|
IP_GLOBAL Ip_u8 *ipppp_vjcomp_uncompress (Ipcom_pkt **pkt, void *comp_cookie, int type);
|
|
#endif /* IPPPP_USE_VJCOMP */
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
|
|
/*
|
|
****************************************************************************
|
|
* END OF FILE
|
|
****************************************************************************
|
|
*/
|