ncp.h revision 134789
181634Sbrian/*- 281634Sbrian * Copyright (c) 2001 Brian Somers <brian@Awfulhak.org> 381634Sbrian * All rights reserved. 481634Sbrian * 581634Sbrian * Redistribution and use in source and binary forms, with or without 681634Sbrian * modification, are permitted provided that the following conditions 781634Sbrian * are met: 881634Sbrian * 1. Redistributions of source code must retain the above copyright 981634Sbrian * notice, this list of conditions and the following disclaimer. 1081634Sbrian * 2. Redistributions in binary form must reproduce the above copyright 1181634Sbrian * notice, this list of conditions and the following disclaimer in the 1281634Sbrian * documentation and/or other materials provided with the distribution. 1381634Sbrian * 1481634Sbrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1581634Sbrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1681634Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1781634Sbrian * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1881634Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1981634Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2081634Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2181634Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2281634Sbrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2381634Sbrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2481634Sbrian * SUCH DAMAGE. 2581634Sbrian * 2681634Sbrian * $FreeBSD: head/usr.sbin/ppp/ncp.h 134789 2004-09-05 01:46:52Z brian $ 2781634Sbrian */ 2881634Sbrian 2981634Sbrianstruct port_range { 3081634Sbrian unsigned nports; /* How many ports */ 3181634Sbrian unsigned maxports; /* How many allocated (malloc) ports */ 3281634Sbrian u_short *port; /* The actual ports */ 3381634Sbrian}; 3481634Sbrian 3581634Sbrianstruct ncp { 3681634Sbrian struct { 3781634Sbrian u_long sendpipe; /* route sendpipe size */ 3881634Sbrian u_long recvpipe; /* route recvpipe size */ 3981634Sbrian 4081634Sbrian struct { 4181634Sbrian struct port_range tcp, udp; /* The range of urgent ports */ 4281634Sbrian unsigned tos : 1; /* Urgent IPTOS_LOWDELAY packets ? */ 4381634Sbrian } urgent; 4481634Sbrian } cfg; 4581634Sbrian 4681634Sbrian int afq; /* Next address family to queue */ 4781634Sbrian 4881634Sbrian struct sticky_route *route; /* List of dynamic routes */ 4981634Sbrian 5081634Sbrian struct ipcp ipcp; /* Our IPCP FSM */ 5181634Sbrian#ifndef NOINET6 5281634Sbrian struct ipv6cp ipv6cp; /* Our IPV6CP FSM */ 5381634Sbrian#endif 5481634Sbrian struct mp mp; /* Our MP */ 5581634Sbrian}; 5681634Sbrian 5781634Sbrianextern void ncp_Init(struct ncp *, struct bundle *); 5881634Sbrianextern void ncp_Destroy(struct ncp *); 5981634Sbrianextern int ncp_fsmStart(struct ncp *, struct bundle *); 6081634Sbrianextern void ncp_IfaceAddrAdded(struct ncp *, const struct iface_addr *); 6181634Sbrianextern void ncp_IfaceAddrDeleted(struct ncp *, const struct iface_addr *); 6281634Sbrianextern void ncp_SetLink(struct ncp *, struct link *); 63134789Sbrianextern void ncp_Enqueue(struct ncp *, int, unsigned, char *, int); 6481634Sbrianextern void ncp_DeleteQueues(struct ncp *); 6581634Sbrianextern size_t ncp_QueueLen(struct ncp *); 6681634Sbrianextern size_t ncp_FillPhysicalQueues(struct ncp *, struct bundle *); 6781634Sbrianextern int ncp_PushPacket(struct ncp *, int *, struct link *); 6881634Sbrianextern int ncp_IsUrgentPort(struct port_range *, u_short, u_short); 6981634Sbrianextern void ncp_AddUrgentPort(struct port_range *, u_short); 7081634Sbrianextern void ncp_RemoveUrgentPort(struct port_range *, u_short); 7181634Sbrianextern void ncp_ClearUrgentPorts(struct port_range *); 7281634Sbrianextern int ncp_Show(struct cmdargs const *); 7381634Sbrianextern int ncp_LayersOpen(struct ncp *); 7481634Sbrianextern int ncp_LayersUnfinished(struct ncp *); 7581634Sbrianextern void ncp_Close(struct ncp *); 7681634Sbrianextern void ncp2initial(struct ncp *); 7781634Sbrian 7881634Sbrian#define ncp_IsUrgentTcpPort(ncp, p1, p2) \ 7981634Sbrian ncp_IsUrgentPort(&(ncp)->cfg.urgent.tcp, p1, p2) 8081634Sbrian#define ncp_IsUrgentUdpPort(ncp, p1, p2) \ 8181634Sbrian ncp_IsUrgentPort(&(ncp)->cfg.urgent.udp, p1, p2) 8281634Sbrian#define ncp_AddUrgentTcpPort(ncp, p) \ 8381634Sbrian ncp_AddUrgentPort(&(ncp)->cfg.urgent.tcp, p) 8481634Sbrian#define ncp_AddUrgentUdpPort(ncp, p) \ 8581634Sbrian ncp_AddUrgentPort(&(ncp)->cfg.urgent.udp, p) 8681634Sbrian#define ncp_RemoveUrgentTcpPort(ncp, p) \ 8781634Sbrian ncp_RemoveUrgentPort(&(ncp)->cfg.urgent.tcp, p) 8881634Sbrian#define ncp_RemoveUrgentUdpPort(ncp, p) \ 8981634Sbrian ncp_RemoveUrgentPort(&(ncp)->cfg.urgent.udp, p) 9081634Sbrian#define ncp_ClearUrgentTcpPorts(ncp) \ 9181634Sbrian ncp_ClearUrgentPorts(&(ncp)->cfg.urgent.tcp) 9281634Sbrian#define ncp_ClearUrgentUdpPorts(ncp) \ 9381634Sbrian ncp_ClearUrgentPorts(&(ncp)->cfg.urgent.udp) 9481634Sbrian#define ncp_ClearUrgentTOS(ncp) (ncp)->cfg.urgent.tos = 0; 9581634Sbrian#define ncp_SetUrgentTOS(ncp) (ncp)->cfg.urgent.tos = 1; 9681634Sbrian 9781634Sbrian#ifndef NOINET6 9881634Sbrian#define isncp(proto) ((proto) == PROTO_IPCP || (proto) == PROTO_IPV6CP) 9981634Sbrian#else 10081634Sbrian#define isncp(proto) ((proto) == PROTO_IPCP) 10181634Sbrian#endif 102