ipv6cp.h revision 330449
119914Swollman/*-
250476Speter * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
31558Srgrimes *
41558Srgrimes * Copyright (c) 2001 Brian Somers <brian@Awfulhak.org>
525451Speter * All rights reserved.
6138593Ssam *
725451Speter * Redistribution and use in source and binary forms, with or without
8138593Ssam * modification, are permitted provided that the following conditions
9138593Ssam * are met:
10138593Ssam * 1. Redistributions of source code must retain the above copyright
11138593Ssam *    notice, this list of conditions and the following disclaimer.
12138593Ssam * 2. Redistributions in binary form must reproduce the above copyright
13138593Ssam *    notice, this list of conditions and the following disclaimer in the
14138593Ssam *    documentation and/or other materials provided with the distribution.
15138593Ssam *
16138593Ssam * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17138593Ssam * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18138593Ssam * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1944764Swpaul * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20138593Ssam * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21138593Ssam * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22138593Ssam * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23138593Ssam * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24138593Ssam * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2577217Sphk * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26138593Ssam * SUCH DAMAGE.
27138593Ssam *
2819914Swollman * $FreeBSD: stable/11/usr.sbin/ppp/ipv6cp.h 330449 2018-03-05 07:26:05Z eadler $
2919914Swollman */
3080057Sobrien
3180057Sobrien#ifndef NOINET6
32138593Ssam#define	IPV6CP_MAXCODE	CODE_CODEREJ
33138593Ssam
34138593Ssam#define	TY_TOKEN	1
3544764Swpaul#define	TY_COMPPROTO	2
36126178Sjohan
371558Srgrimes#define	IPV6CP_IFIDLEN	8		/* RFC2472 */
381558Srgrimes
39struct ipv6cp {
40  struct fsm fsm;			/* The finite state machine */
41
42  struct {
43    struct fsm_retry fsm;		/* frequency to resend requests */
44  } cfg;
45
46  unsigned peer_tokenreq : 1;		/* Any TY_TOKEN REQs from the peer ? */
47
48  u_char my_ifid[IPV6CP_IFIDLEN];	/* Local Interface Identifier */
49  u_char his_ifid[IPV6CP_IFIDLEN];	/* Peer Interface Identifier */
50
51  struct ncpaddr myaddr;		/* Local address */
52  struct ncpaddr hisaddr;		/* Peer address */
53
54  u_int32_t his_reject;			/* Request codes rejected by peer */
55  u_int32_t my_reject;			/* Request codes I have rejected */
56
57  struct pppThroughput throughput;	/* throughput statistics */
58  struct mqueue Queue[2];		/* Output packet queues */
59};
60
61#define fsm2ipv6cp(fp) (fp->proto == PROTO_IPV6CP ? (struct ipv6cp *)fp : NULL)
62#define IPV6CP_QUEUES(ipv6cp) (sizeof ipv6cp->Queue / sizeof ipv6cp->Queue[0])
63
64struct bundle;
65struct link;
66struct cmdargs;
67struct iface_addr;
68
69extern void ipv6cp_Init(struct ipv6cp *, struct bundle *, struct link *,
70                        const struct fsm_parent *);
71extern void ipv6cp_Destroy(struct ipv6cp *);
72extern void ipv6cp_Setup(struct ipv6cp *);
73extern void ipv6cp_SetLink(struct ipv6cp *, struct link *);
74
75extern int  ipv6cp_Show(struct cmdargs const *);
76extern struct mbuf *ipv6cp_Input(struct bundle *, struct link *, struct mbuf *);
77extern void ipv6cp_AddInOctets(struct ipv6cp *, int);
78extern void ipv6cp_AddOutOctets(struct ipv6cp *, int);
79
80extern void ipv6cp_IfaceAddrAdded(struct ipv6cp *, const struct iface_addr *);
81extern void ipv6cp_IfaceAddrDeleted(struct ipv6cp *, const struct iface_addr *);
82extern int  ipv6cp_InterfaceUp(struct ipv6cp *);
83extern size_t ipv6cp_QueueLen(struct ipv6cp *);
84extern int ipv6cp_PushPacket(struct ipv6cp *, struct link *);
85#endif
86