ng_pppoe.h revision 52562
1100894Srwatson 2100894Srwatson/* 3100894Srwatson * ng_pppoe.h 4100894Srwatson * 5100894Srwatson * Copyright (c) 1996-1999 Whistle Communications, Inc. 6100894Srwatson * All rights reserved. 7100894Srwatson * 8100894Srwatson * Subject to the following obligations and disclaimer of warranty, use and 9100894Srwatson * redistribution of this software, in source or object code forms, with or 10106392Srwatson * without modifications are expressly permitted by Whistle Communications; 11106392Srwatson * provided, however, that: 12106392Srwatson * 1. Any and all reproductions of the source or object code must include the 13106392Srwatson * copyright notice above and the following disclaimer of warranties; and 14100894Srwatson * 2. No rights are granted, in any manner or form, to use Whistle 15100894Srwatson * Communications, Inc. trademarks, including the mark "WHISTLE 16100894Srwatson * COMMUNICATIONS" on advertising, endorsements, or otherwise except as 17100894Srwatson * such appears in the above copyright notice or in the software. 18100894Srwatson * 19100894Srwatson * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND 20100894Srwatson * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO 21100894Srwatson * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE, 22100894Srwatson * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF 23100894Srwatson * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. 24100894Srwatson * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY 25100894Srwatson * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS 26100894Srwatson * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE. 27100894Srwatson * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES 28100894Srwatson * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING 29100894Srwatson * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 30100894Srwatson * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR 31100894Srwatson * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 32100894Srwatson * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33100894Srwatson * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34100894Srwatson * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY 35100894Srwatson * OF SUCH DAMAGE. 36100894Srwatson * 37100894Srwatson * Author: Julian Elischer <julian@whistle.com> 38100894Srwatson * 39100894Srwatson * $FreeBSD: head/sys/netgraph/ng_pppoe.h 52562 1999-10-27 11:29:51Z julian $ 40100894Srwatson * $Whistle: ng_pppoe.h,v 1.7 1999/10/16 10:16:43 julian Exp $ 41100894Srwatson */ 42100894Srwatson 43100894Srwatson#ifndef _NETGRAPH_PPPOE_H_ 44100894Srwatson#define _NETGRAPH_PPPOE_H_ 45100894Srwatson 46104300Sphk/******************************************************************** 47101173Srwatson * Netgraph hook constants etc. 48100894Srwatson ********************************************************************/ 49106856Srwatson/* Node type name. This should be unique among all netgraph node types */ 50100979Srwatson#define NG_PPPOE_NODE_TYPE "pppoe" 51106468Srwatson 52100979Srwatson#define NGM_PPPOE_COOKIE 939032003 53100979Srwatson 54102949Sbde/* Number of active sessions we can handle */ 55100979Srwatson#define PPPOE_NUM_SESSIONS 16 /* for now */ 56100979Srwatson#define PPPOE_SERVICE_NAME_SIZE 64 /* for now */ 57101712Srwatson 58100979Srwatson/* Hook names */ 59100979Srwatson#define NG_PPPOE_HOOK_ETHERNET "ethernet" 60100894Srwatson#define NG_PPPOE_HOOK_PADI "PADI" /* default PADI requests come here */ 61100894Srwatson#define NG_PPPOE_HOOK_S_LEADIN "service" /* PADO responses from PADI */ 62100979Srwatson#define NG_PPPOE_HOOK_C_LEADIN "client" /* Connect message starts this */ 63100979Srwatson#define NG_PPPOE_HOOK_DEBUG "debug" 64100979Srwatson 65100979Srwatson/********************************************************************** 66100979Srwatson * Netgraph commands understood by this node type. 67100979Srwatson * FAIL, SUCCESS and CLOSE are sent by the node rather than received. 68100979Srwatson ********************************************************************/ 69100979Srwatsonenum cmd { 70100894Srwatson NGM_PPPOE_SET_FLAG = 1, 71100979Srwatson NGM_PPPOE_CONNECT = 2, /* Client, Try find this service */ 72100979Srwatson NGM_PPPOE_LISTEN = 3, /* Server, Await a request for this service */ 73100979Srwatson NGM_PPPOE_OFFER = 4, /* Server, hook X should respond (*) */ 74100979Srwatson NGM_PPPOE_SUCCESS = 5, /* State machine connected */ 75100979Srwatson NGM_PPPOE_FAIL = 6, /* State machine could not connect */ 76100979Srwatson NGM_PPPOE_CLOSE = 7, /* Session closed down */ 77100979Srwatson NGM_PPPOE_GET_STATUS 78100979Srwatson}; 79100979Srwatson 80100979Srwatson/*********************** 81100979Srwatson * Structures passed in the various netgraph command messages. 82100979Srwatson ***********************/ 83100979Srwatson/* This structure is returned by the NGM_PPPOE_GET_STATUS command */ 84100979Srwatsonstruct ngpppoestat { 85100979Srwatson u_int packets_in; /* packets in from downstream */ 86100979Srwatson u_int packets_out; /* packets out towards downstream */ 87100979Srwatson}; 88100979Srwatson 89101712Srwatson/* 90101712Srwatson * When this structure is accepted by the NGM_PPPOE_CONNECT command : 91101712Srwatson * The data field is MANDATORY. 92101712Srwatson * The session sends out a PADI request for the named service. 93101712Srwatson * 94101712Srwatson * 95101712Srwatson * When this structure is accepted by the NGM_PPPOE_WAIT command. 96100979Srwatson * If no service is given this is assumed to accept ALL PADI requests. 97100979Srwatson * This may at some time take a regexp exporession, but not yet. 98100979Srwatson * Matching PADI requests will be passed up the named hook. 99100979Srwatson * 100104517Srwatson * 101100979Srwatson * When this structure is accepted by the NGM_PPPOE_OFFER command: 102100979Srwatson * The AC-NAme field is set from that given and a PADI 103100979Srwatson * packet is expected to arrive from the session control daemon, on the 104105497Srwatson * named hook. The session will then issue the appropriate PADO 105100979Srwatson * and begin negotiation. 106100979Srwatson */ 107100979Srwatsonstruct ngpppoe_init_data { 108100979Srwatson char hook[NG_HOOKLEN + 1]; /* hook to monitor on */ 109100979Srwatson u_int16_t data_len; /* Length of the service name */ 110105959Srwatson char data[0]; /* init data goes here */ 111105959Srwatson}; 112105959Srwatson 113105959Srwatson/* 114105959Srwatson * This structure is used by the asychronous success and failure messages. 115100979Srwatson * (to report which hook has failed or connected). The message is sent 116100979Srwatson * to whoever requested the connection. (close may use this too). 117105988Srwatson */ 118105988Srwatsonstruct ngpppoe_sts { 119105988Srwatson char hook[NG_HOOKLEN + 1]; /* hook associated with event session */ 120105988Srwatson}; 121105988Srwatson 122105988Srwatson 123100979Srwatson/******************************************************************** 124100979Srwatson * Constants and definitions specific to pppoe 125100979Srwatson ********************************************************************/ 126100979Srwatson 127100979Srwatson#define PPPOE_TIMEOUT_LIMIT 64 128107089Srwatson#define PPPOE_OFFER_TIMEOUT 16 129107089Srwatson 130107089Srwatson/* Codes to identify message types */ 131107089Srwatson#define PADI_CODE 0x09 132107089Srwatson#define PADO_CODE 0x07 133100979Srwatson#define PADR_CODE 0x19 134100979Srwatson#define PADS_CODE 0x65 135100979Srwatson#define PADT_CODE 0xa7 136100979Srwatson 137100979Srwatson/* Tag identifiers */ 138103513Srwatson#if BYTE_ORDER == BIG_ENDIAN 139103513Srwatson#define PTT_EOL (0x0000) 140103513Srwatson#define PTT_SRV_NAME (0x0101) 141104236Srwatson#define PTT_AC_NAME (0x0102) 142103513Srwatson#define PTT_HOST_UNIQ (0x0103) 143100979Srwatson#define PTT_AC_COOKIE (0x0104) 144100979Srwatson#define PTT_VENDOR (0x0105) 145100979Srwatson#define PTT_RELAY_SID (0x0106) 146100979Srwatson#define PTT_SRV_ERR (0x0201) 147100979Srwatson#define PTT_SYS_ERR (0x0202) 148100979Srwatson#define PTT_GEN_ERR (0x0203) 149100979Srwatson 150100979Srwatson#define ETHERTYPE_PPPOE_DISC 0x8863 /* pppoe discovery packets */ 151100979Srwatson#define ETHERTYPE_PPPOE_SESS 0x8864 /* pppoe session packets */ 152100979Srwatson#else 153106045Srwatson#define PTT_EOL (0x0000) 154106045Srwatson#define PTT_SRV_NAME (0x0101) 155106045Srwatson#define PTT_AC_NAME (0x0201) 156106045Srwatson#define PTT_HOST_UNIQ (0x0301) 157106025Srwatson#define PTT_AC_COOKIE (0x0401) 158106045Srwatson#define PTT_VENDOR (0x0501) 159103514Srwatson#define PTT_RELAY_SID (0x0601) 160103514Srwatson#define PTT_SRV_ERR (0x0102) 161104236Srwatson#define PTT_SYS_ERR (0x0202) 162103514Srwatson#define PTT_GEN_ERR (0x0302) 163103136Srwatson 164103136Srwatson#define ETHERTYPE_PPPOE_DISC 0x6388 /* pppoe discovery packets */ 165103136Srwatson#define ETHERTYPE_PPPOE_SESS 0x6488 /* pppoe session packets */ 166103136Srwatson#endif 167101892Srwatson 168100979Srwatsonstruct pppoe_tag { 169100979Srwatson u_int16_t tag_type; 170100979Srwatson u_int16_t tag_len; 171100979Srwatson char tag_data[0]; 172101988Srwatson}__attribute ((packed)); 173104268Srwatson 174104268Srwatsonstruct pppoe_hdr{ 175104268Srwatson u_int8_t ver:4; 176104268Srwatson u_int8_t type:4; 177104268Srwatson u_int8_t code; 178104268Srwatson u_int16_t sid; 179104268Srwatson u_int16_t length; 180104268Srwatson struct pppoe_tag tag[0]; 181104268Srwatson}__attribute__ ((packed)); 182104268Srwatson 183104517Srwatson 184104517Srwatsonstruct pppoe_full_hdr { 185104517Srwatson struct ether_header eh; 186100979Srwatson struct pppoe_hdr ph; 187100979Srwatson}__attribute__ ((packed)); 188107105Srwatson 189104517Srwatsonunion packet { 190104517Srwatson struct pppoe_full_hdr pkt_header; 191100979Srwatson u_int8_t bytes[2048]; 192104517Srwatson}; 193100979Srwatson 194104517Srwatsonstruct datatag { 195100979Srwatson struct pppoe_tag hdr; 196104517Srwatson u_int8_t data[PPPOE_SERVICE_NAME_SIZE]; 197100979Srwatson}; 198104517Srwatson 199100979Srwatson 200104517Srwatson/* 201100979Srwatson * Define the order in which we will place tags in packets 202104517Srwatson * this may be ignored 203100979Srwatson */ 204107105Srwatson/* for PADI */ 205107105Srwatson#define TAGI_SVC 0 206104517Srwatson#define TAGI_HUNIQ 1 207100979Srwatson/* for PADO */ 208104517Srwatson#define TAGO_ACNAME 0 209100979Srwatson#define TAGO_SVC 1 210104517Srwatson#define TAGO_COOKIE 2 211100979Srwatson#define TAGO_HUNIQ 3 212104517Srwatson/* for PADR */ 213100979Srwatson#define TAGR_SVC 0 214101988Srwatson#define TAGR_HUNIQ 1 215100979Srwatson#define TAGR_COOKIE 2 216100979Srwatson/* for PADS */ 217100979Srwatson#define TAGS_ACNAME 0 218100979Srwatson#define TAGS_SVC 1 219100979Srwatson#define TAGS_COOKIE 2 220104546Srwatson#define TAGS_HUNIQ 3 221104546Srwatson/* for PADT */ 222100979Srwatson 223100979Srwatson#endif /* _NETGRAPH_PPPOE_H_ */ 224100979Srwatson 225104541Srwatson