1 /*- 2 * Copyright (c) 2001 Brian Somers <brian@Awfulhak.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD: src/usr.sbin/ppp/ncp.h,v 1.2.26.1 2010/12/21 17:10:29 kensmith Exp $ 27 */ 28 29 struct port_range { 30 unsigned nports; /* How many ports */ 31 unsigned maxports; /* How many allocated (malloc) ports */ 32 u_short *port; /* The actual ports */ 33 }; 34 35 struct ncp { 36 struct { 37 u_long sendpipe; /* route sendpipe size */ 38 u_long recvpipe; /* route recvpipe size */ 39 40 struct { 41 struct port_range tcp, udp; /* The range of urgent ports */ 42 unsigned tos : 1; /* Urgent IPTOS_LOWDELAY packets ? */ 43 } urgent; 44 } cfg; 45 46 int afq; /* Next address family to queue */ 47 48 struct sticky_route *route; /* List of dynamic routes */ 49 50 struct ipcp ipcp; /* Our IPCP FSM */ 51 #ifndef NOINET6 52 struct ipv6cp ipv6cp; /* Our IPV6CP FSM */ 53 #endif 54 struct mp mp; /* Our MP */ 55 }; 56 57 extern void ncp_Init(struct ncp *, struct bundle *); 58 extern void ncp_Destroy(struct ncp *); 59 extern int ncp_fsmStart(struct ncp *, struct bundle *); 60 extern void ncp_IfaceAddrAdded(struct ncp *, const struct iface_addr *); 61 extern void ncp_IfaceAddrDeleted(struct ncp *, const struct iface_addr *); 62 extern void ncp_SetLink(struct ncp *, struct link *); 63 extern void ncp_Enqueue(struct ncp *, int, unsigned, char *, int); 64 extern void ncp_DeleteQueues(struct ncp *); 65 extern size_t ncp_QueueLen(struct ncp *); 66 extern size_t ncp_FillPhysicalQueues(struct ncp *, struct bundle *); 67 extern int ncp_PushPacket(struct ncp *, int *, struct link *); 68 extern int ncp_IsUrgentPort(struct port_range *, u_short, u_short); 69 extern void ncp_AddUrgentPort(struct port_range *, u_short); 70 extern void ncp_RemoveUrgentPort(struct port_range *, u_short); 71 extern void ncp_ClearUrgentPorts(struct port_range *); 72 extern int ncp_Show(struct cmdargs const *); 73 extern int ncp_LayersOpen(struct ncp *); 74 extern int ncp_LayersUnfinished(struct ncp *); 75 extern void ncp_Close(struct ncp *); 76 extern void ncp2initial(struct ncp *); 77 78 #define ncp_IsUrgentTcpPort(ncp, p1, p2) \ 79 ncp_IsUrgentPort(&(ncp)->cfg.urgent.tcp, p1, p2) 80 #define ncp_IsUrgentUdpPort(ncp, p1, p2) \ 81 ncp_IsUrgentPort(&(ncp)->cfg.urgent.udp, p1, p2) 82 #define ncp_AddUrgentTcpPort(ncp, p) \ 83 ncp_AddUrgentPort(&(ncp)->cfg.urgent.tcp, p) 84 #define ncp_AddUrgentUdpPort(ncp, p) \ 85 ncp_AddUrgentPort(&(ncp)->cfg.urgent.udp, p) 86 #define ncp_RemoveUrgentTcpPort(ncp, p) \ 87 ncp_RemoveUrgentPort(&(ncp)->cfg.urgent.tcp, p) 88 #define ncp_RemoveUrgentUdpPort(ncp, p) \ 89 ncp_RemoveUrgentPort(&(ncp)->cfg.urgent.udp, p) 90 #define ncp_ClearUrgentTcpPorts(ncp) \ 91 ncp_ClearUrgentPorts(&(ncp)->cfg.urgent.tcp) 92 #define ncp_ClearUrgentUdpPorts(ncp) \ 93 ncp_ClearUrgentPorts(&(ncp)->cfg.urgent.udp) 94 #define ncp_ClearUrgentTOS(ncp) (ncp)->cfg.urgent.tos = 0; 95 #define ncp_SetUrgentTOS(ncp) (ncp)->cfg.urgent.tos = 1; 96 97 #ifndef NOINET6 98 #define isncp(proto) ((proto) == PROTO_IPCP || (proto) == PROTO_IPV6CP) 99 #else 100 #define isncp(proto) ((proto) == PROTO_IPCP) 101 #endif 102