1999-10-21 09:06:11 +00:00
|
|
|
/*
|
|
|
|
* ng_pppoe.h
|
2005-01-07 01:45:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*-
|
1999-10-21 09:06:11 +00:00
|
|
|
* Copyright (c) 1996-1999 Whistle Communications, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Subject to the following obligations and disclaimer of warranty, use and
|
|
|
|
* redistribution of this software, in source or object code forms, with or
|
|
|
|
* without modifications are expressly permitted by Whistle Communications;
|
|
|
|
* provided, however, that:
|
|
|
|
* 1. Any and all reproductions of the source or object code must include the
|
|
|
|
* copyright notice above and the following disclaimer of warranties; and
|
|
|
|
* 2. No rights are granted, in any manner or form, to use Whistle
|
|
|
|
* Communications, Inc. trademarks, including the mark "WHISTLE
|
|
|
|
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
|
|
|
* such appears in the above copyright notice or in the software.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
|
|
|
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
|
|
|
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
|
|
|
* INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
|
|
|
* WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
|
|
|
* REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
|
|
|
* SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
|
|
|
* IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
|
|
|
* RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
|
|
|
* WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
|
|
|
* PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
|
|
|
* OF SUCH DAMAGE.
|
|
|
|
*
|
2000-10-24 17:32:45 +00:00
|
|
|
* Author: Julian Elischer <julian@freebsd.org>
|
1999-10-21 09:06:11 +00:00
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
* $Whistle: ng_pppoe.h,v 1.7 1999/10/16 10:16:43 julian Exp $
|
|
|
|
*/
|
|
|
|
|
2003-11-11 12:30:37 +00:00
|
|
|
#ifndef _NETGRAPH_NG_PPPOE_H_
|
|
|
|
#define _NETGRAPH_NG_PPPOE_H_
|
1999-10-21 09:06:11 +00:00
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* Netgraph hook constants etc.
|
|
|
|
********************************************************************/
|
|
|
|
/* Node type name. This should be unique among all netgraph node types */
|
1999-10-27 11:29:51 +00:00
|
|
|
#define NG_PPPOE_NODE_TYPE "pppoe"
|
1999-10-21 09:06:11 +00:00
|
|
|
|
2004-07-27 19:47:13 +00:00
|
|
|
#define NGM_PPPOE_COOKIE 1089893072
|
1999-10-21 09:06:11 +00:00
|
|
|
|
|
|
|
#define PPPOE_SERVICE_NAME_SIZE 64 /* for now */
|
|
|
|
|
|
|
|
/* Hook names */
|
|
|
|
#define NG_PPPOE_HOOK_ETHERNET "ethernet"
|
|
|
|
#define NG_PPPOE_HOOK_DEBUG "debug"
|
|
|
|
|
2004-07-27 19:47:13 +00:00
|
|
|
/* Mode names */
|
|
|
|
#define NG_PPPOE_STANDARD "standard"
|
2006-01-27 10:56:22 +00:00
|
|
|
#define NG_PPPOE_3COM "3Com"
|
|
|
|
#define NG_PPPOE_NONSTANDARD NG_PPPOE_3COM
|
|
|
|
#define NG_PPPOE_DLINK "D-Link"
|
2004-07-27 19:47:13 +00:00
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* Netgraph commands understood by this node type.
|
2002-02-20 15:51:11 +00:00
|
|
|
* FAIL, SUCCESS, CLOSE and ACNAME are sent by the node rather than received.
|
1999-10-21 09:06:11 +00:00
|
|
|
********************************************************************/
|
1999-10-23 04:28:11 +00:00
|
|
|
enum cmd {
|
1999-10-21 09:06:11 +00:00
|
|
|
NGM_PPPOE_SET_FLAG = 1,
|
|
|
|
NGM_PPPOE_CONNECT = 2, /* Client, Try find this service */
|
|
|
|
NGM_PPPOE_LISTEN = 3, /* Server, Await a request for this service */
|
|
|
|
NGM_PPPOE_OFFER = 4, /* Server, hook X should respond (*) */
|
|
|
|
NGM_PPPOE_SUCCESS = 5, /* State machine connected */
|
|
|
|
NGM_PPPOE_FAIL = 6, /* State machine could not connect */
|
|
|
|
NGM_PPPOE_CLOSE = 7, /* Session closed down */
|
2000-12-12 22:35:36 +00:00
|
|
|
NGM_PPPOE_SERVICE = 8, /* additional Service to advertise (in PADO) */
|
2002-02-20 15:51:11 +00:00
|
|
|
NGM_PPPOE_ACNAME = 9, /* AC_NAME for informational purposes */
|
2002-05-14 12:32:41 +00:00
|
|
|
NGM_PPPOE_GET_STATUS = 10, /* data in/out */
|
2004-07-27 19:47:13 +00:00
|
|
|
NGM_PPPOE_SESSIONID = 11, /* Session_ID for informational purposes */
|
2006-08-09 09:56:58 +00:00
|
|
|
NGM_PPPOE_SETMODE = 12, /* set to standard or compat modes */
|
2004-07-27 19:47:13 +00:00
|
|
|
NGM_PPPOE_GETMODE = 13, /* see current mode */
|
2006-08-09 09:56:58 +00:00
|
|
|
NGM_PPPOE_SETENADDR = 14, /* set Ethernet address */
|
1999-10-21 09:06:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/***********************
|
|
|
|
* Structures passed in the various netgraph command messages.
|
|
|
|
***********************/
|
|
|
|
/* This structure is returned by the NGM_PPPOE_GET_STATUS command */
|
1999-10-27 11:29:51 +00:00
|
|
|
struct ngpppoestat {
|
1999-11-01 00:31:14 +00:00
|
|
|
u_int packets_in; /* packets in from ethernet */
|
|
|
|
u_int packets_out; /* packets out towards ethernet */
|
1999-10-21 09:06:11 +00:00
|
|
|
};
|
|
|
|
|
2000-10-31 02:45:24 +00:00
|
|
|
/* Keep this in sync with the above structure definition */
|
|
|
|
#define NG_PPPOESTAT_TYPE_INFO { \
|
|
|
|
{ "packets_in", &ng_parse_uint_type }, \
|
|
|
|
{ "packets_out", &ng_parse_uint_type }, \
|
|
|
|
{ NULL } \
|
|
|
|
}
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
/*
|
|
|
|
* When this structure is accepted by the NGM_PPPOE_CONNECT command :
|
|
|
|
* The data field is MANDATORY.
|
|
|
|
* The session sends out a PADI request for the named service.
|
|
|
|
*
|
|
|
|
*
|
2000-12-12 22:35:36 +00:00
|
|
|
* When this structure is accepted by the NGM_PPPOE_LISTEN command.
|
1999-10-21 09:06:11 +00:00
|
|
|
* If no service is given this is assumed to accept ALL PADI requests.
|
1999-11-09 00:31:04 +00:00
|
|
|
* This may at some time take a regexp expression, but not yet.
|
1999-10-21 09:06:11 +00:00
|
|
|
* Matching PADI requests will be passed up the named hook.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* When this structure is accepted by the NGM_PPPOE_OFFER command:
|
|
|
|
* The AC-NAme field is set from that given and a PADI
|
|
|
|
* packet is expected to arrive from the session control daemon, on the
|
|
|
|
* named hook. The session will then issue the appropriate PADO
|
|
|
|
* and begin negotiation.
|
|
|
|
*/
|
1999-10-27 11:29:51 +00:00
|
|
|
struct ngpppoe_init_data {
|
2004-01-26 14:05:31 +00:00
|
|
|
char hook[NG_HOOKSIZ]; /* hook to monitor on */
|
2000-11-16 23:14:53 +00:00
|
|
|
u_int16_t data_len; /* Length of the service name */
|
2005-10-28 14:41:28 +00:00
|
|
|
char data[]; /* init data goes here */
|
1999-10-21 09:06:11 +00:00
|
|
|
};
|
|
|
|
|
2000-10-31 02:45:24 +00:00
|
|
|
/* Keep this in sync with the above structure definition */
|
|
|
|
#define NG_PPPOE_INIT_DATA_TYPE_INFO { \
|
|
|
|
{ "hook", &ng_parse_hookbuf_type }, \
|
2000-11-16 23:14:53 +00:00
|
|
|
{ "data", &ng_parse_sizedstring_type }, \
|
2000-10-31 02:45:24 +00:00
|
|
|
{ NULL } \
|
|
|
|
}
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
/*
|
|
|
|
* This structure is used by the asychronous success and failure messages.
|
|
|
|
* (to report which hook has failed or connected). The message is sent
|
|
|
|
* to whoever requested the connection. (close may use this too).
|
|
|
|
*/
|
1999-10-27 11:29:51 +00:00
|
|
|
struct ngpppoe_sts {
|
2004-01-26 14:05:31 +00:00
|
|
|
char hook[NG_HOOKSIZ]; /* hook associated with event session */
|
1999-10-21 09:06:11 +00:00
|
|
|
};
|
|
|
|
|
2000-10-31 02:45:24 +00:00
|
|
|
/* Keep this in sync with the above structure definition */
|
|
|
|
#define NG_PPPOE_STS_TYPE_INFO { \
|
|
|
|
{ "hook", &ng_parse_hookbuf_type }, \
|
|
|
|
{ NULL } \
|
|
|
|
}
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
|
|
|
|
/********************************************************************
|
1999-10-27 11:29:51 +00:00
|
|
|
* Constants and definitions specific to pppoe
|
1999-10-21 09:06:11 +00:00
|
|
|
********************************************************************/
|
|
|
|
|
|
|
|
#define PPPOE_TIMEOUT_LIMIT 64
|
|
|
|
#define PPPOE_OFFER_TIMEOUT 16
|
1999-12-01 08:05:56 +00:00
|
|
|
#define PPPOE_INITIAL_TIMEOUT 2
|
1999-10-21 09:06:11 +00:00
|
|
|
|
|
|
|
/* Codes to identify message types */
|
|
|
|
#define PADI_CODE 0x09
|
|
|
|
#define PADO_CODE 0x07
|
|
|
|
#define PADR_CODE 0x19
|
|
|
|
#define PADS_CODE 0x65
|
|
|
|
#define PADT_CODE 0xa7
|
|
|
|
|
|
|
|
/* Tag identifiers */
|
|
|
|
#if BYTE_ORDER == BIG_ENDIAN
|
|
|
|
#define PTT_EOL (0x0000)
|
|
|
|
#define PTT_SRV_NAME (0x0101)
|
|
|
|
#define PTT_AC_NAME (0x0102)
|
|
|
|
#define PTT_HOST_UNIQ (0x0103)
|
|
|
|
#define PTT_AC_COOKIE (0x0104)
|
|
|
|
#define PTT_VENDOR (0x0105)
|
2004-03-18 12:34:14 +00:00
|
|
|
#define PTT_RELAY_SID (0x0110)
|
1999-10-21 09:06:11 +00:00
|
|
|
#define PTT_SRV_ERR (0x0201)
|
|
|
|
#define PTT_SYS_ERR (0x0202)
|
|
|
|
#define PTT_GEN_ERR (0x0203)
|
|
|
|
|
1999-10-27 11:29:51 +00:00
|
|
|
#define ETHERTYPE_PPPOE_DISC 0x8863 /* pppoe discovery packets */
|
|
|
|
#define ETHERTYPE_PPPOE_SESS 0x8864 /* pppoe session packets */
|
2006-01-27 10:56:22 +00:00
|
|
|
#define ETHERTYPE_PPPOE_3COM_DISC 0x3c12 /* pppoe discovery packets 3com? */
|
|
|
|
#define ETHERTYPE_PPPOE_3COM_SESS 0x3c13 /* pppoe session packets 3com? */
|
1999-10-21 09:06:11 +00:00
|
|
|
#else
|
|
|
|
#define PTT_EOL (0x0000)
|
|
|
|
#define PTT_SRV_NAME (0x0101)
|
|
|
|
#define PTT_AC_NAME (0x0201)
|
|
|
|
#define PTT_HOST_UNIQ (0x0301)
|
|
|
|
#define PTT_AC_COOKIE (0x0401)
|
|
|
|
#define PTT_VENDOR (0x0501)
|
2004-03-18 12:34:14 +00:00
|
|
|
#define PTT_RELAY_SID (0x1001)
|
1999-10-21 09:06:11 +00:00
|
|
|
#define PTT_SRV_ERR (0x0102)
|
|
|
|
#define PTT_SYS_ERR (0x0202)
|
|
|
|
#define PTT_GEN_ERR (0x0302)
|
|
|
|
|
1999-10-27 11:29:51 +00:00
|
|
|
#define ETHERTYPE_PPPOE_DISC 0x6388 /* pppoe discovery packets */
|
|
|
|
#define ETHERTYPE_PPPOE_SESS 0x6488 /* pppoe session packets */
|
2006-01-27 10:56:22 +00:00
|
|
|
#define ETHERTYPE_PPPOE_3COM_DISC 0x123c /* pppoe discovery packets 3com? */
|
|
|
|
#define ETHERTYPE_PPPOE_3COM_SESS 0x133c /* pppoe session packets 3com? */
|
1999-10-21 09:06:11 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
struct pppoe_tag {
|
|
|
|
u_int16_t tag_type;
|
|
|
|
u_int16_t tag_len;
|
2005-10-28 14:41:28 +00:00
|
|
|
char tag_data[];
|
2002-09-23 18:54:32 +00:00
|
|
|
}__packed;
|
1999-10-21 09:06:11 +00:00
|
|
|
|
|
|
|
struct pppoe_hdr{
|
|
|
|
u_int8_t ver:4;
|
|
|
|
u_int8_t type:4;
|
|
|
|
u_int8_t code;
|
|
|
|
u_int16_t sid;
|
|
|
|
u_int16_t length;
|
2005-10-28 14:41:28 +00:00
|
|
|
struct pppoe_tag tag[];
|
2002-09-23 18:54:32 +00:00
|
|
|
}__packed;
|
1999-10-21 09:06:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
struct pppoe_full_hdr {
|
|
|
|
struct ether_header eh;
|
|
|
|
struct pppoe_hdr ph;
|
2002-09-23 18:54:32 +00:00
|
|
|
}__packed;
|
1999-10-21 09:06:11 +00:00
|
|
|
|
|
|
|
union packet {
|
|
|
|
struct pppoe_full_hdr pkt_header;
|
|
|
|
u_int8_t bytes[2048];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct datatag {
|
|
|
|
struct pppoe_tag hdr;
|
|
|
|
u_int8_t data[PPPOE_SERVICE_NAME_SIZE];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Define the order in which we will place tags in packets
|
|
|
|
* this may be ignored
|
|
|
|
*/
|
|
|
|
/* for PADI */
|
|
|
|
#define TAGI_SVC 0
|
|
|
|
#define TAGI_HUNIQ 1
|
|
|
|
/* for PADO */
|
|
|
|
#define TAGO_ACNAME 0
|
|
|
|
#define TAGO_SVC 1
|
|
|
|
#define TAGO_COOKIE 2
|
|
|
|
#define TAGO_HUNIQ 3
|
|
|
|
/* for PADR */
|
|
|
|
#define TAGR_SVC 0
|
|
|
|
#define TAGR_HUNIQ 1
|
|
|
|
#define TAGR_COOKIE 2
|
|
|
|
/* for PADS */
|
|
|
|
#define TAGS_ACNAME 0
|
|
|
|
#define TAGS_SVC 1
|
|
|
|
#define TAGS_COOKIE 2
|
|
|
|
#define TAGS_HUNIQ 3
|
|
|
|
/* for PADT */
|
|
|
|
|
2003-11-11 12:30:37 +00:00
|
|
|
#endif /* _NETGRAPH_NG_PPPOE_H_ */
|
1999-10-21 09:06:11 +00:00
|
|
|
|