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$
2781634Sbrian */
2881634Sbrian
2981634Sbrian#ifndef NOINET6
3081634Sbrian#define	IPV6CP_MAXCODE	CODE_CODEREJ
3181634Sbrian
3281634Sbrian#define	TY_TOKEN	1
3381634Sbrian#define	TY_COMPPROTO	2
3481634Sbrian
35102558Sbrian#define	IPV6CP_IFIDLEN	8		/* RFC2472 */
36102558Sbrian
3781634Sbrianstruct ipv6cp {
3881634Sbrian  struct fsm fsm;			/* The finite state machine */
3981634Sbrian
4081634Sbrian  struct {
4181634Sbrian    struct fsm_retry fsm;		/* frequency to resend requests */
4281634Sbrian  } cfg;
4381634Sbrian
4481634Sbrian  unsigned peer_tokenreq : 1;		/* Any TY_TOKEN REQs from the peer ? */
4581634Sbrian
46102558Sbrian  u_char my_ifid[IPV6CP_IFIDLEN];	/* Local Interface Identifier */
47102558Sbrian  u_char his_ifid[IPV6CP_IFIDLEN];	/* Peer Interface Identifier */
4881634Sbrian
4981634Sbrian  struct ncpaddr myaddr;		/* Local address */
5081634Sbrian  struct ncpaddr hisaddr;		/* Peer address */
5181634Sbrian
5281634Sbrian  u_int32_t his_reject;			/* Request codes rejected by peer */
5381634Sbrian  u_int32_t my_reject;			/* Request codes I have rejected */
5481634Sbrian
5581634Sbrian  struct pppThroughput throughput;	/* throughput statistics */
5681634Sbrian  struct mqueue Queue[2];		/* Output packet queues */
5781634Sbrian};
5881634Sbrian
5981634Sbrian#define fsm2ipv6cp(fp) (fp->proto == PROTO_IPV6CP ? (struct ipv6cp *)fp : NULL)
6081634Sbrian#define IPV6CP_QUEUES(ipv6cp) (sizeof ipv6cp->Queue / sizeof ipv6cp->Queue[0])
6181634Sbrian
6281634Sbrianstruct bundle;
6381634Sbrianstruct link;
6481634Sbrianstruct cmdargs;
6581634Sbrianstruct iface_addr;
6681634Sbrian
6781634Sbrianextern void ipv6cp_Init(struct ipv6cp *, struct bundle *, struct link *,
6881634Sbrian                        const struct fsm_parent *);
6981634Sbrianextern void ipv6cp_Destroy(struct ipv6cp *);
7081634Sbrianextern void ipv6cp_Setup(struct ipv6cp *);
7181634Sbrianextern void ipv6cp_SetLink(struct ipv6cp *, struct link *);
7281634Sbrian
7381634Sbrianextern int  ipv6cp_Show(struct cmdargs const *);
7481634Sbrianextern struct mbuf *ipv6cp_Input(struct bundle *, struct link *, struct mbuf *);
7581634Sbrianextern void ipv6cp_AddInOctets(struct ipv6cp *, int);
7681634Sbrianextern void ipv6cp_AddOutOctets(struct ipv6cp *, int);
7781634Sbrian
7881634Sbrianextern void ipv6cp_IfaceAddrAdded(struct ipv6cp *, const struct iface_addr *);
7981634Sbrianextern void ipv6cp_IfaceAddrDeleted(struct ipv6cp *, const struct iface_addr *);
8081634Sbrianextern int  ipv6cp_InterfaceUp(struct ipv6cp *);
8181634Sbrianextern size_t ipv6cp_QueueLen(struct ipv6cp *);
8281634Sbrianextern int ipv6cp_PushPacket(struct ipv6cp *, struct link *);
8381634Sbrian#endif
84