1 2 /* 3 * ng_pppoe.h 4 * 5 * Copyright (c) 1996-1999 Whistle Communications, Inc. 6 * All rights reserved. 7 * 8 * Subject to the following obligations and disclaimer of warranty, use and 9 * redistribution of this software, in source or object code forms, with or 10 * without modifications are expressly permitted by Whistle Communications; 11 * provided, however, that: 12 * 1. Any and all reproductions of the source or object code must include the 13 * copyright notice above and the following disclaimer of warranties; and 14 * 2. No rights are granted, in any manner or form, to use Whistle 15 * Communications, Inc. trademarks, including the mark "WHISTLE 16 * COMMUNICATIONS" on advertising, endorsements, or otherwise except as 17 * such appears in the above copyright notice or in the software. 18 * 19 * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND 20 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO 21 * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE, 22 * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF 23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. 24 * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY 25 * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS 26 * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE. 27 * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES 28 * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING 29 * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 30 * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR 31 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY 35 * OF SUCH DAMAGE. 36 * 37 * Author: Julian Elischer <julian@freebsd.org> 38 * 39 * $FreeBSD: src/sys/netgraph/ng_pppoe.h,v 1.7.2.5 2002/06/17 02:19:06 brian Exp $ 40 * $DragonFly: src/sys/netgraph/pppoe/ng_pppoe.h,v 1.3 2007/06/03 20:51:13 dillon Exp $ 41 * $Whistle: ng_pppoe.h,v 1.7 1999/10/16 10:16:43 julian Exp $ 42 */ 43 44 #ifndef _NETGRAPH_PPPOE_H_ 45 #define _NETGRAPH_PPPOE_H_ 46 47 /******************************************************************** 48 * Netgraph hook constants etc. 49 ********************************************************************/ 50 /* Node type name. This should be unique among all netgraph node types */ 51 #define NG_PPPOE_NODE_TYPE "pppoe" 52 53 #define NGM_PPPOE_COOKIE 939032003 54 55 /* Number of active sessions we can handle */ 56 #define PPPOE_NUM_SESSIONS 16 /* for now */ 57 #define PPPOE_SERVICE_NAME_SIZE 64 /* for now */ 58 59 /* Hook names */ 60 #define NG_PPPOE_HOOK_ETHERNET "ethernet" 61 #define NG_PPPOE_HOOK_PADI "PADI" /* default PADI requests come here */ 62 #define NG_PPPOE_HOOK_S_LEADIN "service" /* PADO responses from PADI */ 63 #define NG_PPPOE_HOOK_C_LEADIN "client" /* Connect message starts this */ 64 #define NG_PPPOE_HOOK_DEBUG "debug" 65 66 /********************************************************************** 67 * Netgraph commands understood by this node type. 68 * FAIL, SUCCESS, CLOSE and ACNAME are sent by the node rather than received. 69 ********************************************************************/ 70 enum cmd { 71 NGM_PPPOE_SET_FLAG = 1, 72 NGM_PPPOE_CONNECT = 2, /* Client, Try find this service */ 73 NGM_PPPOE_LISTEN = 3, /* Server, Await a request for this service */ 74 NGM_PPPOE_OFFER = 4, /* Server, hook X should respond (*) */ 75 NGM_PPPOE_SUCCESS = 5, /* State machine connected */ 76 NGM_PPPOE_FAIL = 6, /* State machine could not connect */ 77 NGM_PPPOE_CLOSE = 7, /* Session closed down */ 78 NGM_PPPOE_SERVICE = 8, /* additional Service to advertise (in PADO) */ 79 NGM_PPPOE_ACNAME = 9, /* AC_NAME for informational purposes */ 80 NGM_PPPOE_GET_STATUS = 10, /* data in/out */ 81 NGM_PPPOE_SESSIONID = 11 /* Session_ID for informational purposes */ 82 }; 83 84 /*********************** 85 * Structures passed in the various netgraph command messages. 86 ***********************/ 87 /* This structure is returned by the NGM_PPPOE_GET_STATUS command */ 88 struct ngpppoestat { 89 u_int packets_in; /* packets in from ethernet */ 90 u_int packets_out; /* packets out towards ethernet */ 91 }; 92 93 /* 94 * When this structure is accepted by the NGM_PPPOE_CONNECT command : 95 * The data field is MANDATORY. 96 * The session sends out a PADI request for the named service. 97 * 98 * 99 * When this structure is accepted by the NGM_PPPOE_LISTEN command. 100 * If no service is given this is assumed to accept ALL PADI requests. 101 * This may at some time take a regexp expression, but not yet. 102 * Matching PADI requests will be passed up the named hook. 103 * 104 * 105 * When this structure is accepted by the NGM_PPPOE_OFFER command: 106 * The AC-NAme field is set from that given and a PADI 107 * packet is expected to arrive from the session control daemon, on the 108 * named hook. The session will then issue the appropriate PADO 109 * and begin negotiation. 110 */ 111 struct ngpppoe_init_data { 112 char hook[NG_HOOKSIZ]; /* hook to monitor on */ 113 u_int16_t data_len; /* Length of the service name */ 114 char data[0]; /* init data goes here */ 115 }; 116 117 /* 118 * This structure is used by the asychronous success and failure messages. 119 * (to report which hook has failed or connected). The message is sent 120 * to whoever requested the connection. (close may use this too). 121 */ 122 struct ngpppoe_sts { 123 char hook[NG_HOOKSIZ]; /* hook associated with event session */ 124 }; 125 126 127 /******************************************************************** 128 * Constants and definitions specific to pppoe 129 ********************************************************************/ 130 131 #define PPPOE_TIMEOUT_LIMIT 64 132 #define PPPOE_OFFER_TIMEOUT 16 133 #define PPPOE_INITIAL_TIMEOUT 2 134 135 /* Codes to identify message types */ 136 #define PADI_CODE 0x09 137 #define PADO_CODE 0x07 138 #define PADR_CODE 0x19 139 #define PADS_CODE 0x65 140 #define PADT_CODE 0xa7 141 142 /* Tag identifiers */ 143 #if BYTE_ORDER == BIG_ENDIAN 144 #define PTT_EOL (0x0000) 145 #define PTT_SRV_NAME (0x0101) 146 #define PTT_AC_NAME (0x0102) 147 #define PTT_HOST_UNIQ (0x0103) 148 #define PTT_AC_COOKIE (0x0104) 149 #define PTT_VENDOR (0x0105) 150 #define PTT_RELAY_SID (0x0106) 151 #define PTT_SRV_ERR (0x0201) 152 #define PTT_SYS_ERR (0x0202) 153 #define PTT_GEN_ERR (0x0203) 154 155 #define ETHERTYPE_PPPOE_DISC 0x8863 /* pppoe discovery packets */ 156 #define ETHERTYPE_PPPOE_SESS 0x8864 /* pppoe session packets */ 157 #define ETHERTYPE_PPPOE_STUPID_DISC 0x3c12 /* pppoe discovery packets 3com? */ 158 #define ETHERTYPE_PPPOE_STUPID_SESS 0x3c13 /* pppoe session packets 3com? */ 159 #else 160 #define PTT_EOL (0x0000) 161 #define PTT_SRV_NAME (0x0101) 162 #define PTT_AC_NAME (0x0201) 163 #define PTT_HOST_UNIQ (0x0301) 164 #define PTT_AC_COOKIE (0x0401) 165 #define PTT_VENDOR (0x0501) 166 #define PTT_RELAY_SID (0x0601) 167 #define PTT_SRV_ERR (0x0102) 168 #define PTT_SYS_ERR (0x0202) 169 #define PTT_GEN_ERR (0x0302) 170 171 #define ETHERTYPE_PPPOE_DISC 0x6388 /* pppoe discovery packets */ 172 #define ETHERTYPE_PPPOE_SESS 0x6488 /* pppoe session packets */ 173 #define ETHERTYPE_PPPOE_STUPID_DISC 0x123c /* pppoe discovery packets 3com? */ 174 #define ETHERTYPE_PPPOE_STUPID_SESS 0x133c /* pppoe session packets 3com? */ 175 #endif 176 177 struct pppoe_tag { 178 u_int16_t tag_type; 179 u_int16_t tag_len; 180 char tag_data[0]; 181 }__attribute ((packed)); 182 183 struct pppoe_hdr{ 184 u_int8_t ver:4; 185 u_int8_t type:4; 186 u_int8_t code; 187 u_int16_t sid; 188 u_int16_t length; 189 struct pppoe_tag tag[0]; 190 }__attribute__ ((packed)); 191 192 193 struct pppoe_full_hdr { 194 struct ether_header eh; 195 struct pppoe_hdr ph; 196 }__attribute__ ((packed)); 197 198 union packet { 199 struct pppoe_full_hdr pkt_header; 200 u_int8_t bytes[2048]; 201 }; 202 203 struct datatag { 204 struct pppoe_tag hdr; 205 u_int8_t data[PPPOE_SERVICE_NAME_SIZE]; 206 }; 207 208 209 /* 210 * Define the order in which we will place tags in packets 211 * this may be ignored 212 */ 213 /* for PADI */ 214 #define TAGI_SVC 0 215 #define TAGI_HUNIQ 1 216 /* for PADO */ 217 #define TAGO_ACNAME 0 218 #define TAGO_SVC 1 219 #define TAGO_COOKIE 2 220 #define TAGO_HUNIQ 3 221 /* for PADR */ 222 #define TAGR_SVC 0 223 #define TAGR_HUNIQ 1 224 #define TAGR_COOKIE 2 225 /* for PADS */ 226 #define TAGS_ACNAME 0 227 #define TAGS_SVC 1 228 #define TAGS_COOKIE 2 229 #define TAGS_HUNIQ 3 230 /* for PADT */ 231 232 #endif /* _NETGRAPH_PPPOE_H_ */ 233 234