1 /* $OpenBSD: if_pppvar.h,v 1.21 2024/02/28 16:08:34 denis 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 76 #ifndef _NET_IF_PPPVAR_H_ 77 #define _NET_IF_PPPVAR_H_ 78 79 /* 80 * Supported network protocols. These values are used for 81 * indexing sc_npmode. 82 */ 83 #define NP_IP 0 /* Internet Protocol */ 84 #define NP_IPV6 1 /* Internet Protocol v6 */ 85 #define NUM_NP 2 /* Number of NPs. */ 86 87 struct ppp_pkt; 88 89 struct ppp_pkt_list { 90 struct mutex pl_mtx; 91 struct ppp_pkt *pl_head; 92 struct ppp_pkt *pl_tail; 93 u_int pl_count; 94 u_int pl_limit; 95 }; 96 97 /* 98 * Structure describing each ppp unit. 99 */ 100 struct ppp_softc { 101 struct ifnet sc_if; /* network-visible interface */ 102 struct timeout sc_timo; /* timeout control (for ptys) */ 103 int sc_unit; /* XXX unit number */ 104 u_int sc_flags; /* control/status bits; see if_ppp.h */ 105 void *sc_devp; /* pointer to device-dep structure */ 106 void (*sc_start)(struct ppp_softc *); /* start output proc */ 107 void (*sc_ctlp)(struct ppp_softc *); /* rcvd control pkt */ 108 void (*sc_relinq)(struct ppp_softc *); /* relinquish ifunit */ 109 u_int16_t sc_mru; /* max receive unit */ 110 pid_t sc_xfer; /* used in transferring unit */ 111 struct ppp_pkt_list sc_rawq; /* received packets */ 112 struct mbuf_queue sc_inq; /* queue of input packets for daemon */ 113 struct ifqueue sc_fastq; /* interactive output packet q */ 114 struct mbuf *sc_togo; /* output packet ready to go */ 115 struct mbuf_list sc_npqueue; /* output packets not to be sent yet */ 116 struct pppstat sc_stats; /* count of bytes/pkts sent/rcvd */ 117 enum NPmode sc_npmode[NUM_NP]; /* what to do with each NP */ 118 struct compressor *sc_xcomp; /* transmit compressor */ 119 void *sc_xc_state; /* transmit compressor state */ 120 struct compressor *sc_rcomp; /* receive decompressor */ 121 void *sc_rc_state; /* receive decompressor state */ 122 time_t sc_last_sent; /* time (secs) last NP pkt sent */ 123 time_t sc_last_recv; /* time (secs) last NP pkt rcvd */ 124 struct bpf_program sc_pass_filt; /* filter for packets to pass */ 125 struct bpf_program sc_active_filt; /* filter for "non-idle" packets */ 126 #ifdef VJC 127 struct slcompress *sc_comp; /* vjc control buffer */ 128 #endif 129 130 /* Device-dependent part for async lines. */ 131 ext_accm sc_asyncmap; /* async control character map */ 132 u_int32_t sc_rasyncmap; /* receive async control char map */ 133 struct mbuf *sc_outm; /* mbuf chain currently being output */ 134 struct ppp_pkt *sc_pkt; /* pointer to input pkt chain */ 135 struct ppp_pkt *sc_pktc; /* pointer to current input pkt */ 136 uint8_t *sc_pktp; /* ptr to next char in input pkt */ 137 u_int16_t sc_ilen; /* length of input packet so far */ 138 u_int16_t sc_fcs; /* FCS so far (input) */ 139 u_int16_t sc_outfcs; /* FCS so far for output packet */ 140 u_char sc_rawin[16]; /* chars as received */ 141 int sc_rawin_count; /* # in sc_rawin */ 142 LIST_ENTRY(ppp_softc) sc_list; /* all ppp interfaces */ 143 }; 144 145 #ifdef _KERNEL 146 147 struct ppp_pkt_hdr { 148 struct ppp_pkt *ph_next; /* next in pkt chain */ 149 struct ppp_pkt *ph_pkt; /* prev in chain or next in list */ 150 uint16_t ph_len; 151 uint16_t ph_errmark; 152 }; 153 154 struct ppp_pkt { 155 struct ppp_pkt_hdr p_hdr; 156 uint8_t p_buf[MCLBYTES - sizeof(struct ppp_pkt_hdr)]; 157 }; 158 159 void ppp_pkt_free(struct ppp_pkt *); 160 161 #define PKT_NEXT(_p) ((_p)->p_hdr.ph_next) 162 #define PKT_PREV(_p) ((_p)->p_hdr.ph_pkt) 163 #define PKT_NEXTPKT(_p) ((_p)->p_hdr.ph_pkt) 164 #define PKT_LEN(_p) ((_p)->p_hdr.ph_len) 165 166 extern struct ppp_softc ppp_softc[]; 167 168 struct ppp_softc *pppalloc(pid_t pid); 169 void pppdealloc(struct ppp_softc *sc); 170 int pppioctl(struct ppp_softc *sc, u_long cmd, caddr_t data, 171 int flag, struct proc *p); 172 void ppppktin(struct ppp_softc *sc, struct ppp_pkt *pkt, int lost); 173 struct mbuf *ppp_dequeue(struct ppp_softc *sc); 174 void ppp_restart(struct ppp_softc *sc); 175 int pppoutput(struct ifnet *, struct mbuf *, 176 struct sockaddr *, struct rtentry *); 177 #endif /* _KERNEL */ 178 #endif /* _NET_IF_PPPVAR_H_ */ 179