if_pppox.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /***************************************************************************
  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. #ifndef __LINUX_IF_PPPOX_H
  16. #define __LINUX_IF_PPPOX_H
  17. #include <linux/if.h>
  18. #include <linux/netdevice.h>
  19. #include <linux/ppp_channel.h>
  20. #include <linux/skbuff.h>
  21. #include <uapi/linux/if_pppox.h>
  22. static inline struct pppoe_hdr *pppoe_hdr(const struct sk_buff *skb)
  23. {
  24. return (struct pppoe_hdr *)skb_network_header(skb);
  25. }
  26. struct pppoe_opt {
  27. struct net_device *dev; /* device associated with socket*/
  28. int ifindex; /* ifindex of device associated with socket */
  29. struct pppoe_addr pa; /* what this socket is bound to*/
  30. struct sockaddr_pppox relay; /* what socket data will be
  31. relayed to (PPPoE relaying) */
  32. };
  33. struct pptp_opt {
  34. struct pptp_addr src_addr;
  35. struct pptp_addr dst_addr;
  36. u32 ack_sent, ack_recv;
  37. u32 seq_sent, seq_recv;
  38. int ppp_flags;
  39. };
  40. #include <net/sock.h>
  41. struct pppox_sock {
  42. /* struct sock must be the first member of pppox_sock */
  43. struct sock sk;
  44. struct ppp_channel chan;
  45. struct pppox_sock *next; /* for hash table */
  46. union {
  47. struct pppoe_opt pppoe;
  48. struct pptp_opt pptp;
  49. } proto;
  50. __be16 num;
  51. };
  52. #define pppoe_dev proto.pppoe.dev
  53. #define pppoe_ifindex proto.pppoe.ifindex
  54. #define pppoe_pa proto.pppoe.pa
  55. #define pppoe_relay proto.pppoe.relay
  56. static inline struct pppox_sock *pppox_sk(struct sock *sk)
  57. {
  58. return (struct pppox_sock *)sk;
  59. }
  60. static inline struct sock *sk_pppox(struct pppox_sock *po)
  61. {
  62. return (struct sock *)po;
  63. }
  64. struct module;
  65. struct pppox_proto {
  66. int (*create)(struct net *net, struct socket *sock);
  67. int (*ioctl)(struct socket *sock, unsigned int cmd,
  68. unsigned long arg);
  69. struct module *owner;
  70. };
  71. extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
  72. extern void unregister_pppox_proto(int proto_num);
  73. extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */
  74. extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
  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_ZOMBIE = 8, /* dead, but still bound to ppp device */
  82. PPPOX_DEAD = 16 /* dead, useless, please clean me up!*/
  83. };
  84. #endif /* !(__LINUX_IF_PPPOX_H) */