152419Sjulian/* 252419Sjulian * ng_pppoe.h 3139823Simp */ 4139823Simp 5139823Simp/*- 652419Sjulian * Copyright (c) 1996-1999 Whistle Communications, Inc. 752419Sjulian * All rights reserved. 852419Sjulian * 952419Sjulian * Subject to the following obligations and disclaimer of warranty, use and 1052419Sjulian * redistribution of this software, in source or object code forms, with or 1152419Sjulian * without modifications are expressly permitted by Whistle Communications; 1252419Sjulian * provided, however, that: 1352419Sjulian * 1. Any and all reproductions of the source or object code must include the 1452419Sjulian * copyright notice above and the following disclaimer of warranties; and 1552419Sjulian * 2. No rights are granted, in any manner or form, to use Whistle 1652419Sjulian * Communications, Inc. trademarks, including the mark "WHISTLE 1752419Sjulian * COMMUNICATIONS" on advertising, endorsements, or otherwise except as 1852419Sjulian * such appears in the above copyright notice or in the software. 1952419Sjulian * 2052419Sjulian * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND 2152419Sjulian * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO 2252419Sjulian * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE, 2352419Sjulian * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF 2452419Sjulian * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. 2552419Sjulian * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY 2652419Sjulian * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS 2752419Sjulian * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE. 2852419Sjulian * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES 2952419Sjulian * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING 3052419Sjulian * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 3152419Sjulian * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR 3252419Sjulian * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 3352419Sjulian * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3452419Sjulian * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 3552419Sjulian * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY 3652419Sjulian * OF SUCH DAMAGE. 3752419Sjulian * 3867506Sjulian * Author: Julian Elischer <julian@freebsd.org> 3952419Sjulian * 4052419Sjulian * $FreeBSD$ 4152419Sjulian * $Whistle: ng_pppoe.h,v 1.7 1999/10/16 10:16:43 julian Exp $ 4252419Sjulian */ 4352419Sjulian 44122481Sru#ifndef _NETGRAPH_NG_PPPOE_H_ 45122481Sru#define _NETGRAPH_NG_PPPOE_H_ 4652419Sjulian 4752419Sjulian/******************************************************************** 4852419Sjulian * Netgraph hook constants etc. 4952419Sjulian ********************************************************************/ 5052419Sjulian/* Node type name. This should be unique among all netgraph node types */ 5152562Sjulian#define NG_PPPOE_NODE_TYPE "pppoe" 5252419Sjulian 53132703Sglebius#define NGM_PPPOE_COOKIE 1089893072 5452419Sjulian 5552419Sjulian#define PPPOE_SERVICE_NAME_SIZE 64 /* for now */ 5652419Sjulian 5752419Sjulian/* Hook names */ 5852419Sjulian#define NG_PPPOE_HOOK_ETHERNET "ethernet" 5952419Sjulian#define NG_PPPOE_HOOK_DEBUG "debug" 6052419Sjulian 61132703Sglebius/* Mode names */ 62132703Sglebius#define NG_PPPOE_STANDARD "standard" 63154901Sglebius#define NG_PPPOE_3COM "3Com" 64154901Sglebius#define NG_PPPOE_NONSTANDARD NG_PPPOE_3COM 65154901Sglebius#define NG_PPPOE_DLINK "D-Link" 66132703Sglebius 6752419Sjulian/********************************************************************** 6852419Sjulian * Netgraph commands understood by this node type. 6990973Sbrian * FAIL, SUCCESS, CLOSE and ACNAME are sent by the node rather than received. 7052419Sjulian ********************************************************************/ 7152441Sjulianenum cmd { 7252419Sjulian NGM_PPPOE_SET_FLAG = 1, 7352419Sjulian NGM_PPPOE_CONNECT = 2, /* Client, Try find this service */ 7452419Sjulian NGM_PPPOE_LISTEN = 3, /* Server, Await a request for this service */ 7552419Sjulian NGM_PPPOE_OFFER = 4, /* Server, hook X should respond (*) */ 7652419Sjulian NGM_PPPOE_SUCCESS = 5, /* State machine connected */ 7752419Sjulian NGM_PPPOE_FAIL = 6, /* State machine could not connect */ 7852419Sjulian NGM_PPPOE_CLOSE = 7, /* Session closed down */ 7969934Sjulian NGM_PPPOE_SERVICE = 8, /* additional Service to advertise (in PADO) */ 8090973Sbrian NGM_PPPOE_ACNAME = 9, /* AC_NAME for informational purposes */ 8196578Sbrian NGM_PPPOE_GET_STATUS = 10, /* data in/out */ 82132703Sglebius NGM_PPPOE_SESSIONID = 11, /* Session_ID for informational purposes */ 83161117Sglebius NGM_PPPOE_SETMODE = 12, /* set to standard or compat modes */ 84132703Sglebius NGM_PPPOE_GETMODE = 13, /* see current mode */ 85161117Sglebius NGM_PPPOE_SETENADDR = 14, /* set Ethernet address */ 8652419Sjulian}; 8752419Sjulian 8852419Sjulian/*********************** 8952419Sjulian * Structures passed in the various netgraph command messages. 9052419Sjulian ***********************/ 9152419Sjulian/* This structure is returned by the NGM_PPPOE_GET_STATUS command */ 9252562Sjulianstruct ngpppoestat { 9352722Sjulian u_int packets_in; /* packets in from ethernet */ 9452722Sjulian u_int packets_out; /* packets out towards ethernet */ 9552419Sjulian}; 9652419Sjulian 9768031Sbrian/* Keep this in sync with the above structure definition */ 9868031Sbrian#define NG_PPPOESTAT_TYPE_INFO { \ 9968031Sbrian { "packets_in", &ng_parse_uint_type }, \ 10068031Sbrian { "packets_out", &ng_parse_uint_type }, \ 10168031Sbrian { NULL } \ 10268031Sbrian} 10368031Sbrian 10452419Sjulian/* 10552419Sjulian * When this structure is accepted by the NGM_PPPOE_CONNECT command : 10652419Sjulian * The data field is MANDATORY. 10752419Sjulian * The session sends out a PADI request for the named service. 10852419Sjulian * 10952419Sjulian * 11069934Sjulian * When this structure is accepted by the NGM_PPPOE_LISTEN command. 11152419Sjulian * If no service is given this is assumed to accept ALL PADI requests. 11253042Sjulian * This may at some time take a regexp expression, but not yet. 11352419Sjulian * Matching PADI requests will be passed up the named hook. 11452419Sjulian * 11552419Sjulian * 11652419Sjulian * When this structure is accepted by the NGM_PPPOE_OFFER command: 11752419Sjulian * The AC-NAme field is set from that given and a PADI 11852419Sjulian * packet is expected to arrive from the session control daemon, on the 11952419Sjulian * named hook. The session will then issue the appropriate PADO 12052419Sjulian * and begin negotiation. 12152419Sjulian */ 12252562Sjulianstruct ngpppoe_init_data { 123125028Sharti char hook[NG_HOOKSIZ]; /* hook to monitor on */ 12468845Sbrian u_int16_t data_len; /* Length of the service name */ 125151800Sru char data[]; /* init data goes here */ 12652419Sjulian}; 12752419Sjulian 12868031Sbrian/* Keep this in sync with the above structure definition */ 12968031Sbrian#define NG_PPPOE_INIT_DATA_TYPE_INFO { \ 13068031Sbrian { "hook", &ng_parse_hookbuf_type }, \ 13168845Sbrian { "data", &ng_parse_sizedstring_type }, \ 13268031Sbrian { NULL } \ 13368031Sbrian} 13468031Sbrian 13552419Sjulian/* 13652419Sjulian * This structure is used by the asychronous success and failure messages. 13752419Sjulian * (to report which hook has failed or connected). The message is sent 13852419Sjulian * to whoever requested the connection. (close may use this too). 13952419Sjulian */ 14052562Sjulianstruct ngpppoe_sts { 141125028Sharti char hook[NG_HOOKSIZ]; /* hook associated with event session */ 14252419Sjulian}; 14352419Sjulian 14468031Sbrian/* Keep this in sync with the above structure definition */ 14568031Sbrian#define NG_PPPOE_STS_TYPE_INFO { \ 14668031Sbrian { "hook", &ng_parse_hookbuf_type }, \ 14768031Sbrian { NULL } \ 14868031Sbrian} 14952419Sjulian 15068031Sbrian 15152419Sjulian/******************************************************************** 15252562Sjulian * Constants and definitions specific to pppoe 15352419Sjulian ********************************************************************/ 15452419Sjulian 15552419Sjulian#define PPPOE_TIMEOUT_LIMIT 64 15652419Sjulian#define PPPOE_OFFER_TIMEOUT 16 15753979Sjulian#define PPPOE_INITIAL_TIMEOUT 2 15852419Sjulian 15952419Sjulian/* Codes to identify message types */ 16052419Sjulian#define PADI_CODE 0x09 16152419Sjulian#define PADO_CODE 0x07 16252419Sjulian#define PADR_CODE 0x19 16352419Sjulian#define PADS_CODE 0x65 16452419Sjulian#define PADT_CODE 0xa7 16552419Sjulian 16652419Sjulian/* Tag identifiers */ 16752419Sjulian#if BYTE_ORDER == BIG_ENDIAN 16852419Sjulian#define PTT_EOL (0x0000) 16952419Sjulian#define PTT_SRV_NAME (0x0101) 17052419Sjulian#define PTT_AC_NAME (0x0102) 17152419Sjulian#define PTT_HOST_UNIQ (0x0103) 17252419Sjulian#define PTT_AC_COOKIE (0x0104) 17352419Sjulian#define PTT_VENDOR (0x0105) 174127169Sdwmalone#define PTT_RELAY_SID (0x0110) 17552419Sjulian#define PTT_SRV_ERR (0x0201) 17652419Sjulian#define PTT_SYS_ERR (0x0202) 17752419Sjulian#define PTT_GEN_ERR (0x0203) 17852419Sjulian 17952562Sjulian#define ETHERTYPE_PPPOE_DISC 0x8863 /* pppoe discovery packets */ 18052562Sjulian#define ETHERTYPE_PPPOE_SESS 0x8864 /* pppoe session packets */ 181154901Sglebius#define ETHERTYPE_PPPOE_3COM_DISC 0x3c12 /* pppoe discovery packets 3com? */ 182154901Sglebius#define ETHERTYPE_PPPOE_3COM_SESS 0x3c13 /* pppoe session packets 3com? */ 18352419Sjulian#else 18452419Sjulian#define PTT_EOL (0x0000) 18552419Sjulian#define PTT_SRV_NAME (0x0101) 18652419Sjulian#define PTT_AC_NAME (0x0201) 18752419Sjulian#define PTT_HOST_UNIQ (0x0301) 18852419Sjulian#define PTT_AC_COOKIE (0x0401) 18952419Sjulian#define PTT_VENDOR (0x0501) 190127169Sdwmalone#define PTT_RELAY_SID (0x1001) 19152419Sjulian#define PTT_SRV_ERR (0x0102) 19252419Sjulian#define PTT_SYS_ERR (0x0202) 19352419Sjulian#define PTT_GEN_ERR (0x0302) 19452419Sjulian 19552562Sjulian#define ETHERTYPE_PPPOE_DISC 0x6388 /* pppoe discovery packets */ 19652562Sjulian#define ETHERTYPE_PPPOE_SESS 0x6488 /* pppoe session packets */ 197154901Sglebius#define ETHERTYPE_PPPOE_3COM_DISC 0x123c /* pppoe discovery packets 3com? */ 198154901Sglebius#define ETHERTYPE_PPPOE_3COM_SESS 0x133c /* pppoe session packets 3com? */ 19952419Sjulian#endif 20052419Sjulian 20152419Sjulianstruct pppoe_tag { 20252419Sjulian u_int16_t tag_type; 20352419Sjulian u_int16_t tag_len; 204103870Salfred}__packed; 20552419Sjulian 20652419Sjulianstruct pppoe_hdr{ 20752419Sjulian u_int8_t ver:4; 20852419Sjulian u_int8_t type:4; 20952419Sjulian u_int8_t code; 21052419Sjulian u_int16_t sid; 21152419Sjulian u_int16_t length; 212103870Salfred}__packed; 21352419Sjulian 21452419Sjulian 21552419Sjulianstruct pppoe_full_hdr { 21652419Sjulian struct ether_header eh; 21752419Sjulian struct pppoe_hdr ph; 218103870Salfred}__packed; 21952419Sjulian 22052419Sjulianunion packet { 22152419Sjulian struct pppoe_full_hdr pkt_header; 22252419Sjulian u_int8_t bytes[2048]; 22352419Sjulian}; 22452419Sjulian 22552419Sjulianstruct datatag { 22652419Sjulian struct pppoe_tag hdr; 22752419Sjulian u_int8_t data[PPPOE_SERVICE_NAME_SIZE]; 22852419Sjulian}; 22952419Sjulian 23052419Sjulian 23152419Sjulian/* 23252419Sjulian * Define the order in which we will place tags in packets 23352419Sjulian * this may be ignored 23452419Sjulian */ 23552419Sjulian/* for PADI */ 23652419Sjulian#define TAGI_SVC 0 23752419Sjulian#define TAGI_HUNIQ 1 23852419Sjulian/* for PADO */ 23952419Sjulian#define TAGO_ACNAME 0 24052419Sjulian#define TAGO_SVC 1 24152419Sjulian#define TAGO_COOKIE 2 24252419Sjulian#define TAGO_HUNIQ 3 24352419Sjulian/* for PADR */ 24452419Sjulian#define TAGR_SVC 0 24552419Sjulian#define TAGR_HUNIQ 1 24652419Sjulian#define TAGR_COOKIE 2 24752419Sjulian/* for PADS */ 24852419Sjulian#define TAGS_ACNAME 0 24952419Sjulian#define TAGS_SVC 1 25052419Sjulian#define TAGS_COOKIE 2 25152419Sjulian#define TAGS_HUNIQ 3 25252419Sjulian/* for PADT */ 25352419Sjulian 254122481Sru#endif /* _NETGRAPH_NG_PPPOE_H_ */ 25552419Sjulian 256