* Sync comment with code's reality.
[dragonfly.git] / usr.sbin / ppp / ncp.h
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.1.4.1 2002/09/01 02:12:29 brian Exp $
27  * $DragonFly: src/usr.sbin/ppp/ncp.h,v 1.2 2003/06/17 04:30:00 dillon Exp $
28  */
29
30 struct port_range {
31   unsigned nports;              /* How many ports */
32   unsigned maxports;            /* How many allocated (malloc) ports */
33   u_short *port;                /* The actual ports */
34 };
35
36 struct ncp {
37   struct {
38     u_long sendpipe;                    /* route sendpipe size */
39     u_long recvpipe;                    /* route recvpipe size */
40
41     struct {
42       struct port_range tcp, udp;       /* The range of urgent ports */
43       unsigned tos : 1;                 /* Urgent IPTOS_LOWDELAY packets ? */
44     } urgent;
45   } cfg;
46
47   int afq;                      /* Next address family to queue */
48
49   struct sticky_route *route;   /* List of dynamic routes */
50
51   struct ipcp ipcp;             /* Our IPCP FSM */
52 #ifndef NOINET6
53   struct ipv6cp ipv6cp;         /* Our IPV6CP FSM */
54 #endif
55   struct mp mp;                 /* Our MP */
56 };
57
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, int, 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 void ncp_AddUrgentPort(struct port_range *, u_short);
71 extern void ncp_RemoveUrgentPort(struct port_range *, u_short);
72 extern void ncp_ClearUrgentPorts(struct port_range *);
73 extern int ncp_Show(struct cmdargs const *);
74 extern int ncp_LayersOpen(struct ncp *);
75 extern int ncp_LayersUnfinished(struct ncp *);
76 extern void ncp_Close(struct ncp *);
77 extern void ncp2initial(struct ncp *);
78
79 #define ncp_IsUrgentTcpPort(ncp, p1, p2) \
80           ncp_IsUrgentPort(&(ncp)->cfg.urgent.tcp, p1, p2)
81 #define ncp_IsUrgentUdpPort(ncp, p1, p2) \
82           ncp_IsUrgentPort(&(ncp)->cfg.urgent.udp, p1, p2)
83 #define ncp_AddUrgentTcpPort(ncp, p) \
84           ncp_AddUrgentPort(&(ncp)->cfg.urgent.tcp, p)
85 #define ncp_AddUrgentUdpPort(ncp, p) \
86           ncp_AddUrgentPort(&(ncp)->cfg.urgent.udp, p)
87 #define ncp_RemoveUrgentTcpPort(ncp, p) \
88           ncp_RemoveUrgentPort(&(ncp)->cfg.urgent.tcp, p)
89 #define ncp_RemoveUrgentUdpPort(ncp, p) \
90           ncp_RemoveUrgentPort(&(ncp)->cfg.urgent.udp, p)
91 #define ncp_ClearUrgentTcpPorts(ncp) \
92           ncp_ClearUrgentPorts(&(ncp)->cfg.urgent.tcp)
93 #define ncp_ClearUrgentUdpPorts(ncp) \
94           ncp_ClearUrgentPorts(&(ncp)->cfg.urgent.udp)
95 #define ncp_ClearUrgentTOS(ncp) (ncp)->cfg.urgent.tos = 0;
96 #define ncp_SetUrgentTOS(ncp) (ncp)->cfg.urgent.tos = 1;
97
98 #ifndef NOINET6
99 #define isncp(proto) ((proto) == PROTO_IPCP || (proto) == PROTO_IPV6CP)
100 #else
101 #define isncp(proto) ((proto) == PROTO_IPCP)
102 #endif