if_pppox.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. struct pppolac_opt {
  41. __u32 local;
  42. __u32 remote;
  43. __u32 recv_sequence;
  44. __u32 xmit_sequence;
  45. atomic_t sequencing;
  46. int (*backlog_rcv)(struct sock *sk_udp, struct sk_buff *skb);
  47. };
  48. struct pppopns_opt {
  49. __u16 local;
  50. __u16 remote;
  51. __u32 recv_sequence;
  52. __u32 xmit_sequence;
  53. void (*data_ready)(struct sock *sk_raw, int length);
  54. int (*backlog_rcv)(struct sock *sk_raw, struct sk_buff *skb);
  55. };
  56. #include <net/sock.h>
  57. struct pppox_sock {
  58. /* struct sock must be the first member of pppox_sock */
  59. struct sock sk;
  60. struct ppp_channel chan;
  61. struct pppox_sock *next; /* for hash table */
  62. union {
  63. struct pppoe_opt pppoe;
  64. struct pptp_opt pptp;
  65. struct pppolac_opt lac;
  66. struct pppopns_opt pns;
  67. } proto;
  68. __be16 num;
  69. };
  70. #define pppoe_dev proto.pppoe.dev
  71. #define pppoe_ifindex proto.pppoe.ifindex
  72. #define pppoe_pa proto.pppoe.pa
  73. #define pppoe_relay proto.pppoe.relay
  74. static inline struct pppox_sock *pppox_sk(struct sock *sk)
  75. {
  76. return (struct pppox_sock *)sk;
  77. }
  78. static inline struct sock *sk_pppox(struct pppox_sock *po)
  79. {
  80. return (struct sock *)po;
  81. }
  82. struct module;
  83. struct pppox_proto {
  84. int (*create)(struct net *net, struct socket *sock);
  85. int (*ioctl)(struct socket *sock, unsigned int cmd,
  86. unsigned long arg);
  87. struct module *owner;
  88. };
  89. extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
  90. extern void unregister_pppox_proto(int proto_num);
  91. extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */
  92. extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
  93. /* PPPoX socket states */
  94. enum {
  95. PPPOX_NONE = 0, /* initial state */
  96. PPPOX_CONNECTED = 1, /* connection established ==TCP_ESTABLISHED */
  97. PPPOX_BOUND = 2, /* bound to ppp device */
  98. PPPOX_RELAY = 4, /* forwarding is enabled */
  99. PPPOX_ZOMBIE = 8, /* dead, but still bound to ppp device */
  100. PPPOX_DEAD = 16 /* dead, useless, please clean me up!*/
  101. };
  102. #endif /* !(__LINUX_IF_PPPOX_H) */