if_pppox.h 2.9 KB

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