The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/netgraph/ng_pppoe.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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: releng/5.3/sys/netgraph/ng_pppoe.h 136588 2004-10-16 08:43:07Z cvs2svn $
   40  * $Whistle: ng_pppoe.h,v 1.7 1999/10/16 10:16:43 julian Exp $
   41  */
   42 
   43 #ifndef _NETGRAPH_NG_PPPOE_H_
   44 #define _NETGRAPH_NG_PPPOE_H_
   45 
   46 /********************************************************************
   47  * Netgraph hook constants etc.
   48  ********************************************************************/
   49 /* Node type name. This should be unique among all netgraph node types */
   50 #define NG_PPPOE_NODE_TYPE      "pppoe"
   51 
   52 #define NGM_PPPOE_COOKIE                1089893072
   53 
   54 /* Number of active sessions we can handle */
   55 #define PPPOE_NUM_SESSIONS              16 /* for now */
   56 #define PPPOE_SERVICE_NAME_SIZE         64 /* for now */
   57 
   58 /* Hook names */
   59 #define NG_PPPOE_HOOK_ETHERNET  "ethernet"
   60 #define NG_PPPOE_HOOK_PADI      "PADI"    /* default PADI requests come here */
   61 #define NG_PPPOE_HOOK_S_LEADIN  "service" /* PADO responses from PADI */
   62 #define NG_PPPOE_HOOK_C_LEADIN  "client"  /* Connect message starts this */
   63 #define NG_PPPOE_HOOK_DEBUG     "debug"
   64 
   65 /* Mode names */
   66 #define NG_PPPOE_STANDARD       "standard"
   67 #define NG_PPPOE_NONSTANDARD    "3Com"
   68 
   69 /**********************************************************************
   70  * Netgraph commands understood by this node type.
   71  * FAIL, SUCCESS, CLOSE and ACNAME are sent by the node rather than received.
   72  ********************************************************************/
   73 enum cmd {
   74         NGM_PPPOE_SET_FLAG = 1,
   75         NGM_PPPOE_CONNECT  = 2, /* Client, Try find this service */
   76         NGM_PPPOE_LISTEN   = 3, /* Server, Await a request for this service */
   77         NGM_PPPOE_OFFER    = 4, /* Server, hook X should respond (*) */
   78         NGM_PPPOE_SUCCESS  = 5, /* State machine connected */
   79         NGM_PPPOE_FAIL     = 6, /* State machine could not connect */
   80         NGM_PPPOE_CLOSE    = 7, /* Session closed down */
   81         NGM_PPPOE_SERVICE  = 8, /* additional Service to advertise (in PADO) */
   82         NGM_PPPOE_ACNAME   = 9, /* AC_NAME for informational purposes */
   83         NGM_PPPOE_GET_STATUS = 10, /* data in/out */
   84         NGM_PPPOE_SESSIONID  = 11,  /* Session_ID for informational purposes */
   85         NGM_PPPOE_SETMODE  = 12, /* set to standard or 3Com mode */
   86         NGM_PPPOE_GETMODE  = 13, /* see current mode */
   87 };
   88 
   89 /***********************
   90  * Structures passed in the various netgraph command messages.
   91  ***********************/
   92 /* This structure is returned by the NGM_PPPOE_GET_STATUS command */
   93 struct ngpppoestat {
   94         u_int   packets_in;     /* packets in from ethernet */
   95         u_int   packets_out;    /* packets out towards ethernet */
   96 };
   97 
   98 /* Keep this in sync with the above structure definition */
   99 #define NG_PPPOESTAT_TYPE_INFO  {                               \
  100           { "packets_in",       &ng_parse_uint_type     },      \
  101           { "packets_out",      &ng_parse_uint_type     },      \
  102           { NULL }                                              \
  103 }
  104 
  105 /*
  106  * When this structure is accepted by the NGM_PPPOE_CONNECT command :
  107  * The data field is MANDATORY.
  108  * The session sends out a PADI request for the named service.
  109  *
  110  *
  111  * When this structure is accepted by the NGM_PPPOE_LISTEN command.
  112  * If no service is given this is assumed to accept ALL PADI requests.
  113  * This may at some time take a regexp expression, but not yet.
  114  * Matching PADI requests will be passed up the named hook.
  115  *
  116  *
  117  * When this structure is accepted by the NGM_PPPOE_OFFER command:
  118  * The AC-NAme field is set from that given and a PADI
  119  * packet is expected to arrive from the session control daemon, on the
  120  * named hook. The session will then issue the appropriate PADO
  121  * and begin negotiation.
  122  */
  123 struct ngpppoe_init_data {
  124         char            hook[NG_HOOKSIZ];       /* hook to monitor on */
  125         u_int16_t       data_len;               /* Length of the service name */
  126         char            data[0];                /* init data goes here */
  127 };
  128 
  129 /* Keep this in sync with the above structure definition */
  130 #define NG_PPPOE_INIT_DATA_TYPE_INFO    {               \
  131           { "hook",     &ng_parse_hookbuf_type  },      \
  132           { "data",     &ng_parse_sizedstring_type },   \
  133           { NULL }                                      \
  134 }
  135 
  136 /*
  137  * This structure is used by the asychronous success and failure messages.
  138  * (to report which hook has failed or connected). The message is sent
  139  * to whoever requested the connection. (close may use this too).
  140  */
  141 struct ngpppoe_sts {
  142         char    hook[NG_HOOKSIZ];       /* hook associated with event session */
  143 };
  144 
  145 /* Keep this in sync with the above structure definition */
  146 #define NG_PPPOE_STS_TYPE_INFO          {               \
  147           { "hook",     &ng_parse_hookbuf_type  },      \
  148           { NULL }                                      \
  149 }
  150 
  151 
  152 /********************************************************************
  153  * Constants and definitions specific to pppoe
  154  ********************************************************************/
  155 
  156 #define PPPOE_TIMEOUT_LIMIT 64
  157 #define PPPOE_OFFER_TIMEOUT 16
  158 #define PPPOE_INITIAL_TIMEOUT 2
  159 
  160 /* Codes to identify message types */
  161 #define PADI_CODE       0x09
  162 #define PADO_CODE       0x07
  163 #define PADR_CODE       0x19
  164 #define PADS_CODE       0x65
  165 #define PADT_CODE       0xa7
  166 
  167 /* Tag identifiers */
  168 #if BYTE_ORDER == BIG_ENDIAN
  169 #define PTT_EOL         (0x0000)
  170 #define PTT_SRV_NAME    (0x0101)
  171 #define PTT_AC_NAME     (0x0102)
  172 #define PTT_HOST_UNIQ   (0x0103)
  173 #define PTT_AC_COOKIE   (0x0104)
  174 #define PTT_VENDOR      (0x0105)
  175 #define PTT_RELAY_SID   (0x0110)
  176 #define PTT_SRV_ERR     (0x0201)
  177 #define PTT_SYS_ERR     (0x0202)
  178 #define PTT_GEN_ERR     (0x0203)
  179 
  180 #define ETHERTYPE_PPPOE_DISC    0x8863  /* pppoe discovery packets     */
  181 #define ETHERTYPE_PPPOE_SESS    0x8864  /* pppoe session packets       */
  182 #define ETHERTYPE_PPPOE_STUPID_DISC 0x3c12 /* pppoe discovery packets 3com? */
  183 #define ETHERTYPE_PPPOE_STUPID_SESS 0x3c13 /* pppoe session packets   3com? */
  184 #else
  185 #define PTT_EOL         (0x0000)
  186 #define PTT_SRV_NAME    (0x0101)
  187 #define PTT_AC_NAME     (0x0201)
  188 #define PTT_HOST_UNIQ   (0x0301)
  189 #define PTT_AC_COOKIE   (0x0401)
  190 #define PTT_VENDOR      (0x0501)
  191 #define PTT_RELAY_SID   (0x1001)
  192 #define PTT_SRV_ERR     (0x0102)
  193 #define PTT_SYS_ERR     (0x0202)
  194 #define PTT_GEN_ERR     (0x0302)
  195 
  196 #define ETHERTYPE_PPPOE_DISC    0x6388  /* pppoe discovery packets     */
  197 #define ETHERTYPE_PPPOE_SESS    0x6488  /* pppoe session packets       */
  198 #define ETHERTYPE_PPPOE_STUPID_DISC 0x123c /* pppoe discovery packets 3com? */
  199 #define ETHERTYPE_PPPOE_STUPID_SESS 0x133c /* pppoe session packets   3com? */
  200 #endif
  201 
  202 struct pppoe_tag {
  203         u_int16_t tag_type;
  204         u_int16_t tag_len;
  205         char tag_data[0];
  206 }__packed;
  207 
  208 struct pppoe_hdr{
  209         u_int8_t ver:4;
  210         u_int8_t type:4;
  211         u_int8_t code;
  212         u_int16_t sid;
  213         u_int16_t length;
  214         struct pppoe_tag tag[0];
  215 }__packed;
  216 
  217 
  218 struct pppoe_full_hdr {
  219         struct  ether_header eh;
  220         struct pppoe_hdr ph;
  221 }__packed;
  222 
  223 union   packet {
  224         struct pppoe_full_hdr   pkt_header;
  225         u_int8_t        bytes[2048];
  226 };
  227 
  228 struct datatag {
  229         struct pppoe_tag hdr;
  230         u_int8_t        data[PPPOE_SERVICE_NAME_SIZE];
  231 };     
  232 
  233 
  234 /*
  235  * Define the order in which we will place tags in packets
  236  * this may be ignored
  237  */
  238 /* for PADI */
  239 #define TAGI_SVC 0
  240 #define TAGI_HUNIQ 1
  241 /* for PADO */
  242 #define TAGO_ACNAME 0
  243 #define TAGO_SVC 1
  244 #define TAGO_COOKIE 2
  245 #define TAGO_HUNIQ 3
  246 /* for PADR */
  247 #define TAGR_SVC 0
  248 #define TAGR_HUNIQ 1
  249 #define TAGR_COOKIE 2
  250 /* for PADS */
  251 #define TAGS_ACNAME 0
  252 #define TAGS_SVC 1
  253 #define TAGS_COOKIE 2
  254 #define TAGS_HUNIQ 3
  255 /* for PADT */
  256 
  257 #endif /* _NETGRAPH_NG_PPPOE_H_ */
  258 

Cache object: be1daf1fb1a1cc12a77ad72bed4b8aaf


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.