181634Sbrian/*-
2330449Seadler * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3330449Seadler *
481634Sbrian * Copyright (c) 2001 Brian Somers <brian@Awfulhak.org>
581634Sbrian * All rights reserved.
681634Sbrian *
781634Sbrian * Redistribution and use in source and binary forms, with or without
881634Sbrian * modification, are permitted provided that the following conditions
981634Sbrian * are met:
1081634Sbrian * 1. Redistributions of source code must retain the above copyright
1181634Sbrian *    notice, this list of conditions and the following disclaimer.
1281634Sbrian * 2. Redistributions in binary form must reproduce the above copyright
1381634Sbrian *    notice, this list of conditions and the following disclaimer in the
1481634Sbrian *    documentation and/or other materials provided with the distribution.
1581634Sbrian *
1681634Sbrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1781634Sbrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1881634Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1981634Sbrian * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2081634Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2181634Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2281634Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2381634Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2481634Sbrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2581634Sbrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2681634Sbrian * SUCH DAMAGE.
2781634Sbrian *
2881634Sbrian * $FreeBSD: stable/11/usr.sbin/ppp/ipv6cp.h 330449 2018-03-05 07:26:05Z eadler $
2981634Sbrian */
3081634Sbrian
3181634Sbrian#ifndef NOINET6
3281634Sbrian#define	IPV6CP_MAXCODE	CODE_CODEREJ
3381634Sbrian
3481634Sbrian#define	TY_TOKEN	1
3581634Sbrian#define	TY_COMPPROTO	2
3681634Sbrian
37102558Sbrian#define	IPV6CP_IFIDLEN	8		/* RFC2472 */
38102558Sbrian
3981634Sbrianstruct ipv6cp {
4081634Sbrian  struct fsm fsm;			/* The finite state machine */
4181634Sbrian
4281634Sbrian  struct {
4381634Sbrian    struct fsm_retry fsm;		/* frequency to resend requests */
4481634Sbrian  } cfg;
4581634Sbrian
4681634Sbrian  unsigned peer_tokenreq : 1;		/* Any TY_TOKEN REQs from the peer ? */
4781634Sbrian
48102558Sbrian  u_char my_ifid[IPV6CP_IFIDLEN];	/* Local Interface Identifier */
49102558Sbrian  u_char his_ifid[IPV6CP_IFIDLEN];	/* Peer Interface Identifier */
5081634Sbrian
5181634Sbrian  struct ncpaddr myaddr;		/* Local address */
5281634Sbrian  struct ncpaddr hisaddr;		/* Peer address */
5381634Sbrian
5481634Sbrian  u_int32_t his_reject;			/* Request codes rejected by peer */
5581634Sbrian  u_int32_t my_reject;			/* Request codes I have rejected */
5681634Sbrian
5781634Sbrian  struct pppThroughput throughput;	/* throughput statistics */
5881634Sbrian  struct mqueue Queue[2];		/* Output packet queues */
5981634Sbrian};
6081634Sbrian
6181634Sbrian#define fsm2ipv6cp(fp) (fp->proto == PROTO_IPV6CP ? (struct ipv6cp *)fp : NULL)
6281634Sbrian#define IPV6CP_QUEUES(ipv6cp) (sizeof ipv6cp->Queue / sizeof ipv6cp->Queue[0])
6381634Sbrian
6481634Sbrianstruct bundle;
6581634Sbrianstruct link;
6681634Sbrianstruct cmdargs;
6781634Sbrianstruct iface_addr;
6881634Sbrian
6981634Sbrianextern void ipv6cp_Init(struct ipv6cp *, struct bundle *, struct link *,
7081634Sbrian                        const struct fsm_parent *);
7181634Sbrianextern void ipv6cp_Destroy(struct ipv6cp *);
7281634Sbrianextern void ipv6cp_Setup(struct ipv6cp *);
7381634Sbrianextern void ipv6cp_SetLink(struct ipv6cp *, struct link *);
7481634Sbrian
7581634Sbrianextern int  ipv6cp_Show(struct cmdargs const *);
7681634Sbrianextern struct mbuf *ipv6cp_Input(struct bundle *, struct link *, struct mbuf *);
7781634Sbrianextern void ipv6cp_AddInOctets(struct ipv6cp *, int);
7881634Sbrianextern void ipv6cp_AddOutOctets(struct ipv6cp *, int);
7981634Sbrian
8081634Sbrianextern void ipv6cp_IfaceAddrAdded(struct ipv6cp *, const struct iface_addr *);
8181634Sbrianextern void ipv6cp_IfaceAddrDeleted(struct ipv6cp *, const struct iface_addr *);
8281634Sbrianextern int  ipv6cp_InterfaceUp(struct ipv6cp *);
8381634Sbrianextern size_t ipv6cp_QueueLen(struct ipv6cp *);
8481634Sbrianextern int ipv6cp_PushPacket(struct ipv6cp *, struct link *);
8581634Sbrian#endif
86