1 /* Copyright (C) 2007-2010 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author James Riden <jamesr@europe.com>
22  */
23 
24 #ifndef __DECODE_PPPOE_H__
25 #define __DECODE_PPPOE_H__
26 
27 #include "decode.h"
28 #include "threadvars.h"
29 
30 #define PPPOE_SESSION_HEADER_LEN 8
31 #define PPPOE_DISCOVERY_HEADER_MIN_LEN 6
32 #define PPPOE_SESSION_GET_VERSION(hdr) ((hdr)->pppoe_version_type & 0xF0) >> 4
33 #define PPPOE_SESSION_GET_TYPE(hdr) ((hdr)->pppoe_version_type & 0x0F)
34 #define PPPOE_DISCOVERY_GET_VERSION(hdr) ((hdr)->pppoe_version_type & 0xF0) >> 4
35 #define PPPOE_DISCOVERY_GET_TYPE(hdr) ((hdr)->pppoe_version_type & 0x0F)
36 
37 typedef struct PPPOESessionHdr_
38 {
39     uint8_t pppoe_version_type;
40     uint8_t pppoe_code;
41     uint16_t session_id;
42     uint16_t pppoe_length;
43     uint16_t protocol;
44 } PPPOESessionHdr;
45 
46 typedef struct PPPOEDiscoveryTag_
47 {
48     uint16_t pppoe_tag_type;
49     uint16_t pppoe_tag_length;
50 } __attribute__((__packed__)) PPPOEDiscoveryTag;
51 
52 typedef struct PPPOEDiscoveryHdr_
53 {
54     uint8_t pppoe_version_type;
55     uint8_t pppoe_code;
56     uint16_t discovery_id;
57     uint16_t pppoe_length;
58 } __attribute__((__packed__)) PPPOEDiscoveryHdr;
59 
60 /* see RFC 2516 - discovery codes */
61 #define PPPOE_CODE_PADI 0x09
62 #define PPPOE_CODE_PADO 0x07
63 #define PPPOE_CODE_PADR 0x19
64 #define PPPOE_CODE_PADS 0x65
65 #define PPPOE_CODE_PADT 0xa7
66 
67 /* see RFC 2516 Appendix A */
68 #define PPPOE_TAG_END_OF_LIST         0x0000 /* End-Of-List */
69 #define PPPOE_TAG_SERVICE_NAME        0x0101 /* Service-Name */
70 #define PPPOE_TAG_AC_NAME             0x0102 /* AC-Name */
71 #define PPPOE_TAG_HOST_UNIQ           0x0103 /* Host-Uniq */
72 #define PPPOE_TAG_AC_COOKIE           0x0104 /* AC-Cookie */
73 #define PPPOE_TAG_VENDOR_SPECIFIC     0x0105 /* Vendor-Specific */
74 #define PPPOE_TAG_RELAY_SESSION_ID    0x0110 /* Relay-Session-Id */
75 #define PPPOE_TAG_SERVICE_NAME_ERROR  0x0201 /* Service-Name-Error */
76 #define PPPOE_TAG_AC_SYS_ERROR        0x0202 /* AC-System Error */
77 #define PPPOE_TAG_GEN_ERROR           0x0203 /* Generic-Error */
78 
79 void DecodePPPOERegisterTests(void);
80 
81 #endif /* __DECODE_PPPOE_H__ */
82 
83