if_pppvar.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /* $OpenBSD: if_pppvar.h,v 1.17 2015/06/03 00:50:09 dlg Exp $ */
  2. /* $NetBSD: if_pppvar.h,v 1.5 1997/01/03 07:23:29 mikel Exp $ */
  3. /*
  4. * if_pppvar.h - private structures and declarations for PPP.
  5. *
  6. * Copyright (c) 1989-2002 Paul Mackerras. All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in
  17. * the documentation and/or other materials provided with the
  18. * distribution.
  19. *
  20. * 3. The name(s) of the authors of this software must not be used to
  21. * endorse or promote products derived from this software without
  22. * prior written permission.
  23. *
  24. * 4. Redistributions of any form whatsoever must retain the following
  25. * acknowledgment:
  26. * "This product includes software developed by Paul Mackerras
  27. * <paulus@samba.org>".
  28. *
  29. * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
  30. * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  31. * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
  32. * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  33. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
  34. * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  35. * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  36. *
  37. * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
  38. *
  39. * Redistribution and use in source and binary forms, with or without
  40. * modification, are permitted provided that the following conditions
  41. * are met:
  42. *
  43. * 1. Redistributions of source code must retain the above copyright
  44. * notice, this list of conditions and the following disclaimer.
  45. *
  46. * 2. Redistributions in binary form must reproduce the above copyright
  47. * notice, this list of conditions and the following disclaimer in
  48. * the documentation and/or other materials provided with the
  49. * distribution.
  50. *
  51. * 3. The name "Carnegie Mellon University" must not be used to
  52. * endorse or promote products derived from this software without
  53. * prior written permission. For permission or any legal
  54. * details, please contact
  55. * Office of Technology Transfer
  56. * Carnegie Mellon University
  57. * 5000 Forbes Avenue
  58. * Pittsburgh, PA 15213-3890
  59. * (412) 268-4387, fax: (412) 268-7395
  60. * tech-transfer@andrew.cmu.edu
  61. *
  62. * 4. Redistributions of any form whatsoever must retain the following
  63. * acknowledgment:
  64. * "This product includes software developed by Computing Services
  65. * at Carnegie Mellon University (http://www.cmu.edu/computing/)."
  66. *
  67. * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
  68. * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  69. * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
  70. * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  71. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
  72. * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  73. * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  74. */
  75. #ifndef _NET_IF_PPPVAR_H_
  76. #define _NET_IF_PPPVAR_H_
  77. /*
  78. * Supported network protocols. These values are used for
  79. * indexing sc_npmode.
  80. */
  81. #define NP_IP 0 /* Internet Protocol */
  82. #define NUM_NP 1 /* Number of NPs. */
  83. struct ppp_pkt;
  84. struct ppp_pkt_list {
  85. struct mutex pl_mtx;
  86. struct ppp_pkt *pl_head;
  87. struct ppp_pkt *pl_tail;
  88. u_int pl_count;
  89. u_int pl_limit;
  90. };
  91. /*
  92. * Structure describing each ppp unit.
  93. */
  94. struct ppp_softc {
  95. struct ifnet sc_if; /* network-visible interface */
  96. struct timeout sc_timo; /* timeout control (for ptys) */
  97. int sc_unit; /* XXX unit number */
  98. u_int sc_flags; /* control/status bits; see if_ppp.h */
  99. void *sc_devp; /* pointer to device-dep structure */
  100. void (*sc_start)(struct ppp_softc *); /* start output proc */
  101. void (*sc_ctlp)(struct ppp_softc *); /* rcvd control pkt */
  102. void (*sc_relinq)(struct ppp_softc *); /* relinquish ifunit */
  103. u_int16_t sc_mru; /* max receive unit */
  104. pid_t sc_xfer; /* used in transferring unit */
  105. struct ppp_pkt_list sc_rawq; /* received packets */
  106. struct mbuf_queue sc_inq; /* queue of input packets for daemon */
  107. struct ifqueue sc_fastq; /* interactive output packet q */
  108. struct mbuf *sc_togo; /* output packet ready to go */
  109. struct mbuf *sc_npqueue; /* output packets not to be sent yet */
  110. struct mbuf **sc_npqtail; /* ptr to last next ptr in npqueue */
  111. struct pppstat sc_stats; /* count of bytes/pkts sent/rcvd */
  112. caddr_t sc_bpf; /* hook for BPF */
  113. enum NPmode sc_npmode[NUM_NP]; /* what to do with each NP */
  114. struct compressor *sc_xcomp; /* transmit compressor */
  115. void *sc_xc_state; /* transmit compressor state */
  116. struct compressor *sc_rcomp; /* receive decompressor */
  117. void *sc_rc_state; /* receive decompressor state */
  118. time_t sc_last_sent; /* time (secs) last NP pkt sent */
  119. time_t sc_last_recv; /* time (secs) last NP pkt rcvd */
  120. struct bpf_program sc_pass_filt; /* filter for packets to pass */
  121. struct bpf_program sc_active_filt; /* filter for "non-idle" packets */
  122. #ifdef VJC
  123. struct slcompress *sc_comp; /* vjc control buffer */
  124. #endif
  125. /* Device-dependent part for async lines. */
  126. ext_accm sc_asyncmap; /* async control character map */
  127. u_int32_t sc_rasyncmap; /* receive async control char map */
  128. struct mbuf *sc_outm; /* mbuf chain currently being output */
  129. struct ppp_pkt *sc_pkt; /* pointer to input pkt chain */
  130. struct ppp_pkt *sc_pktc; /* pointer to current input pkt */
  131. uint8_t *sc_pktp; /* ptr to next char in input pkt */
  132. u_int16_t sc_ilen; /* length of input packet so far */
  133. u_int16_t sc_fcs; /* FCS so far (input) */
  134. u_int16_t sc_outfcs; /* FCS so far for output packet */
  135. u_char sc_rawin[16]; /* chars as received */
  136. int sc_rawin_count; /* # in sc_rawin */
  137. LIST_ENTRY(ppp_softc) sc_list; /* all ppp interfaces */
  138. };
  139. #ifdef _KERNEL
  140. struct ppp_pkt_hdr {
  141. struct ppp_pkt *ph_next; /* next in pkt chain */
  142. struct ppp_pkt *ph_pkt; /* prev in chain or next in list */
  143. uint16_t ph_len;
  144. uint16_t ph_errmark;
  145. };
  146. struct ppp_pkt {
  147. struct ppp_pkt_hdr p_hdr;
  148. uint8_t p_buf[MCLBYTES - sizeof(struct ppp_pkt_hdr)];
  149. };
  150. void ppp_pkt_free(struct ppp_pkt *);
  151. #define PKT_NEXT(_p) ((_p)->p_hdr.ph_next)
  152. #define PKT_PREV(_p) ((_p)->p_hdr.ph_pkt)
  153. #define PKT_NEXTPKT(_p) ((_p)->p_hdr.ph_pkt)
  154. #define PKT_LEN(_p) ((_p)->p_hdr.ph_len)
  155. extern struct ppp_softc ppp_softc[];
  156. struct ppp_softc *pppalloc(pid_t pid);
  157. void pppdealloc(struct ppp_softc *sc);
  158. int pppioctl(struct ppp_softc *sc, u_long cmd, caddr_t data,
  159. int flag, struct proc *p);
  160. void ppppktin(struct ppp_softc *sc, struct ppp_pkt *pkt, int lost);
  161. struct mbuf *ppp_dequeue(struct ppp_softc *sc);
  162. void ppp_restart(struct ppp_softc *sc);
  163. int pppoutput(struct ifnet *, struct mbuf *,
  164. struct sockaddr *, struct rtentry *);
  165. #endif /* _KERNEL */
  166. #endif /* _NET_IF_PPPVAR_H_ */