ng_pppoe.h revision 69934
150477Speter 2139749Simp/* 3196008Smjacob * ng_pppoe.h 4167403Smjacob * 5167403Smjacob * Copyright (c) 1996-1999 Whistle Communications, Inc. 6167403Smjacob * All rights reserved. 7167403Smjacob * 8167403Smjacob * Subject to the following obligations and disclaimer of warranty, use and 9167403Smjacob * redistribution of this software, in source or object code forms, with or 10167403Smjacob * without modifications are expressly permitted by Whistle Communications; 11167403Smjacob * provided, however, that: 12167403Smjacob * 1. Any and all reproductions of the source or object code must include the 13167403Smjacob * copyright notice above and the following disclaimer of warranties; and 14167403Smjacob * 2. No rights are granted, in any manner or form, to use Whistle 15167403Smjacob * Communications, Inc. trademarks, including the mark "WHISTLE 16167403Smjacob * COMMUNICATIONS" on advertising, endorsements, or otherwise except as 17167403Smjacob * such appears in the above copyright notice or in the software. 18167403Smjacob * 19167403Smjacob * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND 20167403Smjacob * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO 21167403Smjacob * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE, 22167403Smjacob * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF 23167403Smjacob * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. 24167403Smjacob * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY 25167403Smjacob * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS 26167403Smjacob * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE. 27196008Smjacob * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES 28167403Smjacob * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING 29167403Smjacob * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 3035388Smjacob * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR 3135388Smjacob * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 3235388Smjacob * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3335388Smjacob * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 3435388Smjacob * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY 3535388Smjacob * OF SUCH DAMAGE. 3635388Smjacob * 3735388Smjacob * Author: Julian Elischer <julian@freebsd.org> 3835388Smjacob * 3935388Smjacob * $FreeBSD: head/sys/netgraph/ng_pppoe.h 69934 2000-12-12 22:35:36Z julian $ 4035388Smjacob * $Whistle: ng_pppoe.h,v 1.7 1999/10/16 10:16:43 julian Exp $ 4135388Smjacob */ 4235388Smjacob 4335388Smjacob#ifndef _NETGRAPH_PPPOE_H_ 4435388Smjacob#define _NETGRAPH_PPPOE_H_ 4535388Smjacob 4635388Smjacob/******************************************************************** 4735388Smjacob * Netgraph hook constants etc. 4835388Smjacob ********************************************************************/ 4935388Smjacob/* Node type name. This should be unique among all netgraph node types */ 5035388Smjacob#define NG_PPPOE_NODE_TYPE "pppoe" 5135388Smjacob 5235388Smjacob#define NGM_PPPOE_COOKIE 939032003 5335388Smjacob 5435388Smjacob/* Number of active sessions we can handle */ 5546967Smjacob#define PPPOE_NUM_SESSIONS 16 /* for now */ 5646967Smjacob#define PPPOE_SERVICE_NAME_SIZE 64 /* for now */ 5746967Smjacob 5846967Smjacob/* Hook names */ 5946967Smjacob#define NG_PPPOE_HOOK_ETHERNET "ethernet" 6046967Smjacob#define NG_PPPOE_HOOK_PADI "PADI" /* default PADI requests come here */ 6146967Smjacob#define NG_PPPOE_HOOK_S_LEADIN "service" /* PADO responses from PADI */ 6246967Smjacob#define NG_PPPOE_HOOK_C_LEADIN "client" /* Connect message starts this */ 6335388Smjacob#define NG_PPPOE_HOOK_DEBUG "debug" 6435388Smjacob 6544819Smjacob/********************************************************************** 6635388Smjacob * Netgraph commands understood by this node type. 6744819Smjacob * FAIL, SUCCESS and CLOSE are sent by the node rather than received. 6844819Smjacob ********************************************************************/ 6982689Smjacobenum cmd { 70163899Smjacob NGM_PPPOE_SET_FLAG = 1, 7135388Smjacob NGM_PPPOE_CONNECT = 2, /* Client, Try find this service */ 7235388Smjacob NGM_PPPOE_LISTEN = 3, /* Server, Await a request for this service */ 7344819Smjacob NGM_PPPOE_OFFER = 4, /* Server, hook X should respond (*) */ 7435388Smjacob NGM_PPPOE_SUCCESS = 5, /* State machine connected */ 7535388Smjacob NGM_PPPOE_FAIL = 6, /* State machine could not connect */ 7644819Smjacob NGM_PPPOE_CLOSE = 7, /* Session closed down */ 7735388Smjacob NGM_PPPOE_SERVICE = 8, /* additional Service to advertise (in PADO) */ 7835388Smjacob NGM_PPPOE_GET_STATUS 7944819Smjacob}; 8044819Smjacob 8144819Smjacob/*********************** 8244819Smjacob * Structures passed in the various netgraph command messages. 8364088Smjacob ***********************/ 8464088Smjacob/* This structure is returned by the NGM_PPPOE_GET_STATUS command */ 8564088Smjacobstruct ngpppoestat { 8635388Smjacob u_int packets_in; /* packets in from ethernet */ 8735388Smjacob u_int packets_out; /* packets out towards ethernet */ 8835388Smjacob}; 8935388Smjacob 9035388Smjacob/* Keep this in sync with the above structure definition */ 9144819Smjacob#define NG_PPPOESTAT_TYPE_INFO { \ 9244819Smjacob { \ 9344819Smjacob { "packets_in", &ng_parse_uint_type }, \ 9444819Smjacob { "packets_out", &ng_parse_uint_type }, \ 9544819Smjacob { NULL } \ 9644819Smjacob } \ 9744819Smjacob} 9844819Smjacob 9935388Smjacob/* 10035388Smjacob * When this structure is accepted by the NGM_PPPOE_CONNECT command : 10135388Smjacob * The data field is MANDATORY. 10235388Smjacob * The session sends out a PADI request for the named service. 10344819Smjacob * 10454671Smjacob * 10554671Smjacob * When this structure is accepted by the NGM_PPPOE_LISTEN command. 10654671Smjacob * If no service is given this is assumed to accept ALL PADI requests. 10754671Smjacob * This may at some time take a regexp expression, but not yet. 10854671Smjacob * Matching PADI requests will be passed up the named hook. 10954671Smjacob * 11054671Smjacob * 11154671Smjacob * When this structure is accepted by the NGM_PPPOE_OFFER command: 11254671Smjacob * The AC-NAme field is set from that given and a PADI 11354671Smjacob * packet is expected to arrive from the session control daemon, on the 11454671Smjacob * named hook. The session will then issue the appropriate PADO 11582689Smjacob * and begin negotiation. 11682689Smjacob */ 11782689Smjacobstruct ngpppoe_init_data { 11882689Smjacob char hook[NG_HOOKLEN + 1]; /* hook to monitor on */ 11982689Smjacob u_int16_t data_len; /* Length of the service name */ 12082689Smjacob char data[0]; /* init data goes here */ 12182689Smjacob}; 12282689Smjacob 12382689Smjacob/* Keep this in sync with the above structure definition */ 12482689Smjacob#define NG_PPPOE_INIT_DATA_TYPE_INFO { \ 12582689Smjacob { \ 12682689Smjacob { "hook", &ng_parse_hookbuf_type }, \ 12782689Smjacob { "data", &ng_parse_sizedstring_type }, \ 12882689Smjacob { NULL } \ 12982689Smjacob } \ 13082689Smjacob} 13182689Smjacob 13282689Smjacob/* 13382689Smjacob * This structure is used by the asychronous success and failure messages. 13482689Smjacob * (to report which hook has failed or connected). The message is sent 13582689Smjacob * to whoever requested the connection. (close may use this too). 13682689Smjacob */ 13782689Smjacobstruct ngpppoe_sts { 13882689Smjacob char hook[NG_HOOKLEN + 1]; /* hook associated with event session */ 13982689Smjacob}; 140163899Smjacob 14154671Smjacob/* Keep this in sync with the above structure definition */ 14244819Smjacob#define NG_PPPOE_STS_TYPE_INFO { \ 14354671Smjacob { \ 14444819Smjacob { "hook", &ng_parse_hookbuf_type }, \ 14544819Smjacob { NULL } \ 14644819Smjacob } \ 14744819Smjacob} 14854671Smjacob 14935388Smjacob 15054671Smjacob/******************************************************************** 15154671Smjacob * Constants and definitions specific to pppoe 15254671Smjacob ********************************************************************/ 15354671Smjacob 15454671Smjacob#define PPPOE_TIMEOUT_LIMIT 64 15554671Smjacob#define PPPOE_OFFER_TIMEOUT 16 15654671Smjacob#define PPPOE_INITIAL_TIMEOUT 2 15754671Smjacob 15835388Smjacob/* Codes to identify message types */ 15954671Smjacob#define PADI_CODE 0x09 16035388Smjacob#define PADO_CODE 0x07 16154671Smjacob#define PADR_CODE 0x19 16254671Smjacob#define PADS_CODE 0x65 16354671Smjacob#define PADT_CODE 0xa7 16454671Smjacob 16554671Smjacob/* Tag identifiers */ 16654671Smjacob#if BYTE_ORDER == BIG_ENDIAN 16754671Smjacob#define PTT_EOL (0x0000) 16835388Smjacob#define PTT_SRV_NAME (0x0101) 16954671Smjacob#define PTT_AC_NAME (0x0102) 17054671Smjacob#define PTT_HOST_UNIQ (0x0103) 17135388Smjacob#define PTT_AC_COOKIE (0x0104) 17235388Smjacob#define PTT_VENDOR (0x0105) 17335388Smjacob#define PTT_RELAY_SID (0x0106) 17435388Smjacob#define PTT_SRV_ERR (0x0201) 17535388Smjacob#define PTT_SYS_ERR (0x0202) 17635388Smjacob#define PTT_GEN_ERR (0x0203) 17735388Smjacob 17835388Smjacob#define ETHERTYPE_PPPOE_DISC 0x8863 /* pppoe discovery packets */ 17935388Smjacob#define ETHERTYPE_PPPOE_SESS 0x8864 /* pppoe session packets */ 18035388Smjacob#else 18135388Smjacob#define PTT_EOL (0x0000) 18235388Smjacob#define PTT_SRV_NAME (0x0101) 18335388Smjacob#define PTT_AC_NAME (0x0201) 18435388Smjacob#define PTT_HOST_UNIQ (0x0301) 18535388Smjacob#define PTT_AC_COOKIE (0x0401) 18635388Smjacob#define PTT_VENDOR (0x0501) 18735388Smjacob#define PTT_RELAY_SID (0x0601) 18835388Smjacob#define PTT_SRV_ERR (0x0102) 18935388Smjacob#define PTT_SYS_ERR (0x0202) 19035388Smjacob#define PTT_GEN_ERR (0x0302) 19135388Smjacob 19235388Smjacob#define ETHERTYPE_PPPOE_DISC 0x6388 /* pppoe discovery packets */ 19335388Smjacob#define ETHERTYPE_PPPOE_SESS 0x6488 /* pppoe session packets */ 19435388Smjacob#endif 19554671Smjacob 19654671Smjacobstruct pppoe_tag { 19744819Smjacob u_int16_t tag_type; 19844819Smjacob u_int16_t tag_len; 19945040Smjacob char tag_data[0]; 20035388Smjacob}__attribute ((packed)); 20135388Smjacob 20235388Smjacobstruct pppoe_hdr{ 20335388Smjacob u_int8_t ver:4; 20435388Smjacob u_int8_t type:4; 20535388Smjacob u_int8_t code; 206160080Smjacob u_int16_t sid; 207160080Smjacob u_int16_t length; 20835388Smjacob struct pppoe_tag tag[0]; 20935388Smjacob}__attribute__ ((packed)); 21035388Smjacob 21135388Smjacob 21235388Smjacobstruct pppoe_full_hdr { 21335388Smjacob struct ether_header eh; 21435388Smjacob struct pppoe_hdr ph; 21535388Smjacob}__attribute__ ((packed)); 21635388Smjacob 21735388Smjacobunion packet { 21835388Smjacob struct pppoe_full_hdr pkt_header; 21935388Smjacob u_int8_t bytes[2048]; 22035388Smjacob}; 221163899Smjacob 222163899Smjacobstruct datatag { 22335388Smjacob struct pppoe_tag hdr; 22435388Smjacob u_int8_t data[PPPOE_SERVICE_NAME_SIZE]; 22535388Smjacob}; 22635388Smjacob 22735388Smjacob 22835388Smjacob/* 22935388Smjacob * Define the order in which we will place tags in packets 23035388Smjacob * this may be ignored 23135388Smjacob */ 232163899Smjacob/* for PADI */ 23335388Smjacob#define TAGI_SVC 0 23435388Smjacob#define TAGI_HUNIQ 1 23535388Smjacob/* for PADO */ 23635388Smjacob#define TAGO_ACNAME 0 23735388Smjacob#define TAGO_SVC 1 23835388Smjacob#define TAGO_COOKIE 2 23935388Smjacob#define TAGO_HUNIQ 3 24035388Smjacob/* for PADR */ 24135388Smjacob#define TAGR_SVC 0 24235388Smjacob#define TAGR_HUNIQ 1 24335388Smjacob#define TAGR_COOKIE 2 24435388Smjacob/* for PADS */ 24535388Smjacob#define TAGS_ACNAME 0 24635388Smjacob#define TAGS_SVC 1 24735388Smjacob#define TAGS_COOKIE 2 24835388Smjacob#define TAGS_HUNIQ 3 249163899Smjacob/* for PADT */ 250163899Smjacob 251163899Smjacob#endif /* _NETGRAPH_PPPOE_H_ */ 252163899Smjacob 25335388Smjacob