if_pppox.h 2.8 KB

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