/*      $NetBSD: route.h,v 1.4 2019/04/29 16:12:30 roy Exp $    */

/*
* Copyright (c) 1980, 1986, 1993
*      The Regents of the University of California.  All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
*    notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
*    may be used to endorse or promote products derived from this software
*    without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*      @(#)route.h     8.5 (Berkeley) 2/8/95
*/

#ifndef _COMPAT_NET_ROUTE_H_
#define _COMPAT_NET_ROUTE_H_

#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <net/if.h>

#if !(defined(_KERNEL) || defined(_STANDALONE))
#include <stdbool.h>
#endif

/*
* These numbers are used by reliable protocols for determining
* retransmission behavior and are included in the routing structure.
*/
struct rt_metrics50 {
       u_long  rmx_locks;      /* Kernel must leave these values alone */
       u_long  rmx_mtu;        /* MTU for this path */
       u_long  rmx_hopcount;   /* max hops expected */
       u_long  rmx_expire;     /* lifetime for route, e.g. redirect */
       u_long  rmx_recvpipe;   /* inbound delay-bandwidth product */
       u_long  rmx_sendpipe;   /* outbound delay-bandwidth product */
       u_long  rmx_ssthresh;   /* outbound gateway buffer limit */
       u_long  rmx_rtt;        /* estimated round trip time */
       u_long  rmx_rttvar;     /* estimated rtt variance */
       u_long  rmx_pksent;     /* packets sent using this route */
};

/*
* Structures for routing messages.
*/
struct rt_msghdr50 {
       u_short rtm_msglen;     /* to skip over non-understood messages */
       u_char  rtm_version;    /* future binary compatibility */
       u_char  rtm_type;       /* message type */
       u_short rtm_index;      /* index for associated ifp */
       int     rtm_flags;      /* flags, incl. kern & message, e.g. DONE */
       int     rtm_addrs;      /* bitmask identifying sockaddrs in msg */
       pid_t   rtm_pid;        /* identify sender */
       int     rtm_seq;        /* for sender to identify action */
       int     rtm_errno;      /* why failed */
       int     rtm_use;        /* from rtentry */
       u_long  rtm_inits;      /* which metrics we are initializing */
       struct  rt_metrics50 rtm_rmx; /* metrics themselves */
};

#ifdef _KERNEL
extern struct route_info compat_50_route_info;
void    compat_50_route_enqueue(struct mbuf *, int);
void    compat_50_rt_ifannouncemsg(struct ifnet *, int);
void    compat_50_rt_ieee80211msg(struct ifnet *, int, void *, size_t);
void    compat_50_rt_ifmsg(struct ifnet *);
void    compat_50_rt_missmsg(int, const struct rt_addrinfo *, int, int);
struct mbuf *
       compat_50_rt_msg1(int, struct rt_addrinfo *, void *, int);
void    compat_50_rt_addrmsg_rt(int, struct ifaddr *, int, struct rtentry *);
void    compat_50_rt_addrmsg_src(int, struct ifaddr *, const struct sockaddr *);
void    compat_50_rt_addrmsg(int, struct ifaddr *);
void    compat_70_rt_newaddrmsg1(int, struct ifaddr *);
#endif

#define RTM_OVERSION    3       /* Up the ante and ignore older versions */

#define RT_OROUNDUP(a)          RT_ROUNDUP2((a), sizeof(long))
#define RT_OADVANCE(x, n)       (x += RT_OROUNDUP((n)->sa_len))

#endif /* !_COMPAT_NET_ROUTE_H_ */