if_pppox.h 3.1 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/***************************************************************************
 * Linux PPP over X - Generic PPP transport layer sockets
 * Linux PPP over Ethernet (PPPoE) Socket Implementation (RFC 2516) 
 *
 * This file supplies definitions required by the PPP over Ethernet driver
 * (pppox.c).  All version information wrt this file is located in pppox.c
 *
 * License:
 *		This program is free software; you can redistribute it and/or
 *		modify it under the terms of the GNU General Public License
 *		as published by the Free Software Foundation; either version
 *		2 of the License, or (at your option) any later version.
 *
 */
#ifndef __LINUX_IF_PPPOX_H
#define __LINUX_IF_PPPOX_H

#include <linux/if.h>
#include <linux/netdevice.h>
#include <linux/ppp_channel.h>
21
#include <linux/skbuff.h>
22
#include <linux/workqueue.h>
23
#include <uapi/linux/if_pppox.h>
24 25 26

static inline struct pppoe_hdr *pppoe_hdr(const struct sk_buff *skb)
{
27
	return (struct pppoe_hdr *)skb_network_header(skb);
28 29
}

L
Linus Torvalds 已提交
30 31
struct pppoe_opt {
	struct net_device      *dev;	  /* device associated with socket*/
32
	int			ifindex;  /* ifindex of device associated with socket */
L
Linus Torvalds 已提交
33 34 35
	struct pppoe_addr	pa;	  /* what this socket is bound to*/
	struct sockaddr_pppox	relay;	  /* what socket data will be
					     relayed to (PPPoE relaying) */
36
	struct work_struct      padt_work;/* Work item for handling PADT */
L
Linus Torvalds 已提交
37 38
};

39 40 41 42 43 44 45
struct pptp_opt {
	struct pptp_addr src_addr;
	struct pptp_addr dst_addr;
	u32 ack_sent, ack_recv;
	u32 seq_sent, seq_recv;
	int ppp_flags;
};
L
Linus Torvalds 已提交
46 47 48 49
#include <net/sock.h>

struct pppox_sock {
	/* struct sock must be the first member of pppox_sock */
50 51
	struct sock sk;
	struct ppp_channel chan;
L
Linus Torvalds 已提交
52 53 54
	struct pppox_sock	*next;	  /* for hash table */
	union {
		struct pppoe_opt pppoe;
55
		struct pptp_opt  pptp;
L
Linus Torvalds 已提交
56
	} proto;
A
Al Viro 已提交
57
	__be16			num;
L
Linus Torvalds 已提交
58 59
};
#define pppoe_dev	proto.pppoe.dev
60
#define pppoe_ifindex	proto.pppoe.ifindex
L
Linus Torvalds 已提交
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
#define pppoe_pa	proto.pppoe.pa
#define pppoe_relay	proto.pppoe.relay

static inline struct pppox_sock *pppox_sk(struct sock *sk)
{
	return (struct pppox_sock *)sk;
}

static inline struct sock *sk_pppox(struct pppox_sock *po)
{
	return (struct sock *)po;
}

struct module;

struct pppox_proto {
77
	int		(*create)(struct net *net, struct socket *sock, int kern);
L
Linus Torvalds 已提交
78 79 80 81 82
	int		(*ioctl)(struct socket *sock, unsigned int cmd,
				 unsigned long arg);
	struct module	*owner;
};

83
extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
L
Linus Torvalds 已提交
84 85
extern void unregister_pppox_proto(int proto_num);
extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */
86
extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
87 88 89
extern int pppox_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);

#define PPPOEIOCSFWD32    _IOW(0xB1 ,0, compat_size_t)
L
Linus Torvalds 已提交
90 91 92 93 94 95 96 97 98 99 100

/* PPPoX socket states */
enum {
    PPPOX_NONE		= 0,  /* initial state */
    PPPOX_CONNECTED	= 1,  /* connection established ==TCP_ESTABLISHED */
    PPPOX_BOUND		= 2,  /* bound to ppp device */
    PPPOX_RELAY		= 4,  /* forwarding is enabled */
    PPPOX_DEAD		= 16  /* dead, useless, please clean me up!*/
};

#endif /* !(__LINUX_IF_PPPOX_H) */