130949fd4SBrian Somers /*- 230949fd4SBrian Somers * Copyright (c) 2001 Brian Somers <brian@Awfulhak.org> 330949fd4SBrian Somers * All rights reserved. 430949fd4SBrian Somers * 530949fd4SBrian Somers * Redistribution and use in source and binary forms, with or without 630949fd4SBrian Somers * modification, are permitted provided that the following conditions 730949fd4SBrian Somers * are met: 830949fd4SBrian Somers * 1. Redistributions of source code must retain the above copyright 930949fd4SBrian Somers * notice, this list of conditions and the following disclaimer. 1030949fd4SBrian Somers * 2. Redistributions in binary form must reproduce the above copyright 1130949fd4SBrian Somers * notice, this list of conditions and the following disclaimer in the 1230949fd4SBrian Somers * documentation and/or other materials provided with the distribution. 1330949fd4SBrian Somers * 1430949fd4SBrian Somers * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1530949fd4SBrian Somers * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1630949fd4SBrian Somers * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1730949fd4SBrian Somers * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1830949fd4SBrian Somers * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1930949fd4SBrian Somers * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2030949fd4SBrian Somers * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2130949fd4SBrian Somers * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2230949fd4SBrian Somers * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2330949fd4SBrian Somers * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2430949fd4SBrian Somers * SUCH DAMAGE. 2530949fd4SBrian Somers * 2630949fd4SBrian Somers * $FreeBSD$ 2730949fd4SBrian Somers */ 2830949fd4SBrian Somers 2930949fd4SBrian Somers struct port_range { 3030949fd4SBrian Somers unsigned nports; /* How many ports */ 3130949fd4SBrian Somers unsigned maxports; /* How many allocated (malloc) ports */ 3230949fd4SBrian Somers u_short *port; /* The actual ports */ 3330949fd4SBrian Somers }; 3430949fd4SBrian Somers 3530949fd4SBrian Somers struct ncp { 3630949fd4SBrian Somers struct { 3730949fd4SBrian Somers u_long sendpipe; /* route sendpipe size */ 3830949fd4SBrian Somers u_long recvpipe; /* route recvpipe size */ 3930949fd4SBrian Somers 4030949fd4SBrian Somers struct { 4130949fd4SBrian Somers struct port_range tcp, udp; /* The range of urgent ports */ 4230949fd4SBrian Somers unsigned tos : 1; /* Urgent IPTOS_LOWDELAY packets ? */ 4330949fd4SBrian Somers } urgent; 4430949fd4SBrian Somers } cfg; 4530949fd4SBrian Somers 4630949fd4SBrian Somers int afq; /* Next address family to queue */ 4730949fd4SBrian Somers 4830949fd4SBrian Somers struct sticky_route *route; /* List of dynamic routes */ 4930949fd4SBrian Somers 5030949fd4SBrian Somers struct ipcp ipcp; /* Our IPCP FSM */ 5130949fd4SBrian Somers #ifndef NOINET6 5230949fd4SBrian Somers struct ipv6cp ipv6cp; /* Our IPV6CP FSM */ 5330949fd4SBrian Somers #endif 5430949fd4SBrian Somers struct mp mp; /* Our MP */ 5530949fd4SBrian Somers }; 5630949fd4SBrian Somers 5730949fd4SBrian Somers extern void ncp_Init(struct ncp *, struct bundle *); 5830949fd4SBrian Somers extern void ncp_Destroy(struct ncp *); 5930949fd4SBrian Somers extern int ncp_fsmStart(struct ncp *, struct bundle *); 6030949fd4SBrian Somers extern void ncp_IfaceAddrAdded(struct ncp *, const struct iface_addr *); 6130949fd4SBrian Somers extern void ncp_IfaceAddrDeleted(struct ncp *, const struct iface_addr *); 6230949fd4SBrian Somers extern void ncp_SetLink(struct ncp *, struct link *); 6330949fd4SBrian Somers extern void ncp_Enqueue(struct ncp *, int, int, char *, int); 6430949fd4SBrian Somers extern void ncp_DeleteQueues(struct ncp *); 6530949fd4SBrian Somers extern size_t ncp_QueueLen(struct ncp *); 6630949fd4SBrian Somers extern size_t ncp_FillPhysicalQueues(struct ncp *, struct bundle *); 6730949fd4SBrian Somers extern int ncp_PushPacket(struct ncp *, int *, struct link *); 6830949fd4SBrian Somers extern int ncp_IsUrgentPort(struct port_range *, u_short, u_short); 6930949fd4SBrian Somers extern void ncp_AddUrgentPort(struct port_range *, u_short); 7030949fd4SBrian Somers extern void ncp_RemoveUrgentPort(struct port_range *, u_short); 7130949fd4SBrian Somers extern void ncp_ClearUrgentPorts(struct port_range *); 7230949fd4SBrian Somers extern int ncp_Show(struct cmdargs const *); 7330949fd4SBrian Somers extern int ncp_LayersOpen(struct ncp *); 7430949fd4SBrian Somers extern int ncp_LayersUnfinished(struct ncp *); 7530949fd4SBrian Somers extern void ncp_Close(struct ncp *); 7630949fd4SBrian Somers extern void ncp2initial(struct ncp *); 7730949fd4SBrian Somers 7830949fd4SBrian Somers #define ncp_IsUrgentTcpPort(ncp, p1, p2) \ 7930949fd4SBrian Somers ncp_IsUrgentPort(&(ncp)->cfg.urgent.tcp, p1, p2) 8030949fd4SBrian Somers #define ncp_IsUrgentUdpPort(ncp, p1, p2) \ 8130949fd4SBrian Somers ncp_IsUrgentPort(&(ncp)->cfg.urgent.udp, p1, p2) 8230949fd4SBrian Somers #define ncp_AddUrgentTcpPort(ncp, p) \ 8330949fd4SBrian Somers ncp_AddUrgentPort(&(ncp)->cfg.urgent.tcp, p) 8430949fd4SBrian Somers #define ncp_AddUrgentUdpPort(ncp, p) \ 8530949fd4SBrian Somers ncp_AddUrgentPort(&(ncp)->cfg.urgent.udp, p) 8630949fd4SBrian Somers #define ncp_RemoveUrgentTcpPort(ncp, p) \ 8730949fd4SBrian Somers ncp_RemoveUrgentPort(&(ncp)->cfg.urgent.tcp, p) 8830949fd4SBrian Somers #define ncp_RemoveUrgentUdpPort(ncp, p) \ 8930949fd4SBrian Somers ncp_RemoveUrgentPort(&(ncp)->cfg.urgent.udp, p) 9030949fd4SBrian Somers #define ncp_ClearUrgentTcpPorts(ncp) \ 9130949fd4SBrian Somers ncp_ClearUrgentPorts(&(ncp)->cfg.urgent.tcp) 9230949fd4SBrian Somers #define ncp_ClearUrgentUdpPorts(ncp) \ 9330949fd4SBrian Somers ncp_ClearUrgentPorts(&(ncp)->cfg.urgent.udp) 9430949fd4SBrian Somers #define ncp_ClearUrgentTOS(ncp) (ncp)->cfg.urgent.tos = 0; 9530949fd4SBrian Somers #define ncp_SetUrgentTOS(ncp) (ncp)->cfg.urgent.tos = 1; 9630949fd4SBrian Somers 9730949fd4SBrian Somers #ifndef NOINET6 9830949fd4SBrian Somers #define isncp(proto) ((proto) == PROTO_IPCP || (proto) == PROTO_IPV6CP) 9930949fd4SBrian Somers #else 10030949fd4SBrian Somers #define isncp(proto) ((proto) == PROTO_IPCP) 10130949fd4SBrian Somers #endif 102