xref: /freebsd/usr.sbin/ppp/ipv6cp.h (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
130949fd4SBrian Somers /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
31de7b4b8SPedro F. Giffuni  *
430949fd4SBrian Somers  * Copyright (c) 2001 Brian Somers <brian@Awfulhak.org>
530949fd4SBrian Somers  * All rights reserved.
630949fd4SBrian Somers  *
730949fd4SBrian Somers  * Redistribution and use in source and binary forms, with or without
830949fd4SBrian Somers  * modification, are permitted provided that the following conditions
930949fd4SBrian Somers  * are met:
1030949fd4SBrian Somers  * 1. Redistributions of source code must retain the above copyright
1130949fd4SBrian Somers  *    notice, this list of conditions and the following disclaimer.
1230949fd4SBrian Somers  * 2. Redistributions in binary form must reproduce the above copyright
1330949fd4SBrian Somers  *    notice, this list of conditions and the following disclaimer in the
1430949fd4SBrian Somers  *    documentation and/or other materials provided with the distribution.
1530949fd4SBrian Somers  *
1630949fd4SBrian Somers  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1730949fd4SBrian Somers  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1830949fd4SBrian Somers  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1930949fd4SBrian Somers  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2030949fd4SBrian Somers  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2130949fd4SBrian Somers  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2230949fd4SBrian Somers  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2330949fd4SBrian Somers  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2430949fd4SBrian Somers  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2530949fd4SBrian Somers  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2630949fd4SBrian Somers  * SUCH DAMAGE.
2730949fd4SBrian Somers  */
2830949fd4SBrian Somers 
2930949fd4SBrian Somers #ifndef NOINET6
3030949fd4SBrian Somers #define	IPV6CP_MAXCODE	CODE_CODEREJ
3130949fd4SBrian Somers 
3230949fd4SBrian Somers #define	TY_TOKEN	1
3330949fd4SBrian Somers #define	TY_COMPPROTO	2
3430949fd4SBrian Somers 
35a3c48b40SBrian Somers #define	IPV6CP_IFIDLEN	8		/* RFC2472 */
36a3c48b40SBrian Somers 
3730949fd4SBrian Somers struct ipv6cp {
3830949fd4SBrian Somers   struct fsm fsm;			/* The finite state machine */
3930949fd4SBrian Somers 
4030949fd4SBrian Somers   struct {
4130949fd4SBrian Somers     struct fsm_retry fsm;		/* frequency to resend requests */
4230949fd4SBrian Somers   } cfg;
4330949fd4SBrian Somers 
4430949fd4SBrian Somers   unsigned peer_tokenreq : 1;		/* Any TY_TOKEN REQs from the peer ? */
4530949fd4SBrian Somers 
46a3c48b40SBrian Somers   u_char my_ifid[IPV6CP_IFIDLEN];	/* Local Interface Identifier */
47a3c48b40SBrian Somers   u_char his_ifid[IPV6CP_IFIDLEN];	/* Peer Interface Identifier */
4830949fd4SBrian Somers 
4930949fd4SBrian Somers   struct ncpaddr myaddr;		/* Local address */
5030949fd4SBrian Somers   struct ncpaddr hisaddr;		/* Peer address */
5130949fd4SBrian Somers 
5230949fd4SBrian Somers   u_int32_t his_reject;			/* Request codes rejected by peer */
5330949fd4SBrian Somers   u_int32_t my_reject;			/* Request codes I have rejected */
5430949fd4SBrian Somers 
5530949fd4SBrian Somers   struct pppThroughput throughput;	/* throughput statistics */
5630949fd4SBrian Somers   struct mqueue Queue[2];		/* Output packet queues */
5730949fd4SBrian Somers };
5830949fd4SBrian Somers 
5930949fd4SBrian Somers #define fsm2ipv6cp(fp) (fp->proto == PROTO_IPV6CP ? (struct ipv6cp *)fp : NULL)
6030949fd4SBrian Somers #define IPV6CP_QUEUES(ipv6cp) (sizeof ipv6cp->Queue / sizeof ipv6cp->Queue[0])
6130949fd4SBrian Somers 
6230949fd4SBrian Somers struct bundle;
6330949fd4SBrian Somers struct link;
6430949fd4SBrian Somers struct cmdargs;
6530949fd4SBrian Somers struct iface_addr;
6630949fd4SBrian Somers 
6730949fd4SBrian Somers extern void ipv6cp_Init(struct ipv6cp *, struct bundle *, struct link *,
6830949fd4SBrian Somers                         const struct fsm_parent *);
6930949fd4SBrian Somers extern void ipv6cp_Destroy(struct ipv6cp *);
7030949fd4SBrian Somers extern void ipv6cp_Setup(struct ipv6cp *);
7130949fd4SBrian Somers extern void ipv6cp_SetLink(struct ipv6cp *, struct link *);
7230949fd4SBrian Somers 
7330949fd4SBrian Somers extern int  ipv6cp_Show(struct cmdargs const *);
7430949fd4SBrian Somers extern struct mbuf *ipv6cp_Input(struct bundle *, struct link *, struct mbuf *);
7530949fd4SBrian Somers extern void ipv6cp_AddInOctets(struct ipv6cp *, int);
7630949fd4SBrian Somers extern void ipv6cp_AddOutOctets(struct ipv6cp *, int);
7730949fd4SBrian Somers 
7830949fd4SBrian Somers extern void ipv6cp_IfaceAddrAdded(struct ipv6cp *, const struct iface_addr *);
7930949fd4SBrian Somers extern void ipv6cp_IfaceAddrDeleted(struct ipv6cp *, const struct iface_addr *);
8030949fd4SBrian Somers extern int  ipv6cp_InterfaceUp(struct ipv6cp *);
8130949fd4SBrian Somers extern size_t ipv6cp_QueueLen(struct ipv6cp *);
8230949fd4SBrian Somers extern int ipv6cp_PushPacket(struct ipv6cp *, struct link *);
8330949fd4SBrian Somers #endif
84