2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2001 Brian Somers <brian@Awfulhak.org>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
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
30 unsigned nports; /* How many ports */
31 unsigned maxports; /* How many allocated (malloc) ports */
32 u_short *port; /* The actual ports */
37 u_long sendpipe; /* route sendpipe size */
38 u_long recvpipe; /* route recvpipe size */
41 struct port_range tcp, udp; /* The range of urgent ports */
42 unsigned tos : 1; /* Urgent IPTOS_LOWDELAY packets ? */
43 int len; /* The size below which traffic is prioritised */
47 int afq; /* Next address family to queue */
49 struct sticky_route *route; /* List of dynamic routes */
51 struct ipcp ipcp; /* Our IPCP FSM */
53 struct ipv6cp ipv6cp; /* Our IPV6CP FSM */
55 struct mp mp; /* Our MP */
58 extern void ncp_Init(struct ncp *, struct bundle *);
59 extern void ncp_Destroy(struct ncp *);
60 extern int ncp_fsmStart(struct ncp *, struct bundle *);
61 extern void ncp_IfaceAddrAdded(struct ncp *, const struct iface_addr *);
62 extern void ncp_IfaceAddrDeleted(struct ncp *, const struct iface_addr *);
63 extern void ncp_SetLink(struct ncp *, struct link *);
64 extern void ncp_Enqueue(struct ncp *, int, unsigned, char *, int);
65 extern void ncp_DeleteQueues(struct ncp *);
66 extern size_t ncp_QueueLen(struct ncp *);
67 extern size_t ncp_FillPhysicalQueues(struct ncp *, struct bundle *);
68 extern int ncp_PushPacket(struct ncp *, int *, struct link *);
69 extern int ncp_IsUrgentPort(struct port_range *, u_short, u_short);
70 extern int ncp_IsUrgentTcpLen(struct ncp *, int);
71 extern void ncp_SetUrgentTcpLen(struct ncp *, int);
72 extern void ncp_AddUrgentPort(struct port_range *, u_short);
73 extern void ncp_RemoveUrgentPort(struct port_range *, u_short);
74 extern void ncp_ClearUrgentPorts(struct port_range *);
75 extern int ncp_Show(struct cmdargs const *);
76 extern int ncp_LayersOpen(struct ncp *);
77 extern int ncp_LayersUnfinished(struct ncp *);
78 extern void ncp_Close(struct ncp *);
79 extern void ncp2initial(struct ncp *);
81 #define ncp_IsUrgentTcpPort(ncp, p1, p2) \
82 ncp_IsUrgentPort(&(ncp)->cfg.urgent.tcp, p1, p2)
83 #define ncp_IsUrgentUdpPort(ncp, p1, p2) \
84 ncp_IsUrgentPort(&(ncp)->cfg.urgent.udp, p1, p2)
85 #define ncp_AddUrgentTcpPort(ncp, p) \
86 ncp_AddUrgentPort(&(ncp)->cfg.urgent.tcp, p)
87 #define ncp_AddUrgentUdpPort(ncp, p) \
88 ncp_AddUrgentPort(&(ncp)->cfg.urgent.udp, p)
89 #define ncp_RemoveUrgentTcpPort(ncp, p) \
90 ncp_RemoveUrgentPort(&(ncp)->cfg.urgent.tcp, p)
91 #define ncp_RemoveUrgentUdpPort(ncp, p) \
92 ncp_RemoveUrgentPort(&(ncp)->cfg.urgent.udp, p)
93 #define ncp_ClearUrgentTcpPorts(ncp) \
94 ncp_ClearUrgentPorts(&(ncp)->cfg.urgent.tcp)
95 #define ncp_ClearUrgentUdpPorts(ncp) \
96 ncp_ClearUrgentPorts(&(ncp)->cfg.urgent.udp)
97 #define ncp_ClearUrgentTOS(ncp) (ncp)->cfg.urgent.tos = 0
98 #define ncp_SetUrgentTOS(ncp) (ncp)->cfg.urgent.tos = 1
101 #define isncp(proto) ((proto) == PROTO_IPCP || (proto) == PROTO_IPV6CP)
103 #define isncp(proto) ((proto) == PROTO_IPCP)