if_pppox.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /***************************************************************************
  3. * Linux PPP over X - Generic PPP transport layer sockets
  4. * Linux PPP over Ethernet (PPPoE) Socket Implementation (RFC 2516)
  5. *
  6. * This file supplies definitions required by the PPP over Ethernet driver
  7. * (pppox.c). All version information wrt this file is located in pppox.c
  8. */
  9. #ifndef __LINUX_IF_PPPOX_H
  10. #define __LINUX_IF_PPPOX_H
  11. #include <linux/if.h>
  12. #include <linux/netdevice.h>
  13. #include <linux/ppp_channel.h>
  14. #include <linux/skbuff.h>
  15. #include <linux/workqueue.h>
  16. #include <uapi/linux/if_pppox.h>
  17. static inline struct pppoe_hdr *pppoe_hdr(const struct sk_buff *skb)
  18. {
  19. return (struct pppoe_hdr *)skb_network_header(skb);
  20. }
  21. struct pppoe_opt {
  22. struct net_device *dev; /* device associated with socket*/
  23. int ifindex; /* ifindex of device associated with socket */
  24. struct pppoe_addr pa; /* what this socket is bound to*/
  25. struct sockaddr_pppox relay; /* what socket data will be
  26. relayed to (PPPoE relaying) */
  27. struct work_struct padt_work;/* Work item for handling PADT */
  28. };
  29. struct pptp_opt {
  30. struct pptp_addr src_addr;
  31. struct pptp_addr dst_addr;
  32. u32 ack_sent, ack_recv;
  33. u32 seq_sent, seq_recv;
  34. int ppp_flags;
  35. };
  36. #include <net/sock.h>
  37. struct pppox_sock {
  38. /* struct sock must be the first member of pppox_sock */
  39. struct sock sk;
  40. struct ppp_channel chan;
  41. struct pppox_sock *next; /* for hash table */
  42. union {
  43. struct pppoe_opt pppoe;
  44. struct pptp_opt pptp;
  45. } proto;
  46. __be16 num;
  47. };
  48. #define pppoe_dev proto.pppoe.dev
  49. #define pppoe_ifindex proto.pppoe.ifindex
  50. #define pppoe_pa proto.pppoe.pa
  51. #define pppoe_relay proto.pppoe.relay
  52. static inline struct pppox_sock *pppox_sk(struct sock *sk)
  53. {
  54. return (struct pppox_sock *)sk;
  55. }
  56. static inline struct sock *sk_pppox(struct pppox_sock *po)
  57. {
  58. return (struct sock *)po;
  59. }
  60. struct module;
  61. struct pppox_proto {
  62. int (*create)(struct net *net, struct socket *sock, int kern);
  63. int (*ioctl)(struct socket *sock, unsigned int cmd,
  64. unsigned long arg);
  65. struct module *owner;
  66. };
  67. extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
  68. extern void unregister_pppox_proto(int proto_num);
  69. extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */
  70. extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
  71. extern int pppox_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
  72. #define PPPOEIOCSFWD32 _IOW(0xB1 ,0, compat_size_t)
  73. /* PPPoX socket states */
  74. enum {
  75. PPPOX_NONE = 0, /* initial state */
  76. PPPOX_CONNECTED = 1, /* connection established ==TCP_ESTABLISHED */
  77. PPPOX_BOUND = 2, /* bound to ppp device */
  78. PPPOX_RELAY = 4, /* forwarding is enabled */
  79. PPPOX_DEAD = 16 /* dead, useless, please clean me up!*/
  80. };
  81. #endif /* !(__LINUX_IF_PPPOX_H) */