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