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 int len; /* The size below which traffic is prioritised */ 46 } urgent; 47 } cfg; 48 49 int afq; /* Next address family to queue */ 50 51 struct sticky_route *route; /* List of dynamic routes */ 52 53 struct ipcp ipcp; /* Our IPCP FSM */ 54 #ifndef NOINET6 55 struct ipv6cp ipv6cp; /* Our IPV6CP FSM */ 56 #endif 57 struct mp mp; /* Our MP */ 58 }; 59 60 extern void ncp_Init(struct ncp *, struct bundle *); 61 extern void ncp_Destroy(struct ncp *); 62 extern int ncp_fsmStart(struct ncp *, struct bundle *); 63 extern void ncp_IfaceAddrAdded(struct ncp *, const struct iface_addr *); 64 extern void ncp_IfaceAddrDeleted(struct ncp *, const struct iface_addr *); 65 extern void ncp_SetLink(struct ncp *, struct link *); 66 extern void ncp_Enqueue(struct ncp *, int, unsigned, char *, int); 67 extern void ncp_DeleteQueues(struct ncp *); 68 extern size_t ncp_QueueLen(struct ncp *); 69 extern size_t ncp_FillPhysicalQueues(struct ncp *, struct bundle *); 70 extern int ncp_PushPacket(struct ncp *, int *, struct link *); 71 extern int ncp_IsUrgentPort(struct port_range *, u_short, u_short); 72 extern int ncp_IsUrgentTcpLen(struct ncp *, int); 73 extern void ncp_SetUrgentTcpLen(struct ncp *, int); 74 extern void ncp_AddUrgentPort(struct port_range *, u_short); 75 extern void ncp_RemoveUrgentPort(struct port_range *, u_short); 76 extern void ncp_ClearUrgentPorts(struct port_range *); 77 extern int ncp_Show(struct cmdargs const *); 78 extern int ncp_LayersOpen(struct ncp *); 79 extern int ncp_LayersUnfinished(struct ncp *); 80 extern void ncp_Close(struct ncp *); 81 extern void ncp2initial(struct ncp *); 82 83 #define ncp_IsUrgentTcpPort(ncp, p1, p2) \ 84 ncp_IsUrgentPort(&(ncp)->cfg.urgent.tcp, p1, p2) 85 #define ncp_IsUrgentUdpPort(ncp, p1, p2) \ 86 ncp_IsUrgentPort(&(ncp)->cfg.urgent.udp, p1, p2) 87 #define ncp_AddUrgentTcpPort(ncp, p) \ 88 ncp_AddUrgentPort(&(ncp)->cfg.urgent.tcp, p) 89 #define ncp_AddUrgentUdpPort(ncp, p) \ 90 ncp_AddUrgentPort(&(ncp)->cfg.urgent.udp, p) 91 #define ncp_RemoveUrgentTcpPort(ncp, p) \ 92 ncp_RemoveUrgentPort(&(ncp)->cfg.urgent.tcp, p) 93 #define ncp_RemoveUrgentUdpPort(ncp, p) \ 94 ncp_RemoveUrgentPort(&(ncp)->cfg.urgent.udp, p) 95 #define ncp_ClearUrgentTcpPorts(ncp) \ 96 ncp_ClearUrgentPorts(&(ncp)->cfg.urgent.tcp) 97 #define ncp_ClearUrgentUdpPorts(ncp) \ 98 ncp_ClearUrgentPorts(&(ncp)->cfg.urgent.udp) 99 #define ncp_ClearUrgentTOS(ncp) (ncp)->cfg.urgent.tos = 0; 100 #define ncp_SetUrgentTOS(ncp) (ncp)->cfg.urgent.tos = 1; 101 102 #ifndef NOINET6 103 #define isncp(proto) ((proto) == PROTO_IPCP || (proto) == PROTO_IPV6CP) 104 #else 105 #define isncp(proto) ((proto) == PROTO_IPCP) 106 #endif 107