blob: 6aad18a517d3ea8f9c7861ac2ef327cbc26b9a21 [file] [log] [blame]
David Howells607ca462012-10-13 10:46:48 +01001/***************************************************************************
2 * Linux PPP over X - Generic PPP transport layer sockets
3 * Linux PPP over Ethernet (PPPoE) Socket Implementation (RFC 2516)
4 *
5 * This file supplies definitions required by the PPP over Ethernet driver
6 * (pppox.c). All version information wrt this file is located in pppox.c
7 *
8 * License:
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 *
14 */
15
16#ifndef _UAPI__LINUX_IF_PPPOX_H
17#define _UAPI__LINUX_IF_PPPOX_H
18
19
20#include <linux/types.h>
21#include <asm/byteorder.h>
22
23#include <linux/socket.h>
Mikko Rapelib47b0cc2016-08-22 20:32:38 +020024#include <linux/if.h>
David Howells607ca462012-10-13 10:46:48 +010025#include <linux/if_ether.h>
26#include <linux/if_pppol2tp.h>
Chia-chi Yeh5ebc1fc2009-05-08 04:02:40 +080027#include <linux/if_pppolac.h>
Chia-chi Yeh70511fd2009-06-12 01:09:30 +080028#include <linux/if_pppopns.h>
Mikko Rapelieafe9212016-08-22 20:32:43 +020029#include <linux/in.h>
30#include <linux/in6.h>
David Howells607ca462012-10-13 10:46:48 +010031
32/* For user-space programs to pick up these definitions
33 * which they wouldn't get otherwise without defining __KERNEL__
34 */
35#ifndef AF_PPPOX
36#define AF_PPPOX 24
37#define PF_PPPOX AF_PPPOX
38#endif /* !(AF_PPPOX) */
39
40/************************************************************************
41 * PPPoE addressing definition
42 */
43typedef __be16 sid_t;
44struct pppoe_addr {
45 sid_t sid; /* Session identifier */
46 unsigned char remote[ETH_ALEN]; /* Remote address */
47 char dev[IFNAMSIZ]; /* Local device to use */
48};
49
50/************************************************************************
51 * PPTP addressing definition
52 */
53struct pptp_addr {
stephen hemmingerebd8b932013-08-10 15:22:58 -070054 __u16 call_id;
David Howells607ca462012-10-13 10:46:48 +010055 struct in_addr sin_addr;
56};
57
58/************************************************************************
59 * Protocols supported by AF_PPPOX
60 */
61#define PX_PROTO_OE 0 /* Currently just PPPoE */
62#define PX_PROTO_OL2TP 1 /* Now L2TP also */
63#define PX_PROTO_PPTP 2
Chia-chi Yeh5ebc1fc2009-05-08 04:02:40 +080064#define PX_PROTO_OLAC 3
Chia-chi Yeh70511fd2009-06-12 01:09:30 +080065#define PX_PROTO_OPNS 4
66#define PX_MAX_PROTO 5
David Howells607ca462012-10-13 10:46:48 +010067
68struct sockaddr_pppox {
69 __kernel_sa_family_t sa_family; /* address family, AF_PPPOX */
70 unsigned int sa_protocol; /* protocol identifier */
71 union {
72 struct pppoe_addr pppoe;
73 struct pptp_addr pptp;
74 } sa_addr;
75} __packed;
76
77/* The use of the above union isn't viable because the size of this
78 * struct must stay fixed over time -- applications use sizeof(struct
79 * sockaddr_pppox) to fill it. We use a protocol specific sockaddr
80 * type instead.
81 */
82struct sockaddr_pppol2tp {
83 __kernel_sa_family_t sa_family; /* address family, AF_PPPOX */
84 unsigned int sa_protocol; /* protocol identifier */
85 struct pppol2tp_addr pppol2tp;
86} __packed;
87
88struct sockaddr_pppol2tpin6 {
89 __kernel_sa_family_t sa_family; /* address family, AF_PPPOX */
90 unsigned int sa_protocol; /* protocol identifier */
91 struct pppol2tpin6_addr pppol2tp;
92} __packed;
93
94/* The L2TPv3 protocol changes tunnel and session ids from 16 to 32
95 * bits. So we need a different sockaddr structure.
96 */
97struct sockaddr_pppol2tpv3 {
98 __kernel_sa_family_t sa_family; /* address family, AF_PPPOX */
99 unsigned int sa_protocol; /* protocol identifier */
100 struct pppol2tpv3_addr pppol2tp;
101} __packed;
102
103struct sockaddr_pppol2tpv3in6 {
104 __kernel_sa_family_t sa_family; /* address family, AF_PPPOX */
105 unsigned int sa_protocol; /* protocol identifier */
106 struct pppol2tpv3in6_addr pppol2tp;
107} __packed;
108
109/*********************************************************************
110 *
111 * ioctl interface for defining forwarding of connections
112 *
113 ********************************************************************/
114
115#define PPPOEIOCSFWD _IOW(0xB1 ,0, size_t)
116#define PPPOEIOCDFWD _IO(0xB1 ,1)
117/*#define PPPOEIOCGFWD _IOWR(0xB1,2, size_t)*/
118
119/* Codes to identify message types */
120#define PADI_CODE 0x09
121#define PADO_CODE 0x07
122#define PADR_CODE 0x19
123#define PADS_CODE 0x65
124#define PADT_CODE 0xa7
125struct pppoe_tag {
126 __be16 tag_type;
127 __be16 tag_len;
128 char tag_data[0];
129} __attribute__ ((packed));
130
131/* Tag identifiers */
132#define PTT_EOL __cpu_to_be16(0x0000)
133#define PTT_SRV_NAME __cpu_to_be16(0x0101)
134#define PTT_AC_NAME __cpu_to_be16(0x0102)
135#define PTT_HOST_UNIQ __cpu_to_be16(0x0103)
136#define PTT_AC_COOKIE __cpu_to_be16(0x0104)
137#define PTT_VENDOR __cpu_to_be16(0x0105)
138#define PTT_RELAY_SID __cpu_to_be16(0x0110)
139#define PTT_SRV_ERR __cpu_to_be16(0x0201)
140#define PTT_SYS_ERR __cpu_to_be16(0x0202)
141#define PTT_GEN_ERR __cpu_to_be16(0x0203)
142
143struct pppoe_hdr {
144#if defined(__LITTLE_ENDIAN_BITFIELD)
David Howells607ca462012-10-13 10:46:48 +0100145 __u8 type : 4;
Changli Gaob1a5a342013-06-29 00:15:51 +0800146 __u8 ver : 4;
David Howells607ca462012-10-13 10:46:48 +0100147#elif defined(__BIG_ENDIAN_BITFIELD)
David Howells607ca462012-10-13 10:46:48 +0100148 __u8 ver : 4;
Changli Gaob1a5a342013-06-29 00:15:51 +0800149 __u8 type : 4;
David Howells607ca462012-10-13 10:46:48 +0100150#else
151#error "Please fix <asm/byteorder.h>"
152#endif
153 __u8 code;
154 __be16 sid;
155 __be16 length;
156 struct pppoe_tag tag[0];
157} __packed;
158
159/* Length of entire PPPoE + PPP header */
160#define PPPOE_SES_HLEN 8
161
162
163#endif /* _UAPI__LINUX_IF_PPPOX_H */