Home | History | Annotate | Line # | Download | only in netinet
      1 /*	$NetBSD: ip_fil_compat.c,v 1.5 2018/02/08 08:04:45 mrg Exp $	*/
      2 
      3 /*
      4  * Copyright (C) 2002-2012 by Darren Reed.
      5  *
      6  * See the IPFILTER.LICENCE file for details on licencing.
      7  */
      8 #if defined(KERNEL) || defined(_KERNEL)
      9 # undef KERNEL
     10 # undef _KERNEL
     11 # define        KERNEL	1
     12 # define        _KERNEL	1
     13 #endif
     14 #if defined(__osf__)
     15 # define _PROTO_NET_H_
     16 #endif
     17 #include <sys/param.h>
     18 #include <sys/errno.h>
     19 #include <sys/types.h>
     20 #include <sys/time.h>
     21 #include <sys/file.h>
     22 #if __FreeBSD_version >= 220000 && defined(_KERNEL)
     23 # include <sys/fcntl.h>
     24 # include <sys/filio.h>
     25 #else
     26 # include <sys/ioctl.h>
     27 #endif
     28 #if !defined(_KERNEL)
     29 # include <string.h>
     30 # define _KERNEL
     31 # ifdef __OpenBSD__
     32 struct file;
     33 # endif
     34 # include <sys/uio.h>
     35 # undef _KERNEL
     36 #endif
     37 #include <sys/socket.h>
     38 #if (defined(__osf__) || defined(AIX) || defined(__hpux) || defined(__sgi)) && defined(_KERNEL)
     39 # include "radix_ipf_local.h"
     40 # define _RADIX_H_
     41 #endif
     42 #include <net/if.h>
     43 #if defined(__FreeBSD__)
     44 #  include <sys/cdefs.h>
     45 #  include <sys/proc.h>
     46 #endif
     47 #if defined(_KERNEL)
     48 # include <sys/systm.h>
     49 # if !defined(__SVR4) && !defined(__svr4__)
     50 #  include <sys/mbuf.h>
     51 # endif
     52 #endif
     53 #include <netinet/in.h>
     54 
     55 #include "netinet/ip_compat.h"
     56 #include "netinet/ip_fil.h"
     57 #include "netinet/ip_pool.h"
     58 #include "netinet/ip_htable.h"
     59 #include "netinet/ip_lookup.h"
     60 #include "netinet/ip_nat.h"
     61 #include "netinet/ip_state.h"
     62 #include "netinet/ip_proxy.h"
     63 #include "netinet/ip_auth.h"
     64 /* END OF INCLUDES */
     65 
     66 /*
     67  * NetBSD has moved to 64bit time_t for all architectures.
     68  * For some, such as sparc64, there is no change because long is already
     69  * 64bit, but for others (i386), there is...
     70  */
     71 #ifdef IPFILTER_COMPAT
     72 
     73 # ifdef __NetBSD__
     74 typedef struct timeval_l {
     75 	long	tv_sec;
     76 	long	tv_usec;
     77 } timeval_l_t;
     78 # endif
     79 
     80 /* ------------------------------------------------------------------------ */
     81 
     82 typedef struct tcpinfo4 {
     83 	u_short		ts_sport;
     84 	u_short		ts_dport;
     85 	tcpdata_t	ts_data[2];
     86 } tcpinfo4_t;
     87 
     88 static void ipf_v5tcpinfoto4(tcpinfo_t *, tcpinfo4_t *);
     89 
     90 static void ipf_v5tcpinfoto4(tcpinfo_t *, tcpinfo4_t *);
     91 
     92 static void
     93 ipf_v5tcpinfoto4(tcpinfo_t *v5, tcpinfo4_t *v4)
     94 {
     95 	v4->ts_sport = v5->ts_sport;
     96 	v4->ts_dport = v5->ts_dport;
     97 	v4->ts_data[0] = v5->ts_data[0];
     98 	v4->ts_data[1] = v5->ts_data[1];
     99 }
    100 
    101 typedef struct	fr_ip4	{
    102 	u_32_t	fi_v:4;
    103 	u_32_t	fi_xx:4;
    104 	u_32_t	fi_tos:8;
    105 	u_32_t	fi_ttl:8;
    106 	u_32_t	fi_p:8;
    107 	u_32_t	fi_optmsk;
    108 	i6addr_t fi_src;
    109 	i6addr_t fi_dst;
    110 	u_short	ofi_secmsk;
    111 	u_short	ofi_auth;
    112 	u_32_t	fi_flx;
    113 	u_32_t	fi_tcpmsk;
    114 	u_32_t	fi_res1;
    115 } frip4_t;
    116 
    117 typedef struct	frpcmp4	{
    118 	int	frp_cmp;
    119 	u_short	frp_port;
    120 	u_short	frp_top;
    121 } frpcmp4_t;
    122 
    123 typedef	struct	frtuc4	{
    124 	u_char	ftu_tcpfm;
    125 	u_char	ftu_tcpf;
    126 	frpcmp4_t	ftu_src;
    127 	frpcmp4_t	ftu_dst;
    128 } frtuc4_t;
    129 
    130 typedef	struct	fripf4	{
    131 	frip4_t fri_ip;
    132 	frip4_t fri_mip;
    133 
    134 	u_short	fri_icmpm;
    135 	u_short	fri_icmp;
    136 
    137 	frtuc4_t	fri_tuc;
    138 	int	fri_satype;
    139 	int	fri_datype;
    140 	int	fri_sifpidx;
    141 	int	fri_difpidx;
    142 } fripf4_t;
    143 
    144 typedef struct frdest_4 {
    145 	void		*fd_ifp;
    146 	i6addr_t	ofd_ip6;
    147 	char		fd_ifname[LIFNAMSIZ];
    148 } frdest_4_t;
    149 
    150 /* ------------------------------------------------------------------------ */
    151 
    152 /* 5.1.0 new release (current)
    153  * 4.1.34 changed the size of the time structure used for pps
    154  * 4.1.16 moved the location of fr_flineno
    155  * 4.1.0 base version
    156  */
    157 typedef	struct	frentry_4_1_34 {
    158 	ipfmutex_t	fr_lock;
    159 	struct	frentry	*fr_next;
    160 	struct	frentry	**fr_grp;
    161 	struct	ipscan	*fr_isc;
    162 	void	*fr_ifas[4];
    163 	void	*fr_ptr;	/* for use with fr_arg */
    164 	char	*fr_comment;	/* text comment for rule */
    165 	int	fr_ref;		/* reference count - for grouping */
    166 	int	fr_statecnt;	/* state count - for limit rules */
    167 	int	fr_flineno;	/* line number from conf file */
    168 	U_QUAD_T	fr_hits;
    169 	U_QUAD_T	fr_bytes;
    170 	union {
    171 		struct timeval	frp_lastpkt;
    172 		char	frp_bytes[12];
    173 	} fr_lpu;
    174 	int		fr_curpps;
    175 	union	{
    176 		void		*fru_data;
    177 		char		*fru_caddr;
    178 		fripf4_t	*fru_ipf;
    179 		frentfunc_t	fru_func;
    180 	} fr_dun;
    181 	ipfunc_t fr_func; 	/* call this function */
    182 	int	fr_dsize;
    183 	int	fr_pps;
    184 	int	fr_statemax;	/* max reference count */
    185 	u_32_t	fr_type;
    186 	u_32_t	fr_flags;	/* per-rule flags && options (see below) */
    187 	u_32_t	fr_logtag;	/* user defined log tag # */
    188 	u_32_t	fr_collect;	/* collection number */
    189 	u_int	fr_arg;		/* misc. numeric arg for rule */
    190 	u_int	fr_loglevel;	/* syslog log facility + priority */
    191 	u_int	fr_age[2];	/* non-TCP timeouts */
    192 	u_char	fr_v;
    193 	u_char	fr_icode;	/* return ICMP code */
    194 	char	fr_group[FR_GROUPLEN];	/* group to which this rule belongs */
    195 	char	fr_grhead[FR_GROUPLEN];	/* group # which this rule starts */
    196 	ipftag_t fr_nattag;
    197 	char	fr_ifnames[4][LIFNAMSIZ];
    198 	char	fr_isctag[16];
    199 	frdest_4_t fr_tifs[2];	/* "to"/"reply-to" interface */
    200 	frdest_4_t fr_dif;	/* duplicate packet interface */
    201 	u_int	fr_cksum;	/* checksum on filter rules for performance */
    202 } frentry_4_1_34_t;
    203 
    204 typedef	struct	frentry_4_1_16 {
    205 	ipfmutex_t	fr_lock;
    206 	struct	frentry	*fr_next;
    207 	struct	frentry	**fr_grp;
    208 	struct	ipscan	*fr_isc;
    209 	void	*fr_ifas[4];
    210 	void	*fr_ptr;
    211 	char	*fr_comment;
    212 	int	fr_ref;
    213 	int	fr_statecnt;
    214 	int	fr_flineno;
    215 	U_QUAD_T	fr_hits;
    216 	U_QUAD_T	fr_bytes;
    217 	union {
    218 #ifdef __NetBSD__
    219 		timeval_l_t	frp_lastpkt;
    220 #else
    221 		struct timeval	frp_lastpkt;
    222 #endif
    223 	} fr_lpu;
    224 	int		fr_curpps;
    225 	union	{
    226 		void		*fru_data;
    227 		char		*fru_caddr;
    228 		fripf4_t	*fru_ipf;
    229 		frentfunc_t	fru_func;
    230 	} fr_dun;
    231 	ipfunc_t fr_func;
    232 	int	fr_dsize;
    233 	int	fr_pps;
    234 	int	fr_statemax;
    235 	u_32_t	fr_type;
    236 	u_32_t	fr_flags;
    237 	u_32_t	fr_logtag;
    238 	u_32_t	fr_collect;
    239 	u_int	fr_arg;
    240 	u_int	fr_loglevel;
    241 	u_int	fr_age[2];
    242 	u_char	fr_v;
    243 	u_char	fr_icode;
    244 	char	fr_group[FR_GROUPLEN];
    245 	char	fr_grhead[FR_GROUPLEN];
    246 	ipftag_t fr_nattag;
    247 	char	fr_ifnames[4][LIFNAMSIZ];
    248 	char	fr_isctag[16];
    249 	frdest_4_t fr_tifs[2];
    250 	frdest_4_t fr_dif;
    251 	u_int	fr_cksum;
    252 } frentry_4_1_16_t;
    253 
    254 typedef	struct	frentry_4_1_0 {
    255 	ipfmutex_t	fr_lock;
    256 	struct	frentry	*fr_next;
    257 	struct	frentry	**fr_grp;
    258 	struct	ipscan	*fr_isc;
    259 	void	*fr_ifas[4];
    260 	void	*fr_ptr;
    261 	char	*fr_comment;
    262 	int	fr_ref;
    263 	int	fr_statecnt;
    264 	U_QUAD_T	fr_hits;
    265 	U_QUAD_T	fr_bytes;
    266 	union {
    267 #ifdef __NetBSD__
    268 		timeval_l_t	frp_lastpkt;
    269 #else
    270 		struct timeval	frp_lastpkt;
    271 #endif
    272 	} fr_lpu;
    273 	int		fr_curpps;
    274 
    275 	union	{
    276 		void		*fru_data;
    277 		char		*fru_caddr;
    278 		fripf4_t	*fru_ipf;
    279 		frentfunc_t	fru_func;
    280 	} fr_dun;
    281 	/*
    282 	 * Fields after this may not change whilst in the kernel.
    283 	 */
    284 	ipfunc_t fr_func;
    285 	int	fr_dsize;
    286 	int	fr_pps;
    287 	int	fr_statemax;
    288 	int	fr_flineno;
    289 	u_32_t	fr_type;
    290 	u_32_t	fr_flags;
    291 	u_32_t	fr_logtag;
    292 	u_32_t	fr_collect;
    293 	u_int	fr_arg;
    294 	u_int	fr_loglevel;
    295 	u_int	fr_age[2];
    296 	u_char	fr_v;
    297 	u_char	fr_icode;
    298 	char	fr_group[FR_GROUPLEN];
    299 	char	fr_grhead[FR_GROUPLEN];
    300 	ipftag_t fr_nattag;
    301 	char	fr_ifnames[4][LIFNAMSIZ];
    302 	char	fr_isctag[16];
    303 	frdest_4_t fr_tifs[2];
    304 	frdest_4_t fr_dif;
    305 	u_int	fr_cksum;
    306 } frentry_4_1_0_t;
    307 
    308 /* ------------------------------------------------------------------------ */
    309 
    310 /*
    311  * 5.1.0  new release (current)
    312  * 4.1.32 removed both fin_state and fin_nat, added fin_pktnum
    313  * 4.1.24 added fin_cksum
    314  * 4.1.23 added fin_exthdr
    315  * 4.1.11 added fin_ifname
    316  * 4.1.4  added fin_hbuf
    317  */
    318 typedef	struct	fr_info_4_1_32 {
    319 	void	*fin_ifp;		/* interface packet is `on' */
    320 	frip4_t	fin_fi;		/* IP Packet summary */
    321 	union	{
    322 		u_short	fid_16[2];	/* TCP/UDP ports, ICMP code/type */
    323 		u_32_t	fid_32;
    324 	} fin_dat;
    325 	int	fin_out;		/* in or out ? 1 == out, 0 == in */
    326 	int	fin_rev;		/* state only: 1 = reverse */
    327 	u_short	fin_hlen;		/* length of IP header in bytes */
    328 	u_char	ofin_tcpf;		/* TCP header flags (SYN, ACK, etc) */
    329 	u_char	fin_icode;		/* ICMP error to return */
    330 	u_32_t	fin_rule;		/* rule # last matched */
    331 	char	fin_group[FR_GROUPLEN];	/* group number, -1 for none */
    332 	struct	frentry *fin_fr;	/* last matching rule */
    333 	void	*fin_dp;		/* start of data past IP header */
    334 	int	fin_dlen;		/* length of data portion of packet */
    335 	int	fin_plen;
    336 	int	fin_ipoff;		/* # bytes from buffer start to hdr */
    337 	u_short	fin_id;			/* IP packet id field */
    338 	u_short	fin_off;
    339 	int	fin_depth;		/* Group nesting depth */
    340 	int	fin_error;		/* Error code to return */
    341 	int	fin_cksum;		/* -1 bad, 1 good, 0 not done */
    342 	u_int	fin_pktnum;
    343 	void	*fin_nattag;
    344 	void	*fin_exthdr;
    345 	ip_t	*ofin_ip;
    346 	mb_t	**fin_mp;		/* pointer to pointer to mbuf */
    347 	mb_t	*fin_m;			/* pointer to mbuf */
    348 #ifdef	MENTAT
    349 	mb_t	*fin_qfm;		/* pointer to mblk where pkt starts */
    350 	void	*fin_qpi;
    351 	char	fin_ifname[LIFNAMSIZ];
    352 #endif
    353 #ifdef	__sgi
    354 	void	*fin_hbuf;
    355 #endif
    356 } fr_info_4_1_32_t;
    357 
    358 typedef struct  fr_info_4_1_24 {
    359 	void    *fin_ifp;
    360 	frip4_t fin_fi;
    361 	union   {
    362 		u_short fid_16[2];
    363 		u_32_t  fid_32;
    364 	} fin_dat;
    365 	int     fin_out;
    366 	int     fin_rev;
    367 	u_short fin_hlen;
    368 	u_char  ofin_tcpf;
    369 	u_char  fin_icode;
    370 	u_32_t  fin_rule;
    371 	char    fin_group[FR_GROUPLEN];
    372 	struct  frentry *fin_fr;
    373 	void    *fin_dp;
    374 	int     fin_dlen;
    375 	int     fin_plen;
    376 	int     fin_ipoff;
    377 	u_short fin_id;
    378 	u_short fin_off;
    379 	int     fin_depth;
    380 	int     fin_error;
    381 	int     fin_cksum;
    382 	void	*fin_state;
    383 	void	*fin_nat;
    384 	void    *fin_nattag;
    385 	void    *fin_exthdr;
    386 	ip_t    *ofin_ip;
    387 	mb_t    **fin_mp;
    388 	mb_t    *fin_m;
    389 #ifdef  MENTAT
    390 	mb_t    *fin_qfm;
    391 	void    *fin_qpi;
    392 	char    fin_ifname[LIFNAMSIZ];
    393 #endif
    394 #ifdef  __sgi
    395 	void    *fin_hbuf;
    396 #endif
    397 } fr_info_4_1_24_t;
    398 
    399 typedef struct  fr_info_4_1_23 {
    400 	void    *fin_ifp;
    401 	frip4_t fin_fi;
    402 	union   {
    403 		u_short fid_16[2];
    404 		u_32_t  fid_32;
    405 	} fin_dat;
    406 	int     fin_out;
    407 	int     fin_rev;
    408 	u_short fin_hlen;
    409 	u_char  ofin_tcpf;
    410 	u_char  fin_icode;
    411 	u_32_t  fin_rule;
    412 	char    fin_group[FR_GROUPLEN];
    413 	struct  frentry *fin_fr;
    414 	void    *fin_dp;
    415 	int     fin_dlen;
    416 	int     fin_plen;
    417 	int     fin_ipoff;
    418 	u_short fin_id;
    419 	u_short fin_off;
    420 	int     fin_depth;
    421 	int     fin_error;
    422 	void	*fin_state;
    423 	void	*fin_nat;
    424 	void    *fin_nattag;
    425 	void    *fin_exthdr;
    426 	ip_t    *ofin_ip;
    427 	mb_t    **fin_mp;
    428 	mb_t    *fin_m;
    429 #ifdef  MENTAT
    430 	mb_t    *fin_qfm;
    431 	void    *fin_qpi;
    432 	char    fin_ifname[LIFNAMSIZ];
    433 #endif
    434 #ifdef  __sgi
    435 	void    *fin_hbuf;
    436 #endif
    437 } fr_info_4_1_23_t;
    438 
    439 typedef struct  fr_info_4_1_11 {
    440 	void    *fin_ifp;
    441 	frip4_t fin_fi;
    442 	union   {
    443 		u_short fid_16[2];
    444 		u_32_t  fid_32;
    445 	} fin_dat;
    446 	int     fin_out;
    447 	int     fin_rev;
    448 	u_short fin_hlen;
    449 	u_char  ofin_tcpf;
    450 	u_char  fin_icode;
    451 	u_32_t  fin_rule;
    452 	char    fin_group[FR_GROUPLEN];
    453 	struct  frentry *fin_fr;
    454 	void    *fin_dp;
    455 	int     fin_dlen;
    456 	int     fin_plen;
    457 	int     fin_ipoff;
    458 	u_short fin_id;
    459 	u_short fin_off;
    460 	int     fin_depth;
    461 	int     fin_error;
    462 	void	*fin_state;
    463 	void	*fin_nat;
    464 	void    *fin_nattag;
    465 	ip_t    *ofin_ip;
    466 	mb_t    **fin_mp;
    467 	mb_t    *fin_m;
    468 #ifdef  MENTAT
    469 	mb_t    *fin_qfm;
    470 	void    *fin_qpi;
    471 	char    fin_ifname[LIFNAMSIZ];
    472 #endif
    473 #ifdef  __sgi
    474 	void    *fin_hbuf;
    475 #endif
    476 } fr_info_4_1_11_t;
    477 
    478 /* ------------------------------------------------------------------------ */
    479 
    480 typedef	struct	filterstats_4_1 {
    481 	u_long	fr_pass;	/* packets allowed */
    482 	u_long	fr_block;	/* packets denied */
    483 	u_long	fr_nom;		/* packets which don't match any rule */
    484 	u_long	fr_short;	/* packets which are short */
    485 	u_long	fr_ppkl;	/* packets allowed and logged */
    486 	u_long	fr_bpkl;	/* packets denied and logged */
    487 	u_long	fr_npkl;	/* packets unmatched and logged */
    488 	u_long	fr_pkl;		/* packets logged */
    489 	u_long	fr_skip;	/* packets to be logged but buffer full */
    490 	u_long	fr_ret;		/* packets for which a return is sent */
    491 	u_long	fr_acct;	/* packets for which counting was performed */
    492 	u_long	fr_bnfr;	/* bad attempts to allocate fragment state */
    493 	u_long	fr_nfr;		/* new fragment state kept */
    494 	u_long	fr_cfr;		/* add new fragment state but complete pkt */
    495 	u_long	fr_bads;	/* bad attempts to allocate packet state */
    496 	u_long	fr_ads;		/* new packet state kept */
    497 	u_long	fr_chit;	/* cached hit */
    498 	u_long	fr_tcpbad;	/* TCP checksum check failures */
    499 	u_long	fr_pull[2];	/* good and bad pullup attempts */
    500 	u_long	fr_badsrc;	/* source received doesn't match route */
    501 	u_long	fr_badttl;	/* TTL in packet doesn't reach minimum */
    502 	u_long	fr_bad;		/* bad IP packets to the filter */
    503 	u_long	fr_ipv6;	/* IPv6 packets in/out */
    504 	u_long	fr_ppshit;	/* dropped because of pps ceiling */
    505 	u_long	fr_ipud;	/* IP id update failures */
    506 } filterstats_4_1_t;
    507 
    508 /*
    509  * 5.1.0  new release (current)
    510  * 4.1.33 changed the size of f_locks from IPL_LOGMAX to IPL_LOGSIZE
    511  */
    512 typedef	struct	friostat_4_1_33	{
    513 	struct	filterstats_4_1	of_st[2];
    514 	struct	frentry	*f_ipf[2][2];
    515 	struct	frentry	*f_acct[2][2];
    516 	struct	frentry	*f_ipf6[2][2];
    517 	struct	frentry	*f_acct6[2][2];
    518 	struct	frentry	*f_auth;
    519 	struct	frgroup	*f_groups[IPL_LOGSIZE][2];
    520 	u_long	f_froute[2];
    521 	u_long	f_ticks;
    522 	int	f_locks[IPL_LOGSIZE];
    523 	size_t	f_kmutex_sz;
    524 	size_t	f_krwlock_sz;
    525 	int	f_defpass;	/* default pass - from fr_pass */
    526 	int	f_active;	/* 1 or 0 - active rule set */
    527 	int	f_running;	/* 1 if running, else 0 */
    528 	int	f_logging;	/* 1 if enabled, else 0 */
    529 	int	f_features;
    530 	char	f_version[32];	/* version string */
    531 } friostat_4_1_33_t;
    532 
    533 typedef struct friostat_4_1_0	{
    534 	struct filterstats_4_1 of_st[2];
    535 	struct frentry	*f_ipf[2][2];
    536 	struct frentry	*f_acct[2][2];
    537 	struct frentry	*f_ipf6[2][2];
    538 	struct frentry	*f_acct6[2][2];
    539 	struct frentry	*f_auth;
    540 	struct frgroup	*f_groups[IPL_LOGSIZE][2];
    541 	u_long	f_froute[2];
    542 	u_long	f_ticks;
    543 	int	f_locks[IPL_LOGMAX];
    544 	size_t	f_kmutex_sz;
    545 	size_t	f_krwlock_sz;
    546 	int	f_defpass;
    547 	int	f_active;
    548 	int	f_running;
    549 	int	f_logging;
    550 	int	f_features;
    551 	char	f_version[32];
    552 } friostat_4_1_0_t;
    553 
    554 /* ------------------------------------------------------------------------ */
    555 
    556 /*
    557  * 5.1.0  new release (current)
    558  * 4.1.14 added in_lock
    559  */
    560 typedef	struct	ipnat_4_1_14	{
    561 	ipfmutex_t	in_lock;
    562 	struct	ipnat	*in_next;		/* NAT rule list next */
    563 	struct	ipnat	*in_rnext;		/* rdr rule hash next */
    564 	struct	ipnat	**in_prnext;		/* prior rdr next ptr */
    565 	struct	ipnat	*in_mnext;		/* map rule hash next */
    566 	struct	ipnat	**in_pmnext;		/* prior map next ptr */
    567 	struct	ipftq	*in_tqehead[2];
    568 	void		*in_ifps[2];
    569 	void		*in_apr;
    570 	char		*in_comment;
    571 	i6addr_t	in_next6;
    572 	u_long		in_space;
    573 	u_long		in_hits;
    574 	u_int		in_use;
    575 	u_int		in_hv;
    576 	int		in_flineno;		/* conf. file line number */
    577 	u_short		in_pnext;
    578 	u_char		in_v;
    579 	u_char		in_xxx;
    580 	/* From here to the end is covered by IPN_CMPSIZ */
    581 	u_32_t		in_flags;
    582 	u_32_t		in_mssclamp;		/* if != 0 clamp MSS to this */
    583 	u_int		in_age[2];
    584 	int		in_redir;		/* see below for values */
    585 	int		in_p;			/* protocol. */
    586 	i6addr_t	in_in[2];
    587 	i6addr_t	in_out[2];
    588 	i6addr_t	in_src[2];
    589 	frtuc4_t	in_tuc;
    590 	u_short		in_port[2];
    591 	u_short		in_ppip;		/* ports per IP. */
    592 	u_short		in_ippip;		/* IP #'s per IP# */
    593 	char		in_ifnames[2][LIFNAMSIZ];
    594 	char		in_plabel[APR_LABELLEN];	/* proxy label. */
    595 	ipftag_t	in_tag;
    596 } ipnat_4_1_14_t;
    597 
    598 typedef	struct	ipnat_4_1_0	{
    599 	struct	ipnat	*in_next;
    600 	struct	ipnat	*in_rnext;
    601 	struct	ipnat	**in_prnext;
    602 	struct	ipnat	*in_mnext;
    603 	struct	ipnat	**in_pmnext;
    604 	struct	ipftq	*in_tqehead[2];
    605 	void		*in_ifps[2];
    606 	void		*in_apr;
    607 	char		*in_comment;
    608 	i6addr_t	in_next6;
    609 	u_long		in_space;
    610 	u_long		in_hits;
    611 	u_int		in_use;
    612 	u_int		in_hv;
    613 	int		in_flineno;
    614 	u_short		in_pnext;
    615 	u_char		in_v;
    616 	u_char		in_xxx;
    617 	u_32_t		in_flags;
    618 	u_32_t		in_mssclamp;
    619 	u_int		in_age[2];
    620 	int		in_redir;
    621 	int		in_p;
    622 	i6addr_t	in_in[2];
    623 	i6addr_t	in_out[2];
    624 	i6addr_t	in_src[2];
    625 	frtuc4_t	in_tuc;
    626 	u_short		in_port[2];
    627 	u_short		in_ppip;
    628 	u_short		in_ippip;
    629 	char		in_ifnames[2][LIFNAMSIZ];
    630 	char		in_plabel[APR_LABELLEN];
    631 	ipftag_t	in_tag;
    632 } ipnat_4_1_0_t;
    633 
    634 /* ------------------------------------------------------------------------ */
    635 
    636 typedef	struct	natlookup_4_1_1 {
    637 	struct	in_addr	onl_inip;
    638 	struct	in_addr	onl_outip;
    639 	struct	in_addr	onl_realip;
    640 	int	nl_flags;
    641 	u_short	nl_inport;
    642 	u_short	nl_outport;
    643 	u_short	nl_realport;
    644 } natlookup_4_1_1_t;
    645 
    646 /* ------------------------------------------------------------------------ */
    647 
    648 /*
    649  * 4.1.25 added nat_seqnext (current)
    650  * 4.1.14 added nat_redir
    651  * 4.1.3  moved nat_rev
    652  * 4.1.2  added nat_rev
    653  */
    654 typedef	struct	nat_4_1_25	{
    655 	ipfmutex_t	nat_lock;
    656 	struct	nat_4_1_25	*nat_next;
    657 	struct	nat_4_1_25	**nat_pnext;
    658 	struct	nat_4_1_25	*nat_hnext[2];
    659 	struct	nat_4_1_25	**nat_phnext[2];
    660 	struct	hostmap	*nat_hm;
    661 	void		*nat_data;
    662 	struct	nat_4_1_25	**nat_me;
    663 	struct	ipstate	*nat_state;
    664 	struct	ap_session	*nat_aps;
    665 	frentry_t	*nat_fr;
    666 	struct	ipnat_4_1_14	*nat_ptr;
    667 	void		*nat_ifps[2];
    668 	void		*nat_sync;
    669 	ipftqent_t	nat_tqe;
    670 	u_32_t		nat_flags;
    671 	u_32_t		nat_sumd[2];
    672 	u_32_t		nat_ipsumd;
    673 	u_32_t		nat_mssclamp;
    674 	i6addr_t	nat_inip6;
    675 	i6addr_t	nat_outip6;
    676 	i6addr_t	nat_oip6;
    677 	U_QUAD_T	nat_pkts[2];
    678 	U_QUAD_T	nat_bytes[2];
    679 	union	{
    680 		udpinfo_t	nat_unu;
    681 		tcpinfo4_t	nat_unt;
    682 		icmpinfo_t	nat_uni;
    683 		greinfo_t	nat_ugre;
    684 	} nat_un;
    685 	u_short		nat_oport;
    686 	u_short		nat_use;
    687 	u_char		nat_p;
    688 	int		nat_dir;
    689 	int		nat_ref;
    690 	int		nat_hv[2];
    691 	char		nat_ifnames[2][LIFNAMSIZ];
    692 	int		nat_rev;
    693 	int		nat_redir;
    694 	u_32_t		nat_seqnext[2];
    695 } nat_4_1_25_t;
    696 
    697 typedef	struct	nat_4_1_14	{
    698 	ipfmutex_t	nat_lock;
    699 	struct	nat	*nat_next;
    700 	struct	nat	**nat_pnext;
    701 	struct	nat	*nat_hnext[2];
    702 	struct	nat	**nat_phnext[2];
    703 	struct	hostmap	*nat_hm;
    704 	void		*nat_data;
    705 	struct	nat	**nat_me;
    706 	struct	ipstate	*nat_state;
    707 	struct	ap_session	*nat_aps;
    708 	frentry_t	*nat_fr;
    709 	struct	ipnat	*nat_ptr;
    710 	void		*nat_ifps[2];
    711 	void		*nat_sync;
    712 	ipftqent_t	nat_tqe;
    713 	u_32_t		nat_flags;
    714 	u_32_t		nat_sumd[2];
    715 	u_32_t		nat_ipsumd;
    716 	u_32_t		nat_mssclamp;
    717 	i6addr_t	nat_inip6;
    718 	i6addr_t	nat_outip6;
    719 	i6addr_t	nat_oip6;
    720 	U_QUAD_T	nat_pkts[2];
    721 	U_QUAD_T	nat_bytes[2];
    722 	union	{
    723 		udpinfo_t	nat_unu;
    724 		tcpinfo4_t	nat_unt;
    725 		icmpinfo_t	nat_uni;
    726 		greinfo_t	nat_ugre;
    727 	} nat_un;
    728 	u_short		nat_oport;
    729 	u_short		nat_use;
    730 	u_char		nat_p;
    731 	int		nat_dir;
    732 	int		nat_ref;
    733 	int		nat_hv[2];
    734 	char		nat_ifnames[2][LIFNAMSIZ];
    735 	int		nat_rev;
    736 	int		nat_redir;
    737 } nat_4_1_14_t;
    738 
    739 typedef	struct	nat_4_1_3	{
    740 	ipfmutex_t	nat_lock;
    741 	struct	nat	*nat_next;
    742 	struct	nat	**nat_pnext;
    743 	struct	nat	*nat_hnext[2];
    744 	struct	nat	**nat_phnext[2];
    745 	struct	hostmap	*nat_hm;
    746 	void		*nat_data;
    747 	struct	nat	**nat_me;
    748 	struct	ipstate	*nat_state;
    749 	struct	ap_session	*nat_aps;
    750 	frentry_t	*nat_fr;
    751 	struct	ipnat	*nat_ptr;
    752 	void		*nat_ifps[2];
    753 	void		*nat_sync;
    754 	ipftqent_t	nat_tqe;
    755 	u_32_t		nat_flags;
    756 	u_32_t		nat_sumd[2];
    757 	u_32_t		nat_ipsumd;
    758 	u_32_t		nat_mssclamp;
    759 	i6addr_t	nat_inip6;
    760 	i6addr_t	nat_outip6;
    761 	i6addr_t	nat_oip6;
    762 	U_QUAD_T	nat_pkts[2];
    763 	U_QUAD_T	nat_bytes[2];
    764 	union	{
    765 		udpinfo_t	nat_unu;
    766 		tcpinfo4_t	nat_unt;
    767 		icmpinfo_t	nat_uni;
    768 		greinfo_t	nat_ugre;
    769 	} nat_un;
    770 	u_short		nat_oport;
    771 	u_short		nat_use;
    772 	u_char		nat_p;
    773 	int		nat_dir;
    774 	int		nat_ref;
    775 	int		nat_hv[2];
    776 	char		nat_ifnames[2][LIFNAMSIZ];
    777 	int		nat_rev;
    778 } nat_4_1_3_t;
    779 
    780 
    781 
    782 typedef struct  nat_save_4_1_34    {
    783 	void			*ipn_next;
    784 	struct	nat_4_1_25	ipn_nat;
    785 	struct	ipnat_4_1_14	ipn_ipnat;
    786 	struct	frentry_4_1_34 	ipn_fr;
    787 	int			ipn_dsize;
    788 	char			ipn_data[4];
    789 } nat_save_4_1_34_t;
    790 
    791 typedef	struct	nat_save_4_1_16	{
    792 	void		*ipn_next;
    793 	nat_4_1_14_t	ipn_nat;
    794 	ipnat_t		ipn_ipnat;
    795 	frentry_4_1_16_t	ipn_fr;
    796 	int		ipn_dsize;
    797 	char		ipn_data[4];
    798 } nat_save_4_1_16_t;
    799 
    800 typedef	struct	nat_save_4_1_14	{
    801 	void		*ipn_next;
    802 	nat_4_1_14_t	ipn_nat;
    803 	ipnat_t		ipn_ipnat;
    804 	frentry_4_1_0_t	ipn_fr;
    805 	int		ipn_dsize;
    806 	char		ipn_data[4];
    807 } nat_save_4_1_14_t;
    808 
    809 typedef	struct	nat_save_4_1_3	{
    810 	void		*ipn_next;
    811 	nat_4_1_3_t	ipn_nat;
    812 	ipnat_4_1_0_t	ipn_ipnat;
    813 	frentry_4_1_0_t	ipn_fr;
    814 	int		ipn_dsize;
    815 	char		ipn_data[4];
    816 } nat_save_4_1_3_t;
    817 
    818 /* ------------------------------------------------------------------------ */
    819 
    820 /*
    821  * 5.1.0  new release (current)
    822  * 4.1.32 added ns_uncreate
    823  * 4.1.27 added ns_orphans
    824  * 4.1.16 added ns_ticks
    825  */
    826 typedef	struct	natstat_4_1_32	{
    827 	u_long	ns_mapped[2];
    828 	u_long	ns_rules;
    829 	u_long	ns_added;
    830 	u_long	ns_expire;
    831 	u_long	ns_inuse;
    832 	u_long	ns_logged;
    833 	u_long	ns_logfail;
    834 	u_long	ns_memfail;
    835 	u_long	ns_badnat;
    836 	u_long	ns_addtrpnt;
    837 	nat_t	**ns_table[2];
    838 	hostmap_t **ns_maptable;
    839 	ipnat_t	*ns_list;
    840 	void	*ns_apslist;
    841 	u_int	ns_wilds;
    842 	u_int	ns_nattab_sz;
    843 	u_int	ns_nattab_max;
    844 	u_int	ns_rultab_sz;
    845 	u_int	ns_rdrtab_sz;
    846 	u_int	ns_trpntab_sz;
    847 	u_int	ns_hostmap_sz;
    848 	nat_t	*ns_instances;
    849 	hostmap_t *ns_maplist;
    850 	u_long	*ns_bucketlen[2];
    851 	u_long	ns_ticks;
    852 	u_int	ns_orphans;
    853 	u_long	ns_uncreate[2][2];
    854 } natstat_4_1_32_t;
    855 
    856 typedef struct  natstat_4_1_27 {
    857 	u_long	ns_mapped[2];
    858 	u_long	ns_rules;
    859 	u_long	ns_added;
    860 	u_long	ns_expire;
    861 	u_long	ns_inuse;
    862 	u_long	ns_logged;
    863 	u_long	ns_logfail;
    864 	u_long	ns_memfail;
    865 	u_long	ns_badnat;
    866 	u_long	ns_addtrpnt;
    867 	nat_t	**ns_table[2];
    868 	hostmap_t **ns_maptable;
    869 	ipnat_t *ns_list;
    870 	void    *ns_apslist;
    871 	u_int   ns_wilds;
    872 	u_int   ns_nattab_sz;
    873 	u_int   ns_nattab_max;
    874 	u_int   ns_rultab_sz;
    875 	u_int   ns_rdrtab_sz;
    876 	u_int   ns_trpntab_sz;
    877 	u_int   ns_hostmap_sz;
    878 	nat_t   *ns_instances;
    879 	hostmap_t *ns_maplist;
    880 	u_long  *ns_bucketlen[2];
    881 	u_long  ns_ticks;
    882 	u_int   ns_orphans;
    883 } natstat_4_1_27_t;
    884 
    885 typedef struct  natstat_4_1_16 {
    886 	u_long	ns_mapped[2];
    887 	u_long	ns_rules;
    888 	u_long	ns_added;
    889 	u_long	ns_expire;
    890 	u_long	ns_inuse;
    891 	u_long	ns_logged;
    892 	u_long	ns_logfail;
    893 	u_long	ns_memfail;
    894 	u_long	ns_badnat;
    895 	u_long	ns_addtrpnt;
    896 	nat_t	**ns_table[2];
    897 	hostmap_t **ns_maptable;
    898 	ipnat_t *ns_list;
    899 	void    *ns_apslist;
    900 	u_int   ns_wilds;
    901 	u_int   ns_nattab_sz;
    902 	u_int   ns_nattab_max;
    903 	u_int   ns_rultab_sz;
    904 	u_int   ns_rdrtab_sz;
    905 	u_int   ns_trpntab_sz;
    906 	u_int   ns_hostmap_sz;
    907 	nat_t   *ns_instances;
    908 	hostmap_t *ns_maplist;
    909 	u_long  *ns_bucketlen[2];
    910 	u_long  ns_ticks;
    911 } natstat_4_1_16_t;
    912 
    913 typedef struct  natstat_4_1_0 {
    914 	u_long	ns_mapped[2];
    915 	u_long	ns_rules;
    916 	u_long	ns_added;
    917 	u_long	ns_expire;
    918 	u_long	ns_inuse;
    919 	u_long	ns_logged;
    920 	u_long	ns_logfail;
    921 	u_long	ns_memfail;
    922 	u_long	ns_badnat;
    923 	u_long	ns_addtrpnt;
    924 	nat_t	**ns_table[2];
    925 	hostmap_t **ns_maptable;
    926 	ipnat_t *ns_list;
    927 	void    *ns_apslist;
    928 	u_int   ns_wilds;
    929 	u_int   ns_nattab_sz;
    930 	u_int   ns_nattab_max;
    931 	u_int   ns_rultab_sz;
    932 	u_int   ns_rdrtab_sz;
    933 	u_int   ns_trpntab_sz;
    934 	u_int   ns_hostmap_sz;
    935 	nat_t   *ns_instances;
    936 	hostmap_t *ns_maplist;
    937 	u_long  *ns_bucketlen[2];
    938 } natstat_4_1_0_t;
    939 
    940 /* ------------------------------------------------------------------------ */
    941 
    942 /*
    943  * 5.1.0  new release (current)
    944  * 4.1.32 fra_info:removed both fin_state & fin_nat, added fin_pktnum
    945  * 4.1.29 added fra_flx
    946  * 4.1.24 fra_info:added fin_cksum
    947  * 4.1.23 fra_info:added fin_exthdr
    948  * 4.1.11 fra_info:added fin_ifname
    949  * 4.1.4  fra_info:added fin_hbuf
    950  */
    951 
    952 typedef struct  frauth_4_1_32 {
    953 	int	fra_age;
    954 	int	fra_len;
    955 	int	fra_index;
    956 	u_32_t	fra_pass;
    957 	fr_info_4_1_32_t	fra_info;
    958 	char	*fra_buf;
    959 	u_32_t	fra_flx;
    960 #ifdef	MENTAT
    961 	queue_t	*fra_q;
    962 	mb_t	*fra_m;
    963 #endif
    964 } frauth_4_1_32_t;
    965 
    966 typedef struct  frauth_4_1_29 {
    967 	int	fra_age;
    968 	int	fra_len;
    969 	int	fra_index;
    970 	u_32_t	fra_pass;
    971 	fr_info_4_1_24_t	fra_info;
    972 	char	*fra_buf;
    973 	u_32_t	fra_flx;
    974 #ifdef	MENTAT
    975 	queue_t	*fra_q;
    976 	mb_t	*fra_m;
    977 #endif
    978 } frauth_4_1_29_t;
    979 
    980 typedef struct  frauth_4_1_24 {
    981 	int	fra_age;
    982 	int	fra_len;
    983 	int	fra_index;
    984 	u_32_t	fra_pass;
    985 	fr_info_4_1_24_t	fra_info;
    986 	char	*fra_buf;
    987 #ifdef	MENTAT
    988 	queue_t	*fra_q;
    989 	mb_t	*fra_m;
    990 #endif
    991 } frauth_4_1_24_t;
    992 
    993 typedef struct  frauth_4_1_23 {
    994 	int	fra_age;
    995 	int	fra_len;
    996 	int	fra_index;
    997 	u_32_t	fra_pass;
    998 	fr_info_4_1_23_t	fra_info;
    999 	char	*fra_buf;
   1000 #ifdef	MENTAT
   1001 	queue_t	*fra_q;
   1002 	mb_t	*fra_m;
   1003 #endif
   1004 } frauth_4_1_23_t;
   1005 
   1006 typedef struct  frauth_4_1_11 {
   1007 	int	fra_age;
   1008 	int	fra_len;
   1009 	int	fra_index;
   1010 	u_32_t	fra_pass;
   1011 	fr_info_4_1_11_t	fra_info;
   1012 	char	*fra_buf;
   1013 #ifdef	MENTAT
   1014 	queue_t	*fra_q;
   1015 	mb_t	*fra_m;
   1016 #endif
   1017 } frauth_4_1_11_t;
   1018 
   1019 /* ------------------------------------------------------------------------ */
   1020 
   1021 /*
   1022  * 5.1.0  new release (current)
   1023  * 4.1.16 removed is_nat
   1024  */
   1025 typedef struct ipstate_4_1_16 {
   1026 	ipfmutex_t	is_lock;
   1027 	struct	ipstate	*is_next;
   1028 	struct	ipstate	**is_pnext;
   1029 	struct	ipstate	*is_hnext;
   1030 	struct	ipstate	**is_phnext;
   1031 	struct	ipstate	**is_me;
   1032 	void		*is_ifp[4];
   1033 	void		*is_sync;
   1034 	frentry_t	*is_rule;
   1035 	struct	ipftq	*is_tqehead[2];
   1036 	struct	ipscan	*is_isc;
   1037 	U_QUAD_T	is_pkts[4];
   1038 	U_QUAD_T	is_bytes[4];
   1039 	U_QUAD_T	is_icmppkts[4];
   1040 	struct	ipftqent is_sti;
   1041 	u_int	is_frage[2];
   1042 	int	is_ref;			/* reference count */
   1043 	int	is_isninc[2];
   1044 	u_short	is_sumd[2];
   1045 	i6addr_t	is_src;
   1046 	i6addr_t	is_dst;
   1047 	u_int	is_pass;
   1048 	u_char	is_p;			/* Protocol */
   1049 	u_char	is_v;
   1050 	u_32_t	is_hv;
   1051 	u_32_t	is_tag;
   1052 	u_32_t	is_opt[2];		/* packet options set */
   1053 	u_32_t	is_optmsk[2];		/*    "      "    mask */
   1054 	u_short	is_sec;			/* security options set */
   1055 	u_short	is_secmsk;		/*    "        "    mask */
   1056 	u_short	is_auth;		/* authentication options set */
   1057 	u_short	is_authmsk;		/*    "              "    mask */
   1058 	union {
   1059 		icmpinfo_t	is_ics;
   1060 		tcpinfo4_t	is_ts;
   1061 		udpinfo_t	is_us;
   1062 		greinfo_t	is_ug;
   1063 	} is_ps;
   1064 	u_32_t	is_flags;
   1065 	int	is_flx[2][2];
   1066 	u_32_t	is_rulen;		/* rule number when created */
   1067 	u_32_t	is_s0[2];
   1068 	u_short	is_smsk[2];
   1069 	char	is_group[FR_GROUPLEN];
   1070 	char	is_sbuf[2][16];
   1071 	char	is_ifname[4][LIFNAMSIZ];
   1072 } ipstate_4_1_16_t;
   1073 
   1074 typedef struct ipstate_4_1_0 {
   1075 	ipfmutex_t	is_lock;
   1076 	struct	ipstate	*is_next;
   1077 	struct	ipstate	**is_pnext;
   1078 	struct	ipstate	*is_hnext;
   1079 	struct	ipstate	**is_phnext;
   1080 	struct	ipstate	**is_me;
   1081 	void		*is_ifp[4];
   1082 	void		*is_sync;
   1083 	void		*is_nat[2];
   1084 	frentry_t	*is_rule;
   1085 	struct	ipftq	*is_tqehead[2];
   1086 	struct	ipscan	*is_isc;
   1087 	U_QUAD_T	is_pkts[4];
   1088 	U_QUAD_T	is_bytes[4];
   1089 	U_QUAD_T	is_icmppkts[4];
   1090 	struct	ipftqent is_sti;
   1091 	u_int	is_frage[2];
   1092 	int	is_ref;
   1093 	int	is_isninc[2];
   1094 	u_short	is_sumd[2];
   1095 	i6addr_t	is_src;
   1096 	i6addr_t	is_dst;
   1097 	u_int	is_pass;
   1098 	u_char	is_p;
   1099 	u_char	is_v;
   1100 	u_32_t	is_hv;
   1101 	u_32_t	is_tag;
   1102 	u_32_t	is_opt[2];
   1103 	u_32_t	is_optmsk[2];
   1104 	u_short	is_sec;
   1105 	u_short	is_secmsk;
   1106 	u_short	is_auth;
   1107 	u_short	is_authmsk;
   1108 	union {
   1109 		icmpinfo_t	is_ics;
   1110 		tcpinfo4_t	is_ts;
   1111 		udpinfo_t	is_us;
   1112 		greinfo_t	is_ug;
   1113 	} is_ps;
   1114 	u_32_t	is_flags;
   1115 	int	is_flx[2][2];
   1116 	u_32_t	is_rulen;
   1117 	u_32_t	is_s0[2];
   1118 	u_short	is_smsk[2];
   1119 	char	is_group[FR_GROUPLEN];
   1120 	char	is_sbuf[2][16];
   1121 	char	is_ifname[4][LIFNAMSIZ];
   1122 } ipstate_4_1_0_t;
   1123 
   1124 typedef	struct	ipstate_save_4_1_34	{
   1125 	void	*ips_next;
   1126 	struct	ipstate_4_1_16	ips_is;
   1127 	struct	frentry_4_1_34	ips_fr;
   1128 } ipstate_save_4_1_34_t;
   1129 
   1130 typedef	struct	ipstate_save_4_1_16	{
   1131 	void		*ips_next;
   1132 	ipstate_4_1_0_t	ips_is;
   1133 	frentry_4_1_16_t	ips_fr;
   1134 } ipstate_save_4_1_16_t;
   1135 
   1136 typedef	struct	ipstate_save_4_1_0	{
   1137 	void		*ips_next;
   1138 	ipstate_4_1_0_t	ips_is;
   1139 	frentry_4_1_0_t	ips_fr;
   1140 } ipstate_save_4_1_0_t;
   1141 
   1142 /* ------------------------------------------------------------------------ */
   1143 
   1144 /*
   1145  * 5.1.0  new release (current)
   1146  * 4.1.21 added iss_tcptab
   1147  */
   1148 typedef	struct	ips_stat_4_1_21 {
   1149 	u_long	iss_hits;
   1150 	u_long	iss_miss;
   1151 	u_long	iss_max;
   1152 	u_long	iss_maxref;
   1153 	u_long	iss_tcp;
   1154 	u_long	iss_udp;
   1155 	u_long	iss_icmp;
   1156 	u_long	iss_nomem;
   1157 	u_long	iss_expire;
   1158 	u_long	iss_fin;
   1159 	u_long	iss_active;
   1160 	u_long	iss_logged;
   1161 	u_long	iss_logfail;
   1162 	u_long	iss_inuse;
   1163 	u_long	iss_wild;
   1164 	u_long	iss_killed;
   1165 	u_long	iss_ticks;
   1166 	u_long	iss_bucketfull;
   1167 	int	iss_statesize;
   1168 	int	iss_statemax;
   1169 	ipstate_t **iss_table;
   1170 	ipstate_t *iss_list;
   1171 	u_long	*iss_bucketlen;
   1172 	ipftq_t	*iss_tcptab;
   1173 } ips_stat_4_1_21_t;
   1174 
   1175 typedef	struct	ips_stat_4_1_0 {
   1176 	u_long	iss_hits;
   1177 	u_long	iss_miss;
   1178 	u_long	iss_max;
   1179 	u_long	iss_maxref;
   1180 	u_long	iss_tcp;
   1181 	u_long	iss_udp;
   1182 	u_long	iss_icmp;
   1183 	u_long	iss_nomem;
   1184 	u_long	iss_expire;
   1185 	u_long	iss_fin;
   1186 	u_long	iss_active;
   1187 	u_long	iss_logged;
   1188 	u_long	iss_logfail;
   1189 	u_long	iss_inuse;
   1190 	u_long	iss_wild;
   1191 	u_long	iss_killed;
   1192 	u_long	iss_ticks;
   1193 	u_long	iss_bucketfull;
   1194 	int	iss_statesize;
   1195 	int	iss_statemax;
   1196 	ipstate_t **iss_table;
   1197 	ipstate_t *iss_list;
   1198 	u_long	*iss_bucketlen;
   1199 } ips_stat_4_1_0_t;
   1200 
   1201 /* ------------------------------------------------------------------------ */
   1202 static int ipf_addfrstr(char *, int, char *, int);
   1203 static void ipf_v4iptov5(frip4_t *, fr_ip_t *);
   1204 static void ipf_v5iptov4(fr_ip_t *, frip4_t *);
   1205 static void ipfv4tuctov5(frtuc4_t *, frtuc_t *);
   1206 static void ipfv5tuctov4(frtuc_t *, frtuc4_t *);
   1207 static int ipf_v4fripftov5(fripf4_t *, char *);
   1208 static void ipf_v5fripftov4(fripf_t *, fripf4_t *);
   1209 static int fr_frflags4to5(u_32_t);
   1210 static int fr_frflags5to4(u_32_t);
   1211 
   1212 typedef	struct	ipfrstat_4_1_1 {
   1213 	u_long	ifs_exists;	/* add & already exists */
   1214 	u_long	ifs_nomem;
   1215 	u_long	ifs_new;
   1216 	u_long	ifs_hits;
   1217 	u_long	ifs_expire;
   1218 	u_long	ifs_inuse;
   1219 	u_long	ifs_retrans0;
   1220 	u_long	ifs_short;
   1221 	struct	ipfr	**ifs_table;
   1222 	struct	ipfr	**ifs_nattab;
   1223 } ipfrstat_4_1_1_t;
   1224 
   1225 /* ------------------------------------------------------------------------ */
   1226 static int ipf_addfrstr(char *, int, char *, int);
   1227 static void ipf_v4iptov5(frip4_t *, fr_ip_t *);
   1228 static void ipf_v5iptov4(fr_ip_t *, frip4_t *);
   1229 static void ipfv4tuctov5(frtuc4_t *, frtuc_t *);
   1230 static void ipfv5tuctov4(frtuc_t *, frtuc4_t *);
   1231 static int ipf_v4fripftov5(fripf4_t *, char *);
   1232 static void ipf_v5fripftov4(fripf_t *, fripf4_t *);
   1233 static int fr_frflags4to5(u_32_t);
   1234 static int fr_frflags5to4(u_32_t);
   1235 
   1236 static void friostat_current_to_4_1_0(void *, friostat_4_1_0_t *, int);
   1237 static void friostat_current_to_4_1_33(void *, friostat_4_1_33_t *, int);
   1238 static void ipstate_current_to_4_1_0(void *, ipstate_4_1_0_t *);
   1239 static void ipstate_current_to_4_1_16(void *, ipstate_4_1_16_t *);
   1240 static void ipnat_current_to_4_1_0(void *, ipnat_4_1_0_t *);
   1241 static void ipnat_current_to_4_1_14(void *, ipnat_4_1_14_t *);
   1242 static void frauth_current_to_4_1_11(void *, frauth_4_1_11_t *);
   1243 static void frauth_current_to_4_1_23(void *, frauth_4_1_23_t *);
   1244 static void frauth_current_to_4_1_24(void *, frauth_4_1_24_t *);
   1245 static void frauth_current_to_4_1_29(void *, frauth_4_1_29_t *);
   1246 static void frentry_current_to_4_1_0(void *, frentry_4_1_0_t *);
   1247 static void frentry_current_to_4_1_16(void *, frentry_4_1_16_t *);
   1248 static void frentry_current_to_4_1_34(void *, frentry_4_1_34_t *);
   1249 static void fr_info_current_to_4_1_11(void *, fr_info_4_1_11_t *);
   1250 static void fr_info_current_to_4_1_23(void *, fr_info_4_1_23_t *);
   1251 static void fr_info_current_to_4_1_24(void *, fr_info_4_1_24_t *);
   1252 static void nat_save_current_to_4_1_3(void *, nat_save_4_1_3_t *);
   1253 static void nat_save_current_to_4_1_14(void *, nat_save_4_1_14_t *);
   1254 static void nat_save_current_to_4_1_16(void *, nat_save_4_1_16_t *);
   1255 static void ipstate_save_current_to_4_1_0(void *, ipstate_save_4_1_0_t *);
   1256 static void ipstate_save_current_to_4_1_16(void *, ipstate_save_4_1_16_t *);
   1257 static void ips_stat_current_to_4_1_0(void *, ips_stat_4_1_0_t *);
   1258 static void ips_stat_current_to_4_1_21(void *, ips_stat_4_1_21_t *);
   1259 static void natstat_current_to_4_1_0(void *, natstat_4_1_0_t *);
   1260 static void natstat_current_to_4_1_16(void *, natstat_4_1_16_t *);
   1261 static void natstat_current_to_4_1_27(void *, natstat_4_1_27_t *);
   1262 static void natstat_current_to_4_1_32(void *, natstat_4_1_32_t *);
   1263 static void nat_current_to_4_1_3(void *, nat_4_1_3_t *);
   1264 static void nat_current_to_4_1_14(void *, nat_4_1_14_t *);
   1265 static void nat_current_to_4_1_25(void *, nat_4_1_25_t *);
   1266 
   1267 static void friostat_4_1_0_to_current(friostat_4_1_0_t *, void *);
   1268 static void friostat_4_1_33_to_current(friostat_4_1_33_t *, void *);
   1269 static void ipnat_4_1_0_to_current(ipnat_4_1_0_t *, void *, int);
   1270 static void ipnat_4_1_14_to_current(ipnat_4_1_14_t *, void *, int);
   1271 static void frauth_4_1_11_to_current(frauth_4_1_11_t *, void *);
   1272 static void frauth_4_1_23_to_current(frauth_4_1_23_t *, void *);
   1273 static void frauth_4_1_24_to_current(frauth_4_1_24_t *, void *);
   1274 static void frauth_4_1_29_to_current(frauth_4_1_29_t *, void *);
   1275 static void frauth_4_1_32_to_current(frauth_4_1_32_t *, void *);
   1276 static void frentry_4_1_0_to_current(ipf_main_softc_t *, frentry_4_1_0_t *, void *, int);
   1277 static void frentry_4_1_16_to_current(ipf_main_softc_t *, frentry_4_1_16_t *, void *, int);
   1278 static void frentry_4_1_34_to_current(ipf_main_softc_t *, frentry_4_1_34_t *, void *, int);
   1279 static void fr_info_4_1_11_to_current(fr_info_4_1_11_t *, void *);
   1280 static void fr_info_4_1_23_to_current(fr_info_4_1_23_t *, void *);
   1281 static void fr_info_4_1_24_to_current(fr_info_4_1_24_t *, void *);
   1282 static void fr_info_4_1_32_to_current(fr_info_4_1_32_t *, void *);
   1283 static void nat_save_4_1_3_to_current(ipf_main_softc_t *, nat_save_4_1_3_t *, void *);
   1284 static void nat_save_4_1_14_to_current(ipf_main_softc_t *, nat_save_4_1_14_t *, void *);
   1285 static void nat_save_4_1_16_to_current(ipf_main_softc_t *, nat_save_4_1_16_t *, void *);
   1286 
   1287 /* ------------------------------------------------------------------------ */
   1288 /* In this section is a series of short routines that deal with translating */
   1289 /* the smaller data structures used above as their internal changes make    */
   1290 /* them inappropriate for simple assignment.                                */
   1291 /* ------------------------------------------------------------------------ */
   1292 
   1293 
   1294 static int
   1295 ipf_addfrstr(char *names, int namelen, char *str, int maxlen)
   1296 {
   1297 	char *t;
   1298 	int i;
   1299 
   1300 	for (i = maxlen, t = str; (*t != '\0') && (i > 0); i--) {
   1301 		names[namelen++] = *t++;
   1302 	}
   1303 	names[namelen++] = '\0';
   1304 	return namelen;
   1305 }
   1306 
   1307 
   1308 static void
   1309 ipf_v4iptov5(frip4_t *v4, fr_ip_t *v5)
   1310 {
   1311 	v5->fi_v = v4->fi_v;
   1312 	v5->fi_p = v4->fi_p;
   1313 	v5->fi_xx = v4->fi_xx;
   1314 	v5->fi_tos = v4->fi_tos;
   1315 	v5->fi_ttl = v4->fi_ttl;
   1316 	v5->fi_p = v4->fi_p;
   1317 	v5->fi_optmsk = v4->fi_optmsk;
   1318 	v5->fi_src = v4->fi_src;
   1319 	v5->fi_dst = v4->fi_dst;
   1320 	v5->fi_secmsk = v4->ofi_secmsk;
   1321 	v5->fi_auth = v4->ofi_auth;
   1322 	v5->fi_flx = v4->fi_flx;
   1323 	v5->fi_tcpmsk = v4->fi_tcpmsk;
   1324 }
   1325 
   1326 static void
   1327 ipf_v5iptov4(fr_ip_t *v5, frip4_t *v4)
   1328 {
   1329 	v4->fi_v = v5->fi_v;
   1330 	v4->fi_p = v5->fi_p;
   1331 	v4->fi_xx = v5->fi_xx;
   1332 	v4->fi_tos = v5->fi_tos;
   1333 	v4->fi_ttl = v5->fi_ttl;
   1334 	v4->fi_p = v5->fi_p;
   1335 	v4->fi_optmsk = v5->fi_optmsk;
   1336 	v4->fi_src = v5->fi_src;
   1337 	v4->fi_dst = v5->fi_dst;
   1338 	v4->ofi_secmsk = v5->fi_secmsk;
   1339 	v4->ofi_auth = v5->fi_auth;
   1340 	v4->fi_flx = v5->fi_flx;
   1341 	v4->fi_tcpmsk = v5->fi_tcpmsk;
   1342 }
   1343 
   1344 
   1345 static void
   1346 ipfv4tuctov5(frtuc4_t *v4, frtuc_t *v5)
   1347 {
   1348 	v5->ftu_src.frp_cmp = v4->ftu_src.frp_cmp;
   1349 	v5->ftu_src.frp_port = v4->ftu_src.frp_port;
   1350 	v5->ftu_src.frp_top = v4->ftu_src.frp_top;
   1351 	v5->ftu_dst.frp_cmp = v4->ftu_dst.frp_cmp;
   1352 	v5->ftu_dst.frp_port = v4->ftu_dst.frp_port;
   1353 	v5->ftu_dst.frp_top = v4->ftu_dst.frp_top;
   1354 }
   1355 
   1356 
   1357 static void
   1358 ipfv5tuctov4(frtuc_t *v5, frtuc4_t *v4)
   1359 {
   1360 	v4->ftu_src.frp_cmp = v5->ftu_src.frp_cmp;
   1361 	v4->ftu_src.frp_port = v5->ftu_src.frp_port;
   1362 	v4->ftu_src.frp_top = v5->ftu_src.frp_top;
   1363 	v4->ftu_dst.frp_cmp = v5->ftu_dst.frp_cmp;
   1364 	v4->ftu_dst.frp_port = v5->ftu_dst.frp_port;
   1365 	v4->ftu_dst.frp_top = v5->ftu_dst.frp_top;
   1366 }
   1367 
   1368 
   1369 static int
   1370 ipf_v4fripftov5(fripf4_t *frp4, char *dst)
   1371 {
   1372 	fripf_t *frp;
   1373 
   1374 	frp = (fripf_t *)dst;
   1375 
   1376 	ipf_v4iptov5(&frp4->fri_ip, &frp->fri_ip);
   1377 	ipf_v4iptov5(&frp4->fri_mip, &frp->fri_mip);
   1378 	frp->fri_icmpm = frp4->fri_icmpm;
   1379 	frp->fri_icmp = frp4->fri_icmp;
   1380 	frp->fri_tuc.ftu_tcpfm = frp4->fri_tuc.ftu_tcpfm;
   1381 	frp->fri_tuc.ftu_tcpf = frp4->fri_tuc.ftu_tcpf;
   1382 	ipfv4tuctov5(&frp4->fri_tuc, &frp->fri_tuc);
   1383 	frp->fri_satype = frp4->fri_satype;
   1384 	frp->fri_datype = frp4->fri_datype;
   1385 	frp->fri_sifpidx = frp4->fri_sifpidx;
   1386 	frp->fri_difpidx = frp4->fri_difpidx;
   1387 	return 0;
   1388 }
   1389 
   1390 
   1391 static void
   1392 ipf_v5fripftov4(fripf_t *frp, fripf4_t *frp4)
   1393 {
   1394 
   1395 	ipf_v5iptov4(&frp->fri_ip, &frp4->fri_ip);
   1396 	ipf_v5iptov4(&frp->fri_mip, &frp4->fri_mip);
   1397 	frp4->fri_icmpm = frp->fri_icmpm;
   1398 	frp4->fri_icmp = frp->fri_icmp;
   1399 	frp4->fri_tuc.ftu_tcpfm = frp->fri_tuc.ftu_tcpfm;
   1400 	frp4->fri_tuc.ftu_tcpf = frp->fri_tuc.ftu_tcpf;
   1401 	ipfv5tuctov4(&frp->fri_tuc, &frp4->fri_tuc);
   1402 	frp4->fri_satype = frp->fri_satype;
   1403 	frp4->fri_datype = frp->fri_datype;
   1404 	frp4->fri_sifpidx = frp->fri_sifpidx;
   1405 	frp4->fri_difpidx = frp->fri_difpidx;
   1406 }
   1407 
   1408 
   1409 /* ------------------------------------------------------------------------ */
   1410 /* ipf_in_compat is the first of two service routines. It is responsible for*/
   1411 /* converting data structures from user space into what's required by the   */
   1412 /* kernel module.                                                           */
   1413 /* ------------------------------------------------------------------------ */
   1414 int
   1415 ipf_in_compat(ipf_main_softc_t *softc, ipfobj_t *obj, void *ptr, int size)
   1416 {
   1417 	int error;
   1418 	int sz;
   1419 
   1420 	IPFERROR(140000);
   1421 	error = EINVAL;
   1422 
   1423 	switch (obj->ipfo_type)
   1424 	{
   1425 	default :
   1426 		break;
   1427 
   1428 	case IPFOBJ_FRENTRY :
   1429 		if (obj->ipfo_rev >= 4013400) {
   1430 			frentry_4_1_34_t *old;
   1431 
   1432 			KMALLOC(old, frentry_4_1_34_t *);
   1433 			if (old == NULL) {
   1434 				IPFERROR(140001);
   1435 				error = ENOMEM;
   1436 				break;
   1437 			}
   1438 			error = COPYIN(obj->ipfo_ptr, old, sizeof(*old));
   1439 			if (error == 0) {
   1440 				if (old->fr_type != FR_T_NONE &&
   1441 				    old->fr_type != FR_T_IPF) {
   1442 					IPFERROR(140002);
   1443 					error = EINVAL;
   1444 					KFREE(old);
   1445 					break;
   1446 				}
   1447 				frentry_4_1_34_to_current(softc, old,
   1448 							  ptr, size);
   1449 			} else {
   1450 				IPFERROR(140003);
   1451 			}
   1452 			KFREE(old);
   1453 		} else if (obj->ipfo_rev >= 4011600) {
   1454 			frentry_4_1_16_t *old;
   1455 
   1456 			KMALLOC(old, frentry_4_1_16_t *);
   1457 			if (old == NULL) {
   1458 				IPFERROR(140004);
   1459 				error = ENOMEM;
   1460 				break;
   1461 			}
   1462 			error = COPYIN(obj->ipfo_ptr, old, sizeof(*old));
   1463 			if (error == 0) {
   1464 				if (old->fr_type != FR_T_NONE &&
   1465 				    old->fr_type != FR_T_IPF) {
   1466 					IPFERROR(140005);
   1467 					error = EINVAL;
   1468 					KFREE(old);
   1469 					break;
   1470 				}
   1471 				frentry_4_1_16_to_current(softc, old,
   1472 							  ptr, size);
   1473 			} else {
   1474 				IPFERROR(140006);
   1475 			}
   1476 			KFREE(old);
   1477 		} else {
   1478 			frentry_4_1_0_t *old;
   1479 
   1480 			KMALLOC(old, frentry_4_1_0_t *);
   1481 			if (old == NULL) {
   1482 				IPFERROR(140007);
   1483 				error = ENOMEM;
   1484 				break;
   1485 			}
   1486 			error = COPYIN(obj->ipfo_ptr, old, sizeof(*old));
   1487 			if (error == 0) {
   1488 				if (old->fr_type != FR_T_NONE &&
   1489 				    old->fr_type != FR_T_IPF) {
   1490 					IPFERROR(140008);
   1491 					error = EINVAL;
   1492 					KFREE(old);
   1493 					break;
   1494 				}
   1495 				frentry_4_1_0_to_current(softc, old, ptr, size);
   1496 			} else {
   1497 				IPFERROR(140009);
   1498 			}
   1499 			KFREE(old);
   1500 		}
   1501 		break;
   1502 
   1503 	case IPFOBJ_IPFSTAT :
   1504 		if (obj->ipfo_rev >= 4013300) {
   1505 			friostat_4_1_33_t *old;
   1506 
   1507 			KMALLOC(old, friostat_4_1_33_t *);
   1508 			if (old == NULL) {
   1509 				IPFERROR(140010);
   1510 				error = ENOMEM;
   1511 				break;
   1512 			}
   1513 			error = COPYIN(obj->ipfo_ptr, old, sizeof(*old));
   1514 			if (error == 0) {
   1515 				friostat_4_1_33_to_current(old, ptr);
   1516 			} else {
   1517 				IPFERROR(140011);
   1518 			}
   1519 		} else {
   1520 			friostat_4_1_0_t *old;
   1521 
   1522 			KMALLOC(old, friostat_4_1_0_t *);
   1523 			if (old == NULL) {
   1524 				IPFERROR(140012);
   1525 				error = ENOMEM;
   1526 				break;
   1527 			}
   1528 			error = COPYIN(obj->ipfo_ptr, old, sizeof(*old));
   1529 			if (error == 0) {
   1530 				friostat_4_1_0_to_current(old, ptr);
   1531 			} else {
   1532 				IPFERROR(140013);
   1533 			}
   1534 		}
   1535 		break;
   1536 
   1537 	case IPFOBJ_IPFINFO :	/* unused */
   1538 		break;
   1539 
   1540 	case IPFOBJ_IPNAT :
   1541 		if (obj->ipfo_rev >= 4011400) {
   1542 			ipnat_4_1_14_t *old;
   1543 
   1544 			KMALLOC(old, ipnat_4_1_14_t *);
   1545 			if (old == NULL) {
   1546 				IPFERROR(140014);
   1547 				error = ENOMEM;
   1548 				break;
   1549 			}
   1550 			error = COPYIN(obj->ipfo_ptr, old, sizeof(*old));
   1551 			if (error == 0) {
   1552 				ipnat_4_1_14_to_current(old, ptr, size);
   1553 			} else {
   1554 				IPFERROR(140015);
   1555 			}
   1556 			KFREE(old);
   1557 		} else {
   1558 			ipnat_4_1_0_t *old;
   1559 
   1560 			KMALLOC(old, ipnat_4_1_0_t *);
   1561 			if (old == NULL) {
   1562 				IPFERROR(140016);
   1563 				error = ENOMEM;
   1564 				break;
   1565 			}
   1566 			error = COPYIN(obj->ipfo_ptr, old, sizeof(*old));
   1567 			if (error == 0) {
   1568 				ipnat_4_1_0_to_current(old, ptr, size);
   1569 			} else {
   1570 				IPFERROR(140017);
   1571 			}
   1572 			KFREE(old);
   1573 		}
   1574 		break;
   1575 
   1576 	case IPFOBJ_NATSTAT :
   1577 		/*
   1578 		 * Statistics are not copied in.
   1579 		 */
   1580 		break;
   1581 
   1582 	case IPFOBJ_NATSAVE :
   1583 		if (obj->ipfo_rev >= 4011600) {
   1584 			nat_save_4_1_16_t *old16;
   1585 
   1586 			KMALLOC(old16, nat_save_4_1_16_t *);
   1587 			if (old16 == NULL) {
   1588 				IPFERROR(140018);
   1589 				error = ENOMEM;
   1590 				break;
   1591 			}
   1592 			error = COPYIN(obj->ipfo_ptr, old16, sizeof(*old16));
   1593 			if (error == 0) {
   1594 				nat_save_4_1_16_to_current(softc, old16, ptr);
   1595 			} else {
   1596 				IPFERROR(140019);
   1597 			}
   1598 			KFREE(old16);
   1599 		} else if (obj->ipfo_rev >= 4011400) {
   1600 			nat_save_4_1_14_t *old14;
   1601 
   1602 			KMALLOC(old14, nat_save_4_1_14_t *);
   1603 			if (old14 == NULL) {
   1604 				IPFERROR(140020);
   1605 				error = ENOMEM;
   1606 				break;
   1607 			}
   1608 			error = COPYIN(obj->ipfo_ptr, old14, sizeof(*old14));
   1609 			if (error == 0) {
   1610 				nat_save_4_1_14_to_current(softc, old14, ptr);
   1611 			} else {
   1612 				IPFERROR(140021);
   1613 			}
   1614 			KFREE(old14);
   1615 		} else if (obj->ipfo_rev >= 4010300) {
   1616 			nat_save_4_1_3_t *old3;
   1617 
   1618 			KMALLOC(old3, nat_save_4_1_3_t *);
   1619 			if (old3 == NULL) {
   1620 				IPFERROR(140022);
   1621 				error = ENOMEM;
   1622 				break;
   1623 			}
   1624 			error = COPYIN(obj->ipfo_ptr, old3, sizeof(*old3));
   1625 			if (error == 0) {
   1626 				nat_save_4_1_3_to_current(softc, old3, ptr);
   1627 			} else {
   1628 				IPFERROR(140023);
   1629 			}
   1630 			KFREE(old3);
   1631 		}
   1632 		break;
   1633 
   1634 	case IPFOBJ_STATESAVE :
   1635 		if (obj->ipfo_rev >= 4013400) {
   1636 			ipstate_save_4_1_34_t *old;
   1637 
   1638 			KMALLOC(old, ipstate_save_4_1_34_t *);
   1639 			if (old == NULL) {
   1640 				IPFERROR(140024);
   1641 				error = ENOMEM;
   1642 				break;
   1643 			}
   1644 			error = COPYIN(obj->ipfo_ptr, old, sizeof(*old));
   1645 			if (error != 0) {
   1646 				IPFERROR(140025);
   1647 			}
   1648 			KFREE(old);
   1649 		} else if (obj->ipfo_rev >= 4011600) {
   1650 			ipstate_save_4_1_16_t *old;
   1651 
   1652 			KMALLOC(old, ipstate_save_4_1_16_t *);
   1653 			if (old == NULL) {
   1654 				IPFERROR(140026);
   1655 				error = ENOMEM;
   1656 				break;
   1657 			}
   1658 			error = COPYIN(obj->ipfo_ptr, old, sizeof(*old));
   1659 			if (error != 0) {
   1660 				IPFERROR(140027);
   1661 			}
   1662 			KFREE(old);
   1663 		} else {
   1664 			ipstate_save_4_1_0_t *old;
   1665 
   1666 			KMALLOC(old, ipstate_save_4_1_0_t *);
   1667 			if (old == NULL) {
   1668 				IPFERROR(140028);
   1669 				error = ENOMEM;
   1670 				break;
   1671 			}
   1672 			error = COPYIN(obj->ipfo_ptr, old, sizeof(*old));
   1673 			if (error != 0) {
   1674 				IPFERROR(140029);
   1675 			}
   1676 			KFREE(old);
   1677 		}
   1678 		break;
   1679 
   1680 	case IPFOBJ_IPSTATE :
   1681 		/*
   1682 		 * This structure is not copied in by itself.
   1683 		 */
   1684 		break;
   1685 
   1686 	case IPFOBJ_STATESTAT :
   1687 		/*
   1688 		 * Statistics are not copied in.
   1689 		 */
   1690 		break;
   1691 
   1692 	case IPFOBJ_FRAUTH :
   1693 		if (obj->ipfo_rev >= 4013200) {
   1694 			frauth_4_1_32_t *old32;
   1695 
   1696 			KMALLOC(old32, frauth_4_1_32_t *);
   1697 			if (old32 == NULL) {
   1698 				IPFERROR(140030);
   1699 				error = ENOMEM;
   1700 				break;
   1701 			}
   1702 			error = COPYIN(obj->ipfo_ptr, old32, sizeof(*old32));
   1703 			if (error == 0) {
   1704 				frauth_4_1_32_to_current(old32, ptr);
   1705 			} else {
   1706 				IPFERROR(140031);
   1707 			}
   1708 			KFREE(old32);
   1709 		} else if (obj->ipfo_rev >= 4012900) {
   1710 			frauth_4_1_29_t *old29;
   1711 
   1712 			KMALLOC(old29, frauth_4_1_29_t *);
   1713 			if (old29 == NULL) {
   1714 				IPFERROR(140032);
   1715 				error = ENOMEM;
   1716 				break;
   1717 			}
   1718 			error = COPYIN(obj->ipfo_ptr, old29, sizeof(*old29));
   1719 			if (error == 0) {
   1720 				frauth_4_1_29_to_current(old29, ptr);
   1721 			} else {
   1722 				IPFERROR(140033);
   1723 			}
   1724 			KFREE(old29);
   1725 		} else if (obj->ipfo_rev >= 4012400) {
   1726 			frauth_4_1_24_t *old24;
   1727 
   1728 			KMALLOC(old24, frauth_4_1_24_t *);
   1729 			if (old24 == NULL) {
   1730 				IPFERROR(140034);
   1731 				error = ENOMEM;
   1732 				break;
   1733 			}
   1734 			error = COPYIN(obj->ipfo_ptr, old24, sizeof(*old24));
   1735 			if (error == 0) {
   1736 				frauth_4_1_24_to_current(old24, ptr);
   1737 			} else {
   1738 				IPFERROR(140035);
   1739 			}
   1740 			KFREE(old24);
   1741 		} else if (obj->ipfo_rev >= 4012300) {
   1742 			frauth_4_1_23_t *old23;
   1743 
   1744 			KMALLOC(old23, frauth_4_1_23_t *);
   1745 			if (old23 == NULL) {
   1746 				IPFERROR(140036);
   1747 				error = ENOMEM;
   1748 				break;
   1749 			}
   1750 			error = COPYIN(obj->ipfo_ptr, old23, sizeof(*old23));
   1751 			if (error == 0)
   1752 				frauth_4_1_23_to_current(old23, ptr);
   1753 			KFREE(old23);
   1754 		} else if (obj->ipfo_rev >= 4011100) {
   1755 			frauth_4_1_11_t *old11;
   1756 
   1757 			KMALLOC(old11, frauth_4_1_11_t *);
   1758 			if (old11 == NULL) {
   1759 				IPFERROR(140037);
   1760 				error = ENOMEM;
   1761 				break;
   1762 			}
   1763 			error = COPYIN(obj->ipfo_ptr, old11, sizeof(*old11));
   1764 			if (error == 0) {
   1765 				frauth_4_1_11_to_current(old11, ptr);
   1766 			} else {
   1767 				IPFERROR(140038);
   1768 			}
   1769 			KFREE(old11);
   1770 		}
   1771 		break;
   1772 
   1773 	case IPFOBJ_NAT :
   1774 		if (obj->ipfo_rev >= 4011400) {
   1775 			sz = sizeof(nat_4_1_14_t);
   1776 		} else if (obj->ipfo_rev >= 4010300) {
   1777 			sz = sizeof(nat_4_1_3_t);
   1778 		} else {
   1779 			break;
   1780 		}
   1781 		bzero(ptr, sizeof(nat_t));
   1782 		error = COPYIN(obj->ipfo_ptr, ptr, sz);
   1783 		if (error != 0) {
   1784 			IPFERROR(140039);
   1785 		}
   1786 		break;
   1787 
   1788 	case IPFOBJ_FRIPF :
   1789 		if (obj->ipfo_rev < 5000000) {
   1790 			fripf4_t *old;
   1791 
   1792 			KMALLOC(old, fripf4_t *);
   1793 			if (old == NULL) {
   1794 				IPFERROR(140040);
   1795 				error = ENOMEM;
   1796 				break;
   1797 			}
   1798 			error = COPYIN(obj->ipfo_ptr, old, sizeof(*old));
   1799 			if (error == 0) {
   1800 				ipf_v4fripftov5(old, ptr);
   1801 			} else {
   1802 				IPFERROR(140041);
   1803 			}
   1804 			KFREE(old);
   1805 		}
   1806 		break;
   1807 	}
   1808 
   1809 	return error;
   1810 }
   1811 /* ------------------------------------------------------------------------ */
   1812 
   1813 
   1814 /*
   1815  * flags is v4 flags, returns v5 flags.
   1816  */
   1817 static int
   1818 fr_frflags4to5(u_32_t flags)
   1819 {
   1820 	u_32_t nflags = 0;
   1821 
   1822 	switch (flags & 0xf) {
   1823 	case 0x0 :
   1824 		nflags |= FR_CALL;
   1825 		break;
   1826 	case 0x1 :
   1827 		nflags |= FR_BLOCK;
   1828 		break;
   1829 	case 0x2 :
   1830 		nflags |= FR_PASS;
   1831 		break;
   1832 	case 0x3 :
   1833 		nflags |= FR_AUTH;
   1834 		break;
   1835 	case 0x4 :
   1836 		nflags |= FR_PREAUTH;
   1837 		break;
   1838 	case 0x5 :
   1839 		nflags |= FR_ACCOUNT;
   1840 		break;
   1841 	case 0x6 :
   1842 		nflags |= FR_SKIP;
   1843 		break;
   1844 	default :
   1845 		break;
   1846 	}
   1847 
   1848 	if (flags & 0x00010)
   1849 		nflags |= FR_LOG;
   1850 	if (flags & 0x00020)
   1851 		nflags |= FR_CALLNOW;
   1852 	if (flags & 0x00080)
   1853 		nflags |= FR_NOTSRCIP;
   1854 	if (flags & 0x00040)
   1855 		nflags |= FR_NOTDSTIP;
   1856 	if (flags & 0x00100)
   1857 		nflags |= FR_QUICK;
   1858 	if (flags & 0x00200)
   1859 		nflags |= FR_KEEPFRAG;
   1860 	if (flags & 0x00400)
   1861 		nflags |= FR_KEEPSTATE;
   1862 	if (flags & 0x00800)
   1863 		nflags |= FR_FASTROUTE;
   1864 	if (flags & 0x01000)
   1865 		nflags |= FR_RETRST;
   1866 	if (flags & 0x02000)
   1867 		nflags |= FR_RETICMP;
   1868 	if (flags & 0x03000)
   1869 		nflags |= FR_FAKEICMP;
   1870 	if (flags & 0x04000)
   1871 		nflags |= FR_OUTQUE;
   1872 	if (flags & 0x08000)
   1873 		nflags |= FR_INQUE;
   1874 	if (flags & 0x10000)
   1875 		nflags |= FR_LOGBODY;
   1876 	if (flags & 0x20000)
   1877 		nflags |= FR_LOGFIRST;
   1878 	if (flags & 0x40000)
   1879 		nflags |= FR_LOGORBLOCK;
   1880 	if (flags & 0x100000)
   1881 		nflags |= FR_FRSTRICT;
   1882 	if (flags & 0x200000)
   1883 		nflags |= FR_STSTRICT;
   1884 	if (flags & 0x400000)
   1885 		nflags |= FR_NEWISN;
   1886 	if (flags & 0x800000)
   1887 		nflags |= FR_NOICMPERR;
   1888 	if (flags & 0x1000000)
   1889 		nflags |= FR_STATESYNC;
   1890 	if (flags & 0x8000000)
   1891 		nflags |= FR_NOMATCH;
   1892 	if (flags & 0x40000000)
   1893 		nflags |= FR_COPIED;
   1894 	if (flags & 0x80000000)
   1895 		nflags |= FR_INACTIVE;
   1896 
   1897 	return nflags;
   1898 }
   1899 
   1900 static void
   1901 frentry_4_1_34_to_current(ipf_main_softc_t *softc, frentry_4_1_34_t *old,
   1902     void *current, int size)
   1903 {
   1904 	frentry_t *fr = (frentry_t *)current;
   1905 
   1906 	fr->fr_comment = -1;
   1907 	fr->fr_ref = old->fr_ref;
   1908 	fr->fr_statecnt = old->fr_statecnt;
   1909 	fr->fr_hits = old->fr_hits;
   1910 	fr->fr_bytes = old->fr_bytes;
   1911 	fr->fr_lastpkt.tv_sec = old->fr_lastpkt.tv_sec;
   1912 	fr->fr_lastpkt.tv_usec = old->fr_lastpkt.tv_usec;
   1913 	bcopy(&old->fr_dun, &fr->fr_dun, sizeof(old->fr_dun));
   1914 	fr->fr_func = old->fr_func;
   1915 	fr->fr_dsize = old->fr_dsize;
   1916 	fr->fr_pps = old->fr_pps;
   1917 	fr->fr_statemax = old->fr_statemax;
   1918 	fr->fr_flineno = old->fr_flineno;
   1919 	fr->fr_type = old->fr_type;
   1920 	fr->fr_flags = fr_frflags4to5(old->fr_flags);
   1921 	fr->fr_logtag = old->fr_logtag;
   1922 	fr->fr_collect = old->fr_collect;
   1923 	fr->fr_arg = old->fr_arg;
   1924 	fr->fr_loglevel = old->fr_loglevel;
   1925 	fr->fr_age[0] = old->fr_age[0];
   1926 	fr->fr_age[1] = old->fr_age[1];
   1927 	fr->fr_tifs[0].fd_ip6 = old->fr_tifs[0].ofd_ip6;
   1928 	fr->fr_tifs[0].fd_type = FRD_NORMAL;
   1929 	fr->fr_tifs[1].fd_ip6 = old->fr_tifs[1].ofd_ip6;
   1930 	fr->fr_tifs[1].fd_type = FRD_NORMAL;
   1931 	fr->fr_dif.fd_ip6 = old->fr_dif.ofd_ip6;
   1932 	fr->fr_dif.fd_type = FRD_NORMAL;
   1933 	if (old->fr_v == 4)
   1934 		fr->fr_family = AF_INET;
   1935 	if (old->fr_v == 6)
   1936 		fr->fr_family = AF_INET6;
   1937 	fr->fr_icode = old->fr_icode;
   1938 	fr->fr_cksum = old->fr_cksum;
   1939 	fr->fr_namelen = 0;
   1940 	fr->fr_ifnames[0] = -1;
   1941 	fr->fr_ifnames[1] = -1;
   1942 	fr->fr_ifnames[2] = -1;
   1943 	fr->fr_ifnames[3] = -1;
   1944 	fr->fr_dif.fd_name = -1;
   1945 	fr->fr_tifs[0].fd_name = -1;
   1946 	fr->fr_tifs[1].fd_name = -1;
   1947 	fr->fr_group = -1;
   1948 	fr->fr_grhead = -1;
   1949 	fr->fr_icmphead = -1;
   1950 	if (size == 0) {
   1951 		fr->fr_size = sizeof(*fr) + LIFNAMSIZ * 7 + FR_GROUPLEN * 2;
   1952 		fr->fr_size += sizeof(fripf_t) + 16;
   1953 		fr->fr_size += 9;	/* room for \0's */
   1954 	} else {
   1955 		char *names = fr->fr_names;
   1956 		int nlen = fr->fr_namelen;
   1957 
   1958 		fr->fr_size = size;
   1959 		if (old->fr_ifnames[0][0] != '\0') {
   1960 			fr->fr_ifnames[0] = nlen;
   1961 			nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[0],
   1962 					    LIFNAMSIZ);
   1963 		}
   1964 		if (old->fr_ifnames[1][0] != '\0') {
   1965 			fr->fr_ifnames[1] = nlen;
   1966 			nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[1],
   1967 					    LIFNAMSIZ);
   1968 		}
   1969 		if (old->fr_ifnames[2][0] != '\0') {
   1970 			fr->fr_ifnames[2] = nlen;
   1971 			nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[2],
   1972 					    LIFNAMSIZ);
   1973 		}
   1974 		if (old->fr_ifnames[3][0] != '\0') {
   1975 			fr->fr_ifnames[3] = nlen;
   1976 			nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[3],
   1977 					    LIFNAMSIZ);
   1978 		}
   1979 		if (old->fr_tifs[0].fd_ifname[0] != '\0') {
   1980 			fr->fr_tifs[0].fd_name = nlen;
   1981 			nlen = ipf_addfrstr(names, nlen,
   1982 					    old->fr_tifs[0].fd_ifname,
   1983 					    LIFNAMSIZ);
   1984 		}
   1985 		if (old->fr_tifs[1].fd_ifname[0] != '\0') {
   1986 			fr->fr_tifs[1].fd_name = nlen;
   1987 			nlen = ipf_addfrstr(names, nlen,
   1988 					    old->fr_tifs[1].fd_ifname,
   1989 					    LIFNAMSIZ);
   1990 		}
   1991 		if (old->fr_dif.fd_ifname[0] != '\0') {
   1992 			fr->fr_dif.fd_name = nlen;
   1993 			nlen = ipf_addfrstr(names, nlen,
   1994 					    old->fr_dif.fd_ifname, LIFNAMSIZ);
   1995 		}
   1996 		if (old->fr_group[0] != '\0') {
   1997 			fr->fr_group = nlen;
   1998 			nlen = ipf_addfrstr(names, nlen,
   1999 					    old->fr_group, LIFNAMSIZ);
   2000 		}
   2001 		if (old->fr_grhead[0] != '\0') {
   2002 			fr->fr_grhead = nlen;
   2003 			nlen = ipf_addfrstr(names, nlen,
   2004 					    old->fr_grhead, LIFNAMSIZ);
   2005 		}
   2006 		fr->fr_namelen = nlen;
   2007 
   2008 		if (old->fr_type == FR_T_IPF) {
   2009 			int offset = fr->fr_namelen;
   2010 			ipfobj_t obj;
   2011 			int error;
   2012 
   2013 			obj.ipfo_type = IPFOBJ_FRIPF;
   2014 			obj.ipfo_rev = 4010100;
   2015 			obj.ipfo_ptr = old->fr_data;
   2016 
   2017 			if ((offset & 7) != 0)
   2018 				offset += 8 - (offset & 7);
   2019 			error = ipf_in_compat(softc, &obj,
   2020 					      fr->fr_names + offset, 0);
   2021 			if (error == 0) {
   2022 				fr->fr_data = fr->fr_names + offset;
   2023 				fr->fr_dsize = sizeof(fripf_t);
   2024 			}
   2025 		}
   2026 	}
   2027 }
   2028 
   2029 static void
   2030 frentry_4_1_16_to_current(ipf_main_softc_t *softc, frentry_4_1_16_t *old,
   2031     void *current, int size)
   2032 {
   2033 	frentry_t *fr = (frentry_t *)current;
   2034 
   2035 	fr->fr_comment = -1;
   2036 	fr->fr_ref = old->fr_ref;
   2037 	fr->fr_statecnt = old->fr_statecnt;
   2038 	fr->fr_hits = old->fr_hits;
   2039 	fr->fr_bytes = old->fr_bytes;
   2040 	fr->fr_lastpkt.tv_sec = old->fr_lastpkt.tv_sec;
   2041 	fr->fr_lastpkt.tv_usec = old->fr_lastpkt.tv_usec;
   2042 	bcopy(&old->fr_dun, &fr->fr_dun, sizeof(old->fr_dun));
   2043 	fr->fr_func = old->fr_func;
   2044 	fr->fr_dsize = old->fr_dsize;
   2045 	fr->fr_pps = old->fr_pps;
   2046 	fr->fr_statemax = old->fr_statemax;
   2047 	fr->fr_flineno = old->fr_flineno;
   2048 	fr->fr_type = old->fr_type;
   2049 	fr->fr_flags = fr_frflags4to5(old->fr_flags);
   2050 	fr->fr_logtag = old->fr_logtag;
   2051 	fr->fr_collect = old->fr_collect;
   2052 	fr->fr_arg = old->fr_arg;
   2053 	fr->fr_loglevel = old->fr_loglevel;
   2054 	fr->fr_age[0] = old->fr_age[0];
   2055 	fr->fr_age[1] = old->fr_age[1];
   2056 	fr->fr_tifs[0].fd_ip6 = old->fr_tifs[0].ofd_ip6;
   2057 	fr->fr_tifs[0].fd_type = FRD_NORMAL;
   2058 	fr->fr_tifs[1].fd_ip6 = old->fr_tifs[1].ofd_ip6;
   2059 	fr->fr_tifs[1].fd_type = FRD_NORMAL;
   2060 	fr->fr_dif.fd_ip6 = old->fr_dif.ofd_ip6;
   2061 	fr->fr_dif.fd_type = FRD_NORMAL;
   2062 	if (old->fr_v == 4)
   2063 		fr->fr_family = AF_INET;
   2064 	if (old->fr_v == 6)
   2065 		fr->fr_family = AF_INET6;
   2066 	fr->fr_icode = old->fr_icode;
   2067 	fr->fr_cksum = old->fr_cksum;
   2068 	fr->fr_namelen = 0;
   2069 	fr->fr_ifnames[0] = -1;
   2070 	fr->fr_ifnames[1] = -1;
   2071 	fr->fr_ifnames[2] = -1;
   2072 	fr->fr_ifnames[3] = -1;
   2073 	fr->fr_dif.fd_name = -1;
   2074 	fr->fr_tifs[0].fd_name = -1;
   2075 	fr->fr_tifs[1].fd_name = -1;
   2076 	fr->fr_group = -1;
   2077 	fr->fr_grhead = -1;
   2078 	fr->fr_icmphead = -1;
   2079 	if (size == 0) {
   2080 		fr->fr_size = sizeof(*fr) + LIFNAMSIZ * 7 + FR_GROUPLEN * 2;
   2081 		fr->fr_size += 9;	/* room for \0's */
   2082 	} else {
   2083 		char *names = fr->fr_names;
   2084 		int nlen = fr->fr_namelen;
   2085 
   2086 		fr->fr_size = size;
   2087 		if (old->fr_ifnames[0][0] != '\0') {
   2088 			fr->fr_ifnames[0] = nlen;
   2089 			nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[0],
   2090 					    LIFNAMSIZ);
   2091 		}
   2092 		if (old->fr_ifnames[1][0] != '\0') {
   2093 			fr->fr_ifnames[1] = nlen;
   2094 			nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[1],
   2095 					    LIFNAMSIZ);
   2096 		}
   2097 		if (old->fr_ifnames[2][0] != '\0') {
   2098 			fr->fr_ifnames[2] = nlen;
   2099 			nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[2],
   2100 					    LIFNAMSIZ);
   2101 		}
   2102 		if (old->fr_ifnames[3][0] != '\0') {
   2103 			fr->fr_ifnames[3] = nlen;
   2104 			nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[3],
   2105 					    LIFNAMSIZ);
   2106 		}
   2107 		if (old->fr_tifs[0].fd_ifname[0] != '\0') {
   2108 			fr->fr_tifs[0].fd_name = nlen;
   2109 			nlen = ipf_addfrstr(names, nlen,
   2110 					    old->fr_tifs[0].fd_ifname,
   2111 					    LIFNAMSIZ);
   2112 		}
   2113 		if (old->fr_tifs[1].fd_ifname[0] != '\0') {
   2114 			fr->fr_tifs[1].fd_name = nlen;
   2115 			nlen = ipf_addfrstr(names, nlen,
   2116 					    old->fr_tifs[1].fd_ifname,
   2117 					    LIFNAMSIZ);
   2118 		}
   2119 		if (old->fr_dif.fd_ifname[0] != '\0') {
   2120 			fr->fr_dif.fd_name = nlen;
   2121 			nlen = ipf_addfrstr(names, nlen,
   2122 					    old->fr_dif.fd_ifname, LIFNAMSIZ);
   2123 		}
   2124 		if (old->fr_group[0] != '\0') {
   2125 			fr->fr_group = nlen;
   2126 			nlen = ipf_addfrstr(names, nlen,
   2127 					    old->fr_group, LIFNAMSIZ);
   2128 		}
   2129 		if (old->fr_grhead[0] != '\0') {
   2130 			fr->fr_grhead = nlen;
   2131 			nlen = ipf_addfrstr(names, nlen,
   2132 					    old->fr_grhead, LIFNAMSIZ);
   2133 		}
   2134 		fr->fr_namelen = nlen;
   2135 
   2136 		if (old->fr_type == FR_T_IPF) {
   2137 			int offset = fr->fr_namelen;
   2138 			ipfobj_t obj;
   2139 			int error;
   2140 
   2141 			obj.ipfo_type = IPFOBJ_FRIPF;
   2142 			obj.ipfo_rev = 4010100;
   2143 			obj.ipfo_ptr = old->fr_data;
   2144 
   2145 			if ((offset & 7) != 0)
   2146 				offset += 8 - (offset & 7);
   2147 			error = ipf_in_compat(softc, &obj,
   2148 					      fr->fr_names + offset, 0);
   2149 			if (error == 0) {
   2150 				fr->fr_data = fr->fr_names + offset;
   2151 				fr->fr_dsize = sizeof(fripf_t);
   2152 			}
   2153 		}
   2154 	}
   2155 }
   2156 
   2157 
   2158 static void
   2159 frentry_4_1_0_to_current(ipf_main_softc_t *softc, frentry_4_1_0_t *old,
   2160     void *current, int size)
   2161 {
   2162 	frentry_t *fr = (frentry_t *)current;
   2163 
   2164 	fr->fr_size = sizeof(*fr);
   2165 	fr->fr_comment = -1;
   2166 	fr->fr_ref = old->fr_ref;
   2167 	fr->fr_statecnt = old->fr_statecnt;
   2168 	fr->fr_hits = old->fr_hits;
   2169 	fr->fr_bytes = old->fr_bytes;
   2170 	fr->fr_lastpkt.tv_sec = old->fr_lastpkt.tv_sec;
   2171 	fr->fr_lastpkt.tv_usec = old->fr_lastpkt.tv_usec;
   2172 	bcopy(&old->fr_dun, &fr->fr_dun, sizeof(old->fr_dun));
   2173 	fr->fr_func = old->fr_func;
   2174 	fr->fr_dsize = old->fr_dsize;
   2175 	fr->fr_pps = old->fr_pps;
   2176 	fr->fr_statemax = old->fr_statemax;
   2177 	fr->fr_flineno = old->fr_flineno;
   2178 	fr->fr_type = old->fr_type;
   2179 	fr->fr_flags = fr_frflags4to5(old->fr_flags);
   2180 	fr->fr_logtag = old->fr_logtag;
   2181 	fr->fr_collect = old->fr_collect;
   2182 	fr->fr_arg = old->fr_arg;
   2183 	fr->fr_loglevel = old->fr_loglevel;
   2184 	fr->fr_age[0] = old->fr_age[0];
   2185 	fr->fr_age[1] = old->fr_age[1];
   2186 	fr->fr_tifs[0].fd_ip6 = old->fr_tifs[0].ofd_ip6;
   2187 	fr->fr_tifs[0].fd_type = FRD_NORMAL;
   2188 	fr->fr_tifs[1].fd_ip6 = old->fr_tifs[1].ofd_ip6;
   2189 	fr->fr_tifs[1].fd_type = FRD_NORMAL;
   2190 	fr->fr_dif.fd_ip6 = old->fr_dif.ofd_ip6;
   2191 	fr->fr_dif.fd_type = FRD_NORMAL;
   2192 	if (old->fr_v == 4)
   2193 		fr->fr_family = AF_INET;
   2194 	if (old->fr_v == 6)
   2195 		fr->fr_family = AF_INET6;
   2196 	fr->fr_icode = old->fr_icode;
   2197 	fr->fr_cksum = old->fr_cksum;
   2198 	fr->fr_namelen = 0;
   2199 	fr->fr_ifnames[0] = -1;
   2200 	fr->fr_ifnames[1] = -1;
   2201 	fr->fr_ifnames[2] = -1;
   2202 	fr->fr_ifnames[3] = -1;
   2203 	fr->fr_dif.fd_name = -1;
   2204 	fr->fr_tifs[0].fd_name = -1;
   2205 	fr->fr_tifs[1].fd_name = -1;
   2206 	fr->fr_group = -1;
   2207 	fr->fr_grhead = -1;
   2208 	fr->fr_icmphead = -1;
   2209 	if (size == 0) {
   2210 		fr->fr_size = sizeof(*fr) + LIFNAMSIZ * 7 + FR_GROUPLEN * 2;
   2211 		fr->fr_size += 9;	/* room for \0's */
   2212 	} else {
   2213 		char *names = fr->fr_names;
   2214 		int nlen = fr->fr_namelen;
   2215 
   2216 		fr->fr_size = size;
   2217 		if (old->fr_ifnames[0][0] != '\0') {
   2218 			fr->fr_ifnames[0] = nlen;
   2219 			nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[0],
   2220 					    LIFNAMSIZ);
   2221 		}
   2222 		if (old->fr_ifnames[1][0] != '\0') {
   2223 			fr->fr_ifnames[1] = nlen;
   2224 			nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[1],
   2225 					    LIFNAMSIZ);
   2226 		}
   2227 		if (old->fr_ifnames[2][0] != '\0') {
   2228 			fr->fr_ifnames[2] = nlen;
   2229 			nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[2],
   2230 					    LIFNAMSIZ);
   2231 		}
   2232 		if (old->fr_ifnames[3][0] != '\0') {
   2233 			fr->fr_ifnames[3] = nlen;
   2234 			nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[3],
   2235 					    LIFNAMSIZ);
   2236 		}
   2237 		if (old->fr_tifs[0].fd_ifname[0] != '\0') {
   2238 			fr->fr_tifs[0].fd_name = nlen;
   2239 			nlen = ipf_addfrstr(names, nlen,
   2240 					    old->fr_tifs[0].fd_ifname,
   2241 					    LIFNAMSIZ);
   2242 		}
   2243 		if (old->fr_tifs[1].fd_ifname[0] != '\0') {
   2244 			fr->fr_tifs[1].fd_name = nlen;
   2245 			nlen = ipf_addfrstr(names, nlen,
   2246 					    old->fr_tifs[1].fd_ifname,
   2247 					    LIFNAMSIZ);
   2248 		}
   2249 		if (old->fr_dif.fd_ifname[0] != '\0') {
   2250 			fr->fr_dif.fd_name = nlen;
   2251 			nlen = ipf_addfrstr(names, nlen,
   2252 					    old->fr_dif.fd_ifname, LIFNAMSIZ);
   2253 		}
   2254 		if (old->fr_group[0] != '\0') {
   2255 			fr->fr_group = nlen;
   2256 			nlen = ipf_addfrstr(names, nlen,
   2257 					    old->fr_group, LIFNAMSIZ);
   2258 		}
   2259 		if (old->fr_grhead[0] != '\0') {
   2260 			fr->fr_grhead = nlen;
   2261 			nlen = ipf_addfrstr(names, nlen,
   2262 					    old->fr_grhead, LIFNAMSIZ);
   2263 		}
   2264 		fr->fr_namelen = nlen;
   2265 
   2266 		if (old->fr_type == FR_T_IPF) {
   2267 			int offset = fr->fr_namelen;
   2268 			ipfobj_t obj;
   2269 			int error;
   2270 
   2271 			obj.ipfo_type = IPFOBJ_FRIPF;
   2272 			obj.ipfo_rev = 4010100;
   2273 			obj.ipfo_ptr = old->fr_data;
   2274 
   2275 			if ((offset & 7) != 0)
   2276 				offset += 8 - (offset & 7);
   2277 			error = ipf_in_compat(softc, &obj,
   2278 					      fr->fr_names + offset, 0);
   2279 			if (error == 0) {
   2280 				fr->fr_data = fr->fr_names + offset;
   2281 				fr->fr_dsize = sizeof(fripf_t);
   2282 			}
   2283 		}
   2284 	}
   2285 }
   2286 
   2287 
   2288 static void
   2289 friostat_4_1_33_to_current(friostat_4_1_33_t *old, void *current)
   2290 {
   2291 	friostat_t *fiop = (friostat_t *)current;
   2292 
   2293 	bcopy(&old->of_st[0], &fiop->f_st[0].fr_pass, sizeof(old->of_st[0]));
   2294 	bcopy(&old->of_st[1], &fiop->f_st[1].fr_pass, sizeof(old->of_st[1]));
   2295 
   2296 	fiop->f_ipf[0][0] = old->f_ipf[0][0];
   2297 	fiop->f_ipf[0][1] = old->f_ipf[0][1];
   2298 	fiop->f_ipf[1][0] = old->f_ipf[1][0];
   2299 	fiop->f_ipf[1][1] = old->f_ipf[1][1];
   2300 	fiop->f_acct[0][0] = old->f_acct[0][0];
   2301 	fiop->f_acct[0][1] = old->f_acct[0][1];
   2302 	fiop->f_acct[1][0] = old->f_acct[1][0];
   2303 	fiop->f_acct[1][1] = old->f_acct[1][1];
   2304 	fiop->f_auth = fiop->f_auth;
   2305 	bcopy(&old->f_groups, &fiop->f_groups, sizeof(old->f_groups));
   2306 	bcopy(&old->f_froute, &fiop->f_froute, sizeof(old->f_froute));
   2307 	fiop->f_ticks = old->f_ticks;
   2308 	bcopy(&old->f_locks, &fiop->f_locks, sizeof(old->f_locks));
   2309 	fiop->f_defpass = old->f_defpass;
   2310 	fiop->f_active = old->f_active;
   2311 	fiop->f_running = old->f_running;
   2312 	fiop->f_logging = old->f_logging;
   2313 	fiop->f_features = old->f_features;
   2314 	bcopy(old->f_version, fiop->f_version, sizeof(old->f_version));
   2315 }
   2316 
   2317 
   2318 static void
   2319 friostat_4_1_0_to_current(friostat_4_1_0_t *old, void *current)
   2320 {
   2321 	friostat_t *fiop = (friostat_t *)current;
   2322 
   2323 	bcopy(&old->of_st[0], &fiop->f_st[0].fr_pass, sizeof(old->of_st[0]));
   2324 	bcopy(&old->of_st[1], &fiop->f_st[1].fr_pass, sizeof(old->of_st[1]));
   2325 
   2326 	fiop->f_ipf[0][0] = old->f_ipf[0][0];
   2327 	fiop->f_ipf[0][1] = old->f_ipf[0][1];
   2328 	fiop->f_ipf[1][0] = old->f_ipf[1][0];
   2329 	fiop->f_ipf[1][1] = old->f_ipf[1][1];
   2330 	fiop->f_acct[0][0] = old->f_acct[0][0];
   2331 	fiop->f_acct[0][1] = old->f_acct[0][1];
   2332 	fiop->f_acct[1][0] = old->f_acct[1][0];
   2333 	fiop->f_acct[1][1] = old->f_acct[1][1];
   2334 	fiop->f_auth = fiop->f_auth;
   2335 	bcopy(&old->f_groups, &fiop->f_groups, sizeof(old->f_groups));
   2336 	bcopy(&old->f_froute, &fiop->f_froute, sizeof(old->f_froute));
   2337 	fiop->f_ticks = old->f_ticks;
   2338 	bcopy(&old->f_locks, &fiop->f_locks, sizeof(old->f_locks));
   2339 	fiop->f_defpass = old->f_defpass;
   2340 	fiop->f_active = old->f_active;
   2341 	fiop->f_running = old->f_running;
   2342 	fiop->f_logging = old->f_logging;
   2343 	fiop->f_features = old->f_features;
   2344 	bcopy(old->f_version, fiop->f_version, sizeof(old->f_version));
   2345 }
   2346 
   2347 
   2348 static void
   2349 ipnat_4_1_14_to_current(ipnat_4_1_14_t *old, void *current, int size)
   2350 {
   2351 	ipnat_t *np = (ipnat_t *)current;
   2352 
   2353 	np->in_space = old->in_space;
   2354 	np->in_hv[0] = old->in_hv;
   2355 	np->in_hv[1] = old->in_hv;
   2356 	np->in_flineno = old->in_flineno;
   2357 	if (old->in_redir == NAT_REDIRECT)
   2358 		np->in_dpnext = old->in_pnext;
   2359 	else
   2360 		np->in_spnext = old->in_pnext;
   2361 	np->in_v[0] = old->in_v;
   2362 	np->in_v[1] = old->in_v;
   2363 	np->in_flags = old->in_flags;
   2364 	np->in_mssclamp = old->in_mssclamp;
   2365 	np->in_age[0] = old->in_age[0];
   2366 	np->in_age[1] = old->in_age[1];
   2367 	np->in_redir = old->in_redir;
   2368 	np->in_pr[0] = old->in_p;
   2369 	np->in_pr[1] = old->in_p;
   2370 	if (np->in_redir == NAT_REDIRECT) {
   2371 		np->in_ndst.na_nextaddr = old->in_next6;
   2372 		np->in_ndst.na_addr[0] = old->in_in[0];
   2373 		np->in_ndst.na_addr[1] = old->in_in[1];
   2374 		np->in_ndst.na_atype = FRI_NORMAL;
   2375 		np->in_odst.na_addr[0] = old->in_out[0];
   2376 		np->in_odst.na_addr[1] = old->in_out[1];
   2377 		np->in_odst.na_atype = FRI_NORMAL;
   2378 		np->in_osrc.na_addr[0] = old->in_src[0];
   2379 		np->in_osrc.na_addr[1] = old->in_src[1];
   2380 		np->in_osrc.na_atype = FRI_NORMAL;
   2381 	} else {
   2382 		np->in_nsrc.na_nextaddr = old->in_next6;
   2383 		np->in_nsrc.na_addr[0] = old->in_out[0];
   2384 		np->in_nsrc.na_addr[1] = old->in_out[1];
   2385 		np->in_nsrc.na_atype = FRI_NORMAL;
   2386 		np->in_osrc.na_addr[0] = old->in_in[0];
   2387 		np->in_osrc.na_addr[1] = old->in_in[1];
   2388 		np->in_osrc.na_atype = FRI_NORMAL;
   2389 		np->in_odst.na_addr[0] = old->in_src[0];
   2390 		np->in_odst.na_addr[1] = old->in_src[1];
   2391 		np->in_odst.na_atype = FRI_NORMAL;
   2392 	}
   2393 	ipfv4tuctov5(&old->in_tuc, &np->in_tuc);
   2394 	if (np->in_redir == NAT_REDIRECT) {
   2395 		np->in_dpmin = old->in_port[0];
   2396 		np->in_dpmax = old->in_port[1];
   2397 	} else {
   2398 		np->in_spmin = old->in_port[0];
   2399 		np->in_spmax = old->in_port[1];
   2400 	}
   2401 	np->in_ppip = old->in_ppip;
   2402 	np->in_ippip = old->in_ippip;
   2403 	np->in_tag = old->in_tag;
   2404 
   2405 	np->in_namelen = 0;
   2406 	np->in_plabel = -1;
   2407 	np->in_ifnames[0] = -1;
   2408 	np->in_ifnames[1] = -1;
   2409 
   2410 	if (size == 0) {
   2411 		np->in_size = sizeof(*np);
   2412 		np->in_size += LIFNAMSIZ * 2 + APR_LABELLEN;
   2413 		np->in_size += 3;
   2414 	} else {
   2415 		int nlen = np->in_namelen;
   2416 		char *names = np->in_names;
   2417 
   2418 		if (old->in_ifnames[0][0] != '\0') {
   2419 			np->in_ifnames[0] = nlen;
   2420 			nlen = ipf_addfrstr(names, nlen, old->in_ifnames[0],
   2421 					    LIFNAMSIZ);
   2422 		}
   2423 		if (old->in_ifnames[1][0] != '\0') {
   2424 			np->in_ifnames[0] = nlen;
   2425 			nlen = ipf_addfrstr(names, nlen, old->in_ifnames[1],
   2426 					    LIFNAMSIZ);
   2427 		}
   2428 		if (old->in_plabel[0] != '\0') {
   2429 			np->in_plabel = nlen;
   2430 			nlen = ipf_addfrstr(names, nlen, old->in_plabel,
   2431 					    LIFNAMSIZ);
   2432 		}
   2433 		np->in_namelen = nlen;
   2434 		np->in_size = size;
   2435 	}
   2436 }
   2437 
   2438 
   2439 static void
   2440 ipnat_4_1_0_to_current(ipnat_4_1_0_t *old, void *current, int size)
   2441 {
   2442 	ipnat_t *np = (ipnat_t *)current;
   2443 
   2444 	np->in_space = old->in_space;
   2445 	np->in_hv[0] = old->in_hv;
   2446 	np->in_hv[1] = old->in_hv;
   2447 	np->in_flineno = old->in_flineno;
   2448 	if (old->in_redir == NAT_REDIRECT)
   2449 		np->in_dpnext = old->in_pnext;
   2450 	else
   2451 		np->in_spnext = old->in_pnext;
   2452 	np->in_v[0] = old->in_v;
   2453 	np->in_v[1] = old->in_v;
   2454 	np->in_flags = old->in_flags;
   2455 	np->in_mssclamp = old->in_mssclamp;
   2456 	np->in_age[0] = old->in_age[0];
   2457 	np->in_age[1] = old->in_age[1];
   2458 	np->in_redir = old->in_redir;
   2459 	np->in_pr[0] = old->in_p;
   2460 	np->in_pr[1] = old->in_p;
   2461 	if (np->in_redir == NAT_REDIRECT) {
   2462 		np->in_ndst.na_nextaddr = old->in_next6;
   2463 		bcopy(&old->in_in, &np->in_ndst.na_addr, sizeof(old->in_in));
   2464 		bcopy(&old->in_out, &np->in_odst.na_addr, sizeof(old->in_out));
   2465 		bcopy(&old->in_src, &np->in_osrc.na_addr, sizeof(old->in_src));
   2466 	} else {
   2467 		np->in_nsrc.na_nextaddr = old->in_next6;
   2468 		bcopy(&old->in_in, &np->in_osrc.na_addr, sizeof(old->in_in));
   2469 		bcopy(&old->in_out, &np->in_nsrc.na_addr, sizeof(old->in_out));
   2470 		bcopy(&old->in_src, &np->in_odst.na_addr, sizeof(old->in_src));
   2471 	}
   2472 	ipfv4tuctov5(&old->in_tuc, &np->in_tuc);
   2473 	if (np->in_redir == NAT_REDIRECT) {
   2474 		np->in_dpmin = old->in_port[0];
   2475 		np->in_dpmax = old->in_port[1];
   2476 	} else {
   2477 		np->in_spmin = old->in_port[0];
   2478 		np->in_spmax = old->in_port[1];
   2479 	}
   2480 	np->in_ppip = old->in_ppip;
   2481 	np->in_ippip = old->in_ippip;
   2482 	bcopy(&old->in_tag, &np->in_tag, sizeof(np->in_tag));
   2483 
   2484 	np->in_namelen = 0;
   2485 	np->in_plabel = -1;
   2486 	np->in_ifnames[0] = -1;
   2487 	np->in_ifnames[1] = -1;
   2488 
   2489 	if (size == 0) {
   2490 		np->in_size = sizeof(*np);
   2491 		np->in_size += LIFNAMSIZ * 2 + APR_LABELLEN;
   2492 		np->in_size += 3;
   2493 	} else {
   2494 		int nlen = np->in_namelen;
   2495 		char *names = np->in_names;
   2496 
   2497 		if (old->in_ifnames[0][0] != '\0') {
   2498 			np->in_ifnames[0] = nlen;
   2499 			nlen = ipf_addfrstr(names, nlen, old->in_ifnames[0],
   2500 					    LIFNAMSIZ);
   2501 		}
   2502 		if (old->in_ifnames[1][0] != '\0') {
   2503 			np->in_ifnames[0] = nlen;
   2504 			nlen = ipf_addfrstr(names, nlen, old->in_ifnames[1],
   2505 					    LIFNAMSIZ);
   2506 		}
   2507 		if (old->in_plabel[0] != '\0') {
   2508 			np->in_plabel = nlen;
   2509 			nlen = ipf_addfrstr(names, nlen, old->in_plabel,
   2510 					    LIFNAMSIZ);
   2511 		}
   2512 		np->in_namelen = nlen;
   2513 		np->in_size = size;
   2514 	}
   2515 }
   2516 
   2517 
   2518 static void
   2519 frauth_4_1_32_to_current(frauth_4_1_32_t *old, void *current)
   2520 {
   2521 	frauth_t *fra = (frauth_t *)current;
   2522 
   2523 	fra->fra_age = old->fra_age;
   2524 	fra->fra_len = old->fra_len;
   2525 	fra->fra_index = old->fra_index;
   2526 	fra->fra_pass = old->fra_pass;
   2527 	fr_info_4_1_32_to_current(&old->fra_info, &fra->fra_info);
   2528 	fra->fra_buf = old->fra_buf;
   2529 	fra->fra_flx = old->fra_flx;
   2530 #ifdef	MENTAT
   2531 	fra->fra_q = old->fra_q;
   2532 	fra->fra_m = old->fra_m;
   2533 #endif
   2534 }
   2535 
   2536 
   2537 static void
   2538 frauth_4_1_29_to_current(frauth_4_1_29_t *old, void *current)
   2539 {
   2540 	frauth_t *fra = (frauth_t *)current;
   2541 
   2542 	fra->fra_age = old->fra_age;
   2543 	fra->fra_len = old->fra_len;
   2544 	fra->fra_index = old->fra_index;
   2545 	fra->fra_pass = old->fra_pass;
   2546 	fr_info_4_1_24_to_current(&old->fra_info, &fra->fra_info);
   2547 	fra->fra_buf = old->fra_buf;
   2548 	fra->fra_flx = old->fra_flx;
   2549 #ifdef	MENTAT
   2550 	fra->fra_q = old->fra_q;
   2551 	fra->fra_m = old->fra_m;
   2552 #endif
   2553 }
   2554 
   2555 
   2556 static void
   2557 frauth_4_1_24_to_current(frauth_4_1_24_t *old, void *current)
   2558 {
   2559 	frauth_t *fra = (frauth_t *)current;
   2560 
   2561 	fra->fra_age = old->fra_age;
   2562 	fra->fra_len = old->fra_len;
   2563 	fra->fra_index = old->fra_index;
   2564 	fra->fra_pass = old->fra_pass;
   2565 	fr_info_4_1_24_to_current(&old->fra_info, &fra->fra_info);
   2566 	fra->fra_buf = old->fra_buf;
   2567 #ifdef	MENTAT
   2568 	fra->fra_q = old->fra_q;
   2569 	fra->fra_m = old->fra_m;
   2570 #endif
   2571 }
   2572 
   2573 
   2574 static void
   2575 frauth_4_1_23_to_current(frauth_4_1_23_t *old, void *current)
   2576 {
   2577 	frauth_t *fra = (frauth_t *)current;
   2578 
   2579 	fra->fra_age = old->fra_age;
   2580 	fra->fra_len = old->fra_len;
   2581 	fra->fra_index = old->fra_index;
   2582 	fra->fra_pass = old->fra_pass;
   2583 	fr_info_4_1_23_to_current(&old->fra_info, &fra->fra_info);
   2584 	fra->fra_buf = old->fra_buf;
   2585 #ifdef	MENTAT
   2586 	fra->fra_q = old->fra_q;
   2587 	fra->fra_m = old->fra_m;
   2588 #endif
   2589 }
   2590 
   2591 
   2592 static void
   2593 frauth_4_1_11_to_current(frauth_4_1_11_t *old, void *current)
   2594 {
   2595 	frauth_t *fra = (frauth_t *)current;
   2596 
   2597 	fra->fra_age = old->fra_age;
   2598 	fra->fra_len = old->fra_len;
   2599 	fra->fra_index = old->fra_index;
   2600 	fra->fra_pass = old->fra_pass;
   2601 	fr_info_4_1_11_to_current(&old->fra_info, &fra->fra_info);
   2602 	fra->fra_buf = old->fra_buf;
   2603 #ifdef	MENTAT
   2604 	fra->fra_q = old->fra_q;
   2605 	fra->fra_m = old->fra_m;
   2606 #endif
   2607 }
   2608 
   2609 
   2610 static void
   2611 fr_info_4_1_32_to_current(fr_info_4_1_32_t *old, void *current)
   2612 {
   2613 	fr_info_t *fin = (fr_info_t *)current;
   2614 
   2615 	fin->fin_ifp = old->fin_ifp;
   2616 	ipf_v4iptov5(&old->fin_fi, &fin->fin_fi);
   2617 	bcopy(&old->fin_dat, &fin->fin_dat, sizeof(old->fin_dat));
   2618 	fin->fin_out = old->fin_out;
   2619 	fin->fin_rev = old->fin_rev;
   2620 	fin->fin_hlen = old->fin_hlen;
   2621 	fin->fin_tcpf = old->ofin_tcpf;
   2622 	fin->fin_icode = old->fin_icode;
   2623 	fin->fin_rule = old->fin_rule;
   2624 	bcopy(old->fin_group, fin->fin_group, sizeof(old->fin_group));
   2625 	fin->fin_fr = old->fin_fr;
   2626 	fin->fin_dp = old->fin_dp;
   2627 	fin->fin_dlen = old->fin_dlen;
   2628 	fin->fin_plen = old->fin_plen;
   2629 	fin->fin_ipoff = old->fin_ipoff;
   2630 	fin->fin_id = old->fin_id;
   2631 	fin->fin_off = old->fin_off;
   2632 	fin->fin_depth = old->fin_depth;
   2633 	fin->fin_error = old->fin_error;
   2634 	fin->fin_cksum = old->fin_cksum;
   2635 	fin->fin_nattag = old->fin_nattag;
   2636 	fin->fin_ip = old->ofin_ip;
   2637 	fin->fin_mp = old->fin_mp;
   2638 	fin->fin_m = old->fin_m;
   2639 #ifdef  MENTAT
   2640 	fin->fin_qfm = old->fin_qfm;
   2641 	fin->fin_qpi = old->fin_qpi;
   2642 #endif
   2643 #ifdef  __sgi
   2644 	fin->fin_hbuf = old->fin_hbuf;
   2645 #endif
   2646 }
   2647 
   2648 
   2649 static void
   2650 fr_info_4_1_24_to_current(fr_info_4_1_24_t *old, void *current)
   2651 {
   2652 	fr_info_t *fin = (fr_info_t *)current;
   2653 
   2654 	fin->fin_ifp = old->fin_ifp;
   2655 	ipf_v4iptov5(&old->fin_fi, &fin->fin_fi);
   2656 	bcopy(&old->fin_dat, &fin->fin_dat, sizeof(old->fin_dat));
   2657 	fin->fin_out = old->fin_out;
   2658 	fin->fin_rev = old->fin_rev;
   2659 	fin->fin_hlen = old->fin_hlen;
   2660 	fin->fin_tcpf = old->ofin_tcpf;
   2661 	fin->fin_icode = old->fin_icode;
   2662 	fin->fin_rule = old->fin_rule;
   2663 	bcopy(old->fin_group, fin->fin_group, sizeof(old->fin_group));
   2664 	fin->fin_fr = old->fin_fr;
   2665 	fin->fin_dp = old->fin_dp;
   2666 	fin->fin_dlen = old->fin_dlen;
   2667 	fin->fin_plen = old->fin_plen;
   2668 	fin->fin_ipoff = old->fin_ipoff;
   2669 	fin->fin_id = old->fin_id;
   2670 	fin->fin_off = old->fin_off;
   2671 	fin->fin_depth = old->fin_depth;
   2672 	fin->fin_error = old->fin_error;
   2673 	fin->fin_cksum = old->fin_cksum;
   2674 	fin->fin_nattag = old->fin_nattag;
   2675 	fin->fin_ip = old->ofin_ip;
   2676 	fin->fin_mp = old->fin_mp;
   2677 	fin->fin_m = old->fin_m;
   2678 #ifdef  MENTAT
   2679 	fin->fin_qfm = old->fin_qfm;
   2680 	fin->fin_qpi = old->fin_qpi;
   2681 #endif
   2682 #ifdef  __sgi
   2683 	fin->fin_hbuf = old->fin_hbuf;
   2684 #endif
   2685 }
   2686 
   2687 
   2688 static void
   2689 fr_info_4_1_23_to_current(fr_info_4_1_23_t *old, void *current)
   2690 {
   2691 	fr_info_t *fin = (fr_info_t *)current;
   2692 
   2693 	fin->fin_ifp = old->fin_ifp;
   2694 	ipf_v4iptov5(&old->fin_fi, &fin->fin_fi);
   2695 	bcopy(&old->fin_dat, &fin->fin_dat, sizeof(old->fin_dat));
   2696 	fin->fin_out = old->fin_out;
   2697 	fin->fin_rev = old->fin_rev;
   2698 	fin->fin_hlen = old->fin_hlen;
   2699 	fin->fin_tcpf = old->ofin_tcpf;
   2700 	fin->fin_icode = old->fin_icode;
   2701 	fin->fin_rule = old->fin_rule;
   2702 	bcopy(old->fin_group, fin->fin_group, sizeof(old->fin_group));
   2703 	fin->fin_fr = old->fin_fr;
   2704 	fin->fin_dp = old->fin_dp;
   2705 	fin->fin_dlen = old->fin_dlen;
   2706 	fin->fin_plen = old->fin_plen;
   2707 	fin->fin_ipoff = old->fin_ipoff;
   2708 	fin->fin_id = old->fin_id;
   2709 	fin->fin_off = old->fin_off;
   2710 	fin->fin_depth = old->fin_depth;
   2711 	fin->fin_error = old->fin_error;
   2712 	fin->fin_nattag = old->fin_nattag;
   2713 	fin->fin_ip = old->ofin_ip;
   2714 	fin->fin_mp = old->fin_mp;
   2715 	fin->fin_m = old->fin_m;
   2716 #ifdef  MENTAT
   2717 	fin->fin_qfm = old->fin_qfm;
   2718 	fin->fin_qpi = old->fin_qpi;
   2719 #endif
   2720 #ifdef  __sgi
   2721 	fin->fin_hbuf = fin->fin_hbuf;
   2722 #endif
   2723 }
   2724 
   2725 
   2726 static void
   2727 fr_info_4_1_11_to_current(fr_info_4_1_11_t *old, void *current)
   2728 {
   2729 	fr_info_t *fin = (fr_info_t *)current;
   2730 
   2731 	fin->fin_ifp = old->fin_ifp;
   2732 	ipf_v4iptov5(&old->fin_fi, &fin->fin_fi);
   2733 	bcopy(&old->fin_dat, &fin->fin_dat, sizeof(old->fin_dat));
   2734 	fin->fin_out = old->fin_out;
   2735 	fin->fin_rev = old->fin_rev;
   2736 	fin->fin_hlen = old->fin_hlen;
   2737 	fin->fin_tcpf = old->ofin_tcpf;
   2738 	fin->fin_icode = old->fin_icode;
   2739 	fin->fin_rule = old->fin_rule;
   2740 	bcopy(old->fin_group, fin->fin_group, sizeof(old->fin_group));
   2741 	fin->fin_fr = old->fin_fr;
   2742 	fin->fin_dp = old->fin_dp;
   2743 	fin->fin_dlen = old->fin_dlen;
   2744 	fin->fin_plen = old->fin_plen;
   2745 	fin->fin_ipoff = old->fin_ipoff;
   2746 	fin->fin_id = old->fin_id;
   2747 	fin->fin_off = old->fin_off;
   2748 	fin->fin_depth = old->fin_depth;
   2749 	fin->fin_error = old->fin_error;
   2750 	fin->fin_nattag = old->fin_nattag;
   2751 	fin->fin_ip = old->ofin_ip;
   2752 	fin->fin_mp = old->fin_mp;
   2753 	fin->fin_m = old->fin_m;
   2754 #ifdef  MENTAT
   2755 	fin->fin_qfm = old->fin_qfm;
   2756 	fin->fin_qpi = old->fin_qpi;
   2757 #endif
   2758 #ifdef  __sgi
   2759 	fin->fin_hbuf = fin->fin_hbuf;
   2760 #endif
   2761 }
   2762 
   2763 
   2764 static void
   2765 nat_4_1_3_to_current(nat_4_1_3_t *old, nat_t *current)
   2766 {
   2767 	bzero((void *)current, sizeof(*current));
   2768 	bcopy((void *)old, (void *)current, sizeof(*old));
   2769 }
   2770 
   2771 
   2772 static void
   2773 nat_4_1_14_to_current(nat_4_1_14_t *old, nat_t *current)
   2774 {
   2775 	bzero((void *)current, sizeof(*current));
   2776 	bcopy((void *)old, (void *)current, sizeof(*old));
   2777 }
   2778 
   2779 
   2780 static void
   2781 nat_save_4_1_16_to_current(ipf_main_softc_t *softc, nat_save_4_1_16_t *old,
   2782     void *current)
   2783 {
   2784 	nat_save_t *nats = (nat_save_t *)current;
   2785 
   2786 	nats->ipn_next = old->ipn_next;
   2787 	nat_4_1_14_to_current(&old->ipn_nat, &nats->ipn_nat);
   2788 	bcopy(&old->ipn_ipnat, &nats->ipn_ipnat, sizeof(old->ipn_ipnat));
   2789 	frentry_4_1_16_to_current(softc, &old->ipn_fr, &nats->ipn_fr, 0);
   2790 	nats->ipn_dsize = old->ipn_dsize;
   2791 	bcopy(old->ipn_data, nats->ipn_data, sizeof(nats->ipn_data));
   2792 }
   2793 
   2794 
   2795 static void
   2796 nat_save_4_1_14_to_current(ipf_main_softc_t *softc, nat_save_4_1_14_t *old,
   2797     void *current)
   2798 {
   2799 	nat_save_t *nats = (nat_save_t *)current;
   2800 
   2801 	nats->ipn_next = old->ipn_next;
   2802 	nat_4_1_14_to_current(&old->ipn_nat, &nats->ipn_nat);
   2803 	bcopy(&old->ipn_ipnat, &nats->ipn_ipnat, sizeof(old->ipn_ipnat));
   2804 	frentry_4_1_0_to_current(softc, &old->ipn_fr, &nats->ipn_fr, 0);
   2805 	nats->ipn_dsize = old->ipn_dsize;
   2806 	bcopy(old->ipn_data, nats->ipn_data, sizeof(nats->ipn_data));
   2807 }
   2808 
   2809 
   2810 static void
   2811 nat_save_4_1_3_to_current(ipf_main_softc_t *softc, nat_save_4_1_3_t *old,
   2812     void *current)
   2813 {
   2814 	nat_save_t *nats = (nat_save_t *)current;
   2815 
   2816 	nats->ipn_next = old->ipn_next;
   2817 	nat_4_1_3_to_current(&old->ipn_nat, &nats->ipn_nat);
   2818 	ipnat_4_1_0_to_current(&old->ipn_ipnat, &nats->ipn_ipnat, 0);
   2819 	frentry_4_1_0_to_current(softc, &old->ipn_fr, &nats->ipn_fr, 0);
   2820 	nats->ipn_dsize = old->ipn_dsize;
   2821 	bcopy(old->ipn_data, nats->ipn_data, sizeof(nats->ipn_data));
   2822 }
   2823 
   2824 
   2825 static void
   2826 natstat_current_to_4_1_32(void *current, natstat_4_1_32_t *old)
   2827 {
   2828 	natstat_t *ns = (natstat_t *)current;
   2829 
   2830 	old->ns_mapped[0] = ns->ns_side[0].ns_translated;
   2831 	old->ns_mapped[1] = ns->ns_side[1].ns_translated;
   2832 	old->ns_rules = ns->ns_side[0].ns_inuse + ns->ns_side[1].ns_inuse;
   2833 	old->ns_added = ns->ns_side[0].ns_added + ns->ns_side[1].ns_added;
   2834 	old->ns_expire = ns->ns_expire;
   2835 	old->ns_inuse = ns->ns_side[0].ns_inuse + ns->ns_side[1].ns_inuse;
   2836 	old->ns_logged = ns->ns_log_ok;
   2837 	old->ns_logfail = ns->ns_log_fail;
   2838 	old->ns_memfail = ns->ns_side[0].ns_memfail + ns->ns_side[1].ns_memfail;
   2839 	old->ns_badnat = ns->ns_side[0].ns_badnat + ns->ns_side[1].ns_badnat;
   2840 	old->ns_addtrpnt = ns->ns_addtrpnt;
   2841 	old->ns_table[0] = ns->ns_side[0].ns_table;
   2842 	old->ns_table[1] = ns->ns_side[1].ns_table;
   2843 	old->ns_maptable = NULL;
   2844 	old->ns_list = ns->ns_list;
   2845 	old->ns_apslist = NULL;
   2846 	old->ns_wilds = ns->ns_wilds;
   2847 	old->ns_nattab_sz = ns->ns_nattab_sz;
   2848 	old->ns_nattab_max = ns->ns_nattab_max;
   2849 	old->ns_rultab_sz = ns->ns_rultab_sz;
   2850 	old->ns_rdrtab_sz = ns->ns_rdrtab_sz;
   2851 	old->ns_trpntab_sz = ns->ns_trpntab_sz;
   2852 	old->ns_hostmap_sz = 0;
   2853 	old->ns_instances = ns->ns_instances;
   2854 	old->ns_maplist = ns->ns_maplist;
   2855 	old->ns_bucketlen[0] = (u_long *)ns->ns_side[0].ns_bucketlen;
   2856 	old->ns_bucketlen[1] = (u_long *)ns->ns_side[1].ns_bucketlen;
   2857 	old->ns_ticks = ns->ns_ticks;
   2858 	old->ns_orphans = ns->ns_orphans;
   2859 	old->ns_uncreate[0][0] = ns->ns_side[0].ns_uncreate[0];
   2860 	old->ns_uncreate[0][1] = ns->ns_side[0].ns_uncreate[1];
   2861 	old->ns_uncreate[1][0] = ns->ns_side[1].ns_uncreate[0];
   2862 	old->ns_uncreate[1][1] = ns->ns_side[1].ns_uncreate[1];
   2863 }
   2864 
   2865 
   2866 static void
   2867 natstat_current_to_4_1_27(void *current, natstat_4_1_27_t *old)
   2868 {
   2869 	natstat_t *ns = (natstat_t *)current;
   2870 
   2871 	old->ns_mapped[0] = ns->ns_side[0].ns_translated;
   2872 	old->ns_mapped[1] = ns->ns_side[1].ns_translated;
   2873 	old->ns_rules = ns->ns_side[0].ns_inuse + ns->ns_side[1].ns_inuse;
   2874 	old->ns_added = ns->ns_side[0].ns_added + ns->ns_side[1].ns_added;
   2875 	old->ns_expire = ns->ns_expire;
   2876 	old->ns_inuse = ns->ns_side[0].ns_inuse + ns->ns_side[1].ns_inuse;
   2877 	old->ns_logged = ns->ns_log_ok;
   2878 	old->ns_logfail = ns->ns_log_fail;
   2879 	old->ns_memfail = ns->ns_side[0].ns_memfail + ns->ns_side[1].ns_memfail;
   2880 	old->ns_badnat = ns->ns_side[0].ns_badnat + ns->ns_side[1].ns_badnat;
   2881 	old->ns_addtrpnt = ns->ns_addtrpnt;
   2882 	old->ns_table[0] = ns->ns_side[0].ns_table;
   2883 	old->ns_table[1] = ns->ns_side[1].ns_table;
   2884 	old->ns_maptable = NULL;
   2885 	old->ns_list = ns->ns_list;
   2886 	old->ns_apslist = NULL;
   2887 	old->ns_wilds = ns->ns_wilds;
   2888 	old->ns_nattab_sz = ns->ns_nattab_sz;
   2889 	old->ns_nattab_max = ns->ns_nattab_max;
   2890 	old->ns_rultab_sz = ns->ns_rultab_sz;
   2891 	old->ns_rdrtab_sz = ns->ns_rdrtab_sz;
   2892 	old->ns_trpntab_sz = ns->ns_trpntab_sz;
   2893 	old->ns_hostmap_sz = 0;
   2894 	old->ns_instances = ns->ns_instances;
   2895 	old->ns_maplist = ns->ns_maplist;
   2896 	old->ns_bucketlen[0] = (u_long *)ns->ns_side[0].ns_bucketlen;
   2897 	old->ns_bucketlen[1] = (u_long *)ns->ns_side[1].ns_bucketlen;
   2898 	old->ns_ticks = ns->ns_ticks;
   2899 	old->ns_orphans = ns->ns_orphans;
   2900 }
   2901 
   2902 
   2903 static void
   2904 natstat_current_to_4_1_16(void *current, natstat_4_1_16_t *old)
   2905 {
   2906 	natstat_t *ns = (natstat_t *)current;
   2907 
   2908 	old->ns_mapped[0] = ns->ns_side[0].ns_translated;
   2909 	old->ns_mapped[1] = ns->ns_side[1].ns_translated;
   2910 	old->ns_rules = ns->ns_side[0].ns_inuse + ns->ns_side[1].ns_inuse;
   2911 	old->ns_added = ns->ns_side[0].ns_added + ns->ns_side[1].ns_added;
   2912 	old->ns_expire = ns->ns_expire;
   2913 	old->ns_inuse = ns->ns_side[0].ns_inuse + ns->ns_side[1].ns_inuse;
   2914 	old->ns_logged = ns->ns_log_ok;
   2915 	old->ns_logfail = ns->ns_log_fail;
   2916 	old->ns_memfail = ns->ns_side[0].ns_memfail + ns->ns_side[1].ns_memfail;
   2917 	old->ns_badnat = ns->ns_side[0].ns_badnat + ns->ns_side[1].ns_badnat;
   2918 	old->ns_addtrpnt = ns->ns_addtrpnt;
   2919 	old->ns_table[0] = ns->ns_side[0].ns_table;
   2920 	old->ns_table[1] = ns->ns_side[1].ns_table;
   2921 	old->ns_maptable = NULL;
   2922 	old->ns_list = ns->ns_list;
   2923 	old->ns_apslist = NULL;
   2924 	old->ns_wilds = ns->ns_wilds;
   2925 	old->ns_nattab_sz = ns->ns_nattab_sz;
   2926 	old->ns_nattab_max = ns->ns_nattab_max;
   2927 	old->ns_rultab_sz = ns->ns_rultab_sz;
   2928 	old->ns_rdrtab_sz = ns->ns_rdrtab_sz;
   2929 	old->ns_trpntab_sz = ns->ns_trpntab_sz;
   2930 	old->ns_hostmap_sz = 0;
   2931 	old->ns_instances = ns->ns_instances;
   2932 	old->ns_maplist = ns->ns_maplist;
   2933 	old->ns_bucketlen[0] = (u_long *)ns->ns_side[0].ns_bucketlen;
   2934 	old->ns_bucketlen[1] = (u_long *)ns->ns_side[1].ns_bucketlen;
   2935 	old->ns_ticks = ns->ns_ticks;
   2936 }
   2937 
   2938 
   2939 static void
   2940 natstat_current_to_4_1_0(void *current, natstat_4_1_0_t *old)
   2941 {
   2942 	natstat_t *ns = (natstat_t *)current;
   2943 
   2944 	old->ns_mapped[0] = ns->ns_side[0].ns_translated;
   2945 	old->ns_mapped[1] = ns->ns_side[1].ns_translated;
   2946 	old->ns_rules = ns->ns_side[0].ns_inuse + ns->ns_side[1].ns_inuse;
   2947 	old->ns_added = ns->ns_side[0].ns_added + ns->ns_side[1].ns_added;
   2948 	old->ns_expire = ns->ns_expire;
   2949 	old->ns_inuse = ns->ns_side[0].ns_inuse + ns->ns_side[1].ns_inuse;
   2950 	old->ns_logged = ns->ns_log_ok;
   2951 	old->ns_logfail = ns->ns_log_fail;
   2952 	old->ns_memfail = ns->ns_side[0].ns_memfail + ns->ns_side[1].ns_memfail;
   2953 	old->ns_badnat = ns->ns_side[0].ns_badnat + ns->ns_side[1].ns_badnat;
   2954 	old->ns_addtrpnt = ns->ns_addtrpnt;
   2955 	old->ns_table[0] = ns->ns_side[0].ns_table;
   2956 	old->ns_table[1] = ns->ns_side[1].ns_table;
   2957 	old->ns_maptable = NULL;
   2958 	old->ns_list = ns->ns_list;
   2959 	old->ns_apslist = NULL;
   2960 	old->ns_wilds = ns->ns_wilds;
   2961 	old->ns_nattab_sz = ns->ns_nattab_sz;
   2962 	old->ns_nattab_max = ns->ns_nattab_max;
   2963 	old->ns_rultab_sz = ns->ns_rultab_sz;
   2964 	old->ns_rdrtab_sz = ns->ns_rdrtab_sz;
   2965 	old->ns_trpntab_sz = ns->ns_trpntab_sz;
   2966 	old->ns_hostmap_sz = 0;
   2967 	old->ns_instances = ns->ns_instances;
   2968 	old->ns_maplist = ns->ns_maplist;
   2969 	old->ns_bucketlen[0] = (u_long *)ns->ns_side[0].ns_bucketlen;
   2970 	old->ns_bucketlen[1] = (u_long *)ns->ns_side[1].ns_bucketlen;
   2971 }
   2972 
   2973 
   2974 static void
   2975 ipstate_save_current_to_4_1_16(void *current, ipstate_save_4_1_16_t *old)
   2976 {
   2977 	ipstate_save_t *ips = (ipstate_save_t *)current;
   2978 
   2979 	old->ips_next = ips->ips_next;
   2980 	ipstate_current_to_4_1_0(&ips->ips_is, &old->ips_is);
   2981 	frentry_current_to_4_1_16(&ips->ips_fr, &old->ips_fr);
   2982 }
   2983 
   2984 
   2985 static void
   2986 ipstate_save_current_to_4_1_0(void *current, ipstate_save_4_1_0_t *old)
   2987 {
   2988 	ipstate_save_t *ips = (ipstate_save_t *)current;
   2989 
   2990 	old->ips_next = ips->ips_next;
   2991 	ipstate_current_to_4_1_0(&ips->ips_is, &old->ips_is);
   2992 	frentry_current_to_4_1_0(&ips->ips_fr, &old->ips_fr);
   2993 }
   2994 
   2995 
   2996 int
   2997 ipf_out_compat(ipf_main_softc_t *softc, ipfobj_t *obj, void *ptr)
   2998 {
   2999 	frentry_t *fr;
   3000 	int error;
   3001 
   3002 	IPFERROR(140042);
   3003 	error = EINVAL;
   3004 
   3005 	switch (obj->ipfo_type)
   3006 	{
   3007 	default :
   3008 		break;
   3009 
   3010 	case IPFOBJ_FRENTRY :
   3011 		if (obj->ipfo_rev >= 4013400) {
   3012 			frentry_4_1_34_t *old;
   3013 
   3014 			KMALLOC(old, frentry_4_1_34_t *);
   3015 			if (old == NULL) {
   3016 				IPFERROR(140043);
   3017 				error = ENOMEM;
   3018 				break;
   3019 			}
   3020 			frentry_current_to_4_1_34(ptr, old);
   3021 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3022 			if (error == 0 && old->fr_dsize > 0) {
   3023 				char *dst = obj->ipfo_ptr;
   3024 
   3025 				fr = ptr;
   3026 				dst += sizeof(*old);
   3027 				error = COPYOUT(fr->fr_data, dst,
   3028 						old->fr_dsize);
   3029 				if (error != 0) {
   3030 					IPFERROR(140044);
   3031 				}
   3032 			}
   3033 			KFREE(old);
   3034 			obj->ipfo_size = sizeof(*old);
   3035 		} else if (obj->ipfo_rev >= 4011600) {
   3036 			frentry_4_1_16_t *old;
   3037 
   3038 			KMALLOC(old, frentry_4_1_16_t *);
   3039 			if (old == NULL) {
   3040 				IPFERROR(140045);
   3041 				error = ENOMEM;
   3042 				break;
   3043 			}
   3044 			frentry_current_to_4_1_16(ptr, old);
   3045 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3046 			if (error != 0) {
   3047 				IPFERROR(140046);
   3048 			}
   3049 			KFREE(old);
   3050 			obj->ipfo_size = sizeof(*old);
   3051 		} else {
   3052 			frentry_4_1_0_t *old;
   3053 
   3054 			KMALLOC(old, frentry_4_1_0_t *);
   3055 			if (old == NULL) {
   3056 				IPFERROR(140047);
   3057 				error = ENOMEM;
   3058 				break;
   3059 			}
   3060 			frentry_current_to_4_1_0(ptr, old);
   3061 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3062 			if (error != 0) {
   3063 				IPFERROR(140048);
   3064 			}
   3065 			KFREE(old);
   3066 			obj->ipfo_size = sizeof(*old);
   3067 		}
   3068 		break;
   3069 
   3070 	case IPFOBJ_IPFSTAT :
   3071 		if (obj->ipfo_rev >= 4013300) {
   3072 			friostat_4_1_33_t *old;
   3073 
   3074 			KMALLOC(old, friostat_4_1_33_t *);
   3075 			if (old == NULL) {
   3076 				IPFERROR(140049);
   3077 				error = ENOMEM;
   3078 				break;
   3079 			}
   3080 			friostat_current_to_4_1_33(ptr, old, obj->ipfo_rev);
   3081 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3082 			if (error != 0) {
   3083 				IPFERROR(140050);
   3084 			}
   3085 			KFREE(old);
   3086 		} else {
   3087 			friostat_4_1_0_t *old;
   3088 
   3089 			KMALLOC(old, friostat_4_1_0_t *);
   3090 			if (old == NULL) {
   3091 				IPFERROR(140051);
   3092 				error = ENOMEM;
   3093 				break;
   3094 			}
   3095 			friostat_current_to_4_1_0(ptr, old, obj->ipfo_rev);
   3096 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3097 			if (error != 0) {
   3098 				IPFERROR(140052);
   3099 			}
   3100 			KFREE(old);
   3101 		}
   3102 		break;
   3103 
   3104 	case IPFOBJ_IPFINFO :	/* unused */
   3105 		break;
   3106 
   3107 	case IPFOBJ_IPNAT :
   3108 		if (obj->ipfo_rev >= 4011400) {
   3109 			ipnat_4_1_14_t *old;
   3110 
   3111 			KMALLOC(old, ipnat_4_1_14_t *);
   3112 			if (old == NULL) {
   3113 				IPFERROR(140053);
   3114 				error = ENOMEM;
   3115 				break;
   3116 			}
   3117 			ipnat_current_to_4_1_14(ptr, old);
   3118 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3119 			if (error != 0) {
   3120 				IPFERROR(140054);
   3121 			}
   3122 			KFREE(old);
   3123 		} else {
   3124 			ipnat_4_1_0_t *old;
   3125 
   3126 			KMALLOC(old, ipnat_4_1_0_t *);
   3127 			if (old == NULL) {
   3128 				IPFERROR(140055);
   3129 				error = ENOMEM;
   3130 				break;
   3131 			}
   3132 			ipnat_current_to_4_1_0(ptr, old);
   3133 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3134 			if (error != 0) {
   3135 				IPFERROR(140056);
   3136 			}
   3137 			KFREE(old);
   3138 		}
   3139 		break;
   3140 
   3141 	case IPFOBJ_NATSTAT :
   3142 		if (obj->ipfo_rev >= 4013200) {
   3143 			natstat_4_1_32_t *old;
   3144 
   3145 			KMALLOC(old, natstat_4_1_32_t *);
   3146 			if (old == NULL) {
   3147 				IPFERROR(140057);
   3148 				error = ENOMEM;
   3149 				break;
   3150 			}
   3151 			natstat_current_to_4_1_32(ptr, old);
   3152 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3153 			if (error != 0) {
   3154 				IPFERROR(140058);
   3155 			}
   3156 			KFREE(old);
   3157 		} else if (obj->ipfo_rev >= 4012700) {
   3158 			natstat_4_1_27_t *old;
   3159 
   3160 			KMALLOC(old, natstat_4_1_27_t *);
   3161 			if (old == NULL) {
   3162 				IPFERROR(140059);
   3163 				error = ENOMEM;
   3164 				break;
   3165 			}
   3166 			natstat_current_to_4_1_27(ptr, old);
   3167 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3168 			if (error != 0) {
   3169 				IPFERROR(140060);
   3170 			}
   3171 			KFREE(old);
   3172 		} else if (obj->ipfo_rev >= 4011600) {
   3173 			natstat_4_1_16_t *old;
   3174 
   3175 			KMALLOC(old, natstat_4_1_16_t *);
   3176 			if (old == NULL) {
   3177 				IPFERROR(140061);
   3178 				error = ENOMEM;
   3179 				break;
   3180 			}
   3181 			natstat_current_to_4_1_16(ptr, old);
   3182 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3183 			if (error != 0) {
   3184 				IPFERROR(140062);
   3185 			}
   3186 			KFREE(old);
   3187 		} else {
   3188 			natstat_4_1_0_t *old;
   3189 
   3190 			KMALLOC(old, natstat_4_1_0_t *);
   3191 			if (old == NULL) {
   3192 				IPFERROR(140063);
   3193 				error = ENOMEM;
   3194 				break;
   3195 			}
   3196 			natstat_current_to_4_1_0(ptr, old);
   3197 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3198 			if (error != 0) {
   3199 				IPFERROR(140064);
   3200 			}
   3201 			KFREE(old);
   3202 		}
   3203 		break;
   3204 
   3205 	case IPFOBJ_STATESAVE :
   3206 		if (obj->ipfo_rev >= 4011600) {
   3207 			ipstate_save_4_1_16_t *old;
   3208 
   3209 			KMALLOC(old, ipstate_save_4_1_16_t *);
   3210 			if (old == NULL) {
   3211 				IPFERROR(140065);
   3212 				error = ENOMEM;
   3213 				break;
   3214 			}
   3215 			ipstate_save_current_to_4_1_16(ptr, old);
   3216 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3217 			if (error != 0) {
   3218 				IPFERROR(140066);
   3219 			}
   3220 			KFREE(old);
   3221 		} else {
   3222 			ipstate_save_4_1_0_t *old;
   3223 
   3224 			KMALLOC(old, ipstate_save_4_1_0_t *);
   3225 			if (old == NULL) {
   3226 				IPFERROR(140067);
   3227 				error = ENOMEM;
   3228 				break;
   3229 			}
   3230 			ipstate_save_current_to_4_1_0(ptr, old);
   3231 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3232 			if (error != 0) {
   3233 				IPFERROR(140068);
   3234 			}
   3235 			KFREE(old);
   3236 		}
   3237 		break;
   3238 
   3239 	case IPFOBJ_NATSAVE :
   3240 		if (obj->ipfo_rev >= 4011600) {
   3241 			nat_save_4_1_16_t *old16;
   3242 
   3243 			KMALLOC(old16, nat_save_4_1_16_t *);
   3244 			if (old16 == NULL) {
   3245 				IPFERROR(140069);
   3246 				error = ENOMEM;
   3247 				break;
   3248 			}
   3249 			nat_save_current_to_4_1_16(ptr, old16);
   3250 			error = COPYOUT(&old16, obj->ipfo_ptr, sizeof(*old16));
   3251 			if (error != 0) {
   3252 				IPFERROR(140070);
   3253 			}
   3254 			KFREE(old16);
   3255 		} else if (obj->ipfo_rev >= 4011400) {
   3256 			nat_save_4_1_14_t *old14;
   3257 
   3258 			KMALLOC(old14, nat_save_4_1_14_t *);
   3259 			if (old14 == NULL) {
   3260 				IPFERROR(140071);
   3261 				error = ENOMEM;
   3262 				break;
   3263 			}
   3264 			nat_save_current_to_4_1_14(ptr, old14);
   3265 			error = COPYOUT(&old14, obj->ipfo_ptr, sizeof(*old14));
   3266 			if (error != 0) {
   3267 				IPFERROR(140072);
   3268 			}
   3269 			KFREE(old14);
   3270 		} else if (obj->ipfo_rev >= 4010300) {
   3271 			nat_save_4_1_3_t *old3;
   3272 
   3273 			KMALLOC(old3, nat_save_4_1_3_t *);
   3274 			if (old3 == NULL) {
   3275 				IPFERROR(140073);
   3276 				error = ENOMEM;
   3277 				break;
   3278 			}
   3279 			nat_save_current_to_4_1_3(ptr, old3);
   3280 			error = COPYOUT(&old3, obj->ipfo_ptr, sizeof(*old3));
   3281 			if (error != 0) {
   3282 				IPFERROR(140074);
   3283 			}
   3284 			KFREE(old3);
   3285 		}
   3286 		break;
   3287 
   3288 	case IPFOBJ_IPSTATE :
   3289 		if (obj->ipfo_rev >= 4011600) {
   3290 			ipstate_4_1_16_t *old;
   3291 
   3292 			KMALLOC(old, ipstate_4_1_16_t *);
   3293 			if (old == NULL) {
   3294 				IPFERROR(140075);
   3295 				error = ENOMEM;
   3296 				break;
   3297 			}
   3298 			ipstate_current_to_4_1_16(ptr, old);
   3299 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3300 			if (error != 0) {
   3301 				IPFERROR(140076);
   3302 			}
   3303 			KFREE(old);
   3304 		} else {
   3305 			ipstate_4_1_0_t *old;
   3306 
   3307 			KMALLOC(old, ipstate_4_1_0_t *);
   3308 			if (old == NULL) {
   3309 				IPFERROR(140077);
   3310 				error = ENOMEM;
   3311 				break;
   3312 			}
   3313 			ipstate_current_to_4_1_0(ptr, old);
   3314 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3315 			if (error != 0) {
   3316 				IPFERROR(140078);
   3317 			}
   3318 			KFREE(old);
   3319 		}
   3320 		break;
   3321 
   3322 	case IPFOBJ_STATESTAT :
   3323 		if (obj->ipfo_rev >= 4012100) {
   3324 			ips_stat_4_1_21_t *old;
   3325 
   3326 			KMALLOC(old, ips_stat_4_1_21_t *);
   3327 			if (old == NULL) {
   3328 				IPFERROR(140079);
   3329 				error = ENOMEM;
   3330 				break;
   3331 			}
   3332 			ips_stat_current_to_4_1_21(ptr, old);
   3333 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3334 			if (error != 0) {
   3335 				IPFERROR(140080);
   3336 			}
   3337 			KFREE(old);
   3338 		} else {
   3339 			ips_stat_4_1_0_t *old;
   3340 
   3341 			KMALLOC(old, ips_stat_4_1_0_t *);
   3342 			if (old == NULL) {
   3343 				IPFERROR(140081);
   3344 				error = ENOMEM;
   3345 				break;
   3346 			}
   3347 			ips_stat_current_to_4_1_0(ptr, old);
   3348 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3349 			if (error != 0) {
   3350 				IPFERROR(140082);
   3351 			}
   3352 			KFREE(old);
   3353 		}
   3354 		break;
   3355 
   3356 	case IPFOBJ_FRAUTH :
   3357 		if (obj->ipfo_rev >= 4012900) {
   3358 			frauth_4_1_29_t *old29;
   3359 
   3360 			KMALLOC(old29, frauth_4_1_29_t *);
   3361 			if (old29 == NULL) {
   3362 				IPFERROR(140083);
   3363 				error = ENOMEM;
   3364 				break;
   3365 			}
   3366 			frauth_current_to_4_1_29(ptr, old29);
   3367 			error = COPYOUT(old29, obj->ipfo_ptr, sizeof(*old29));
   3368 			if (error != 0) {
   3369 				IPFERROR(140084);
   3370 			}
   3371 			KFREE(old29);
   3372 		} else if (obj->ipfo_rev >= 4012400) {
   3373 			frauth_4_1_24_t *old24;
   3374 
   3375 			KMALLOC(old24, frauth_4_1_24_t *);
   3376 			if (old24 == NULL) {
   3377 				IPFERROR(140085);
   3378 				error = ENOMEM;
   3379 				break;
   3380 			}
   3381 			frauth_current_to_4_1_24(ptr, old24);
   3382 			error = COPYOUT(old24, obj->ipfo_ptr, sizeof(*old24));
   3383 			if (error != 0) {
   3384 				IPFERROR(140086);
   3385 			}
   3386 			KFREE(old24);
   3387 		} else if (obj->ipfo_rev >= 4012300) {
   3388 			frauth_4_1_23_t *old23;
   3389 
   3390 			KMALLOC(old23, frauth_4_1_23_t *);
   3391 			if (old23 == NULL) {
   3392 				IPFERROR(140087);
   3393 				error = ENOMEM;
   3394 				break;
   3395 			}
   3396 			frauth_current_to_4_1_23(ptr, old23);
   3397 			error = COPYOUT(old23, obj->ipfo_ptr, sizeof(*old23));
   3398 			if (error != 0) {
   3399 				IPFERROR(140088);
   3400 			}
   3401 			KFREE(old23);
   3402 		} else if (obj->ipfo_rev >= 4011100) {
   3403 			frauth_4_1_11_t *old11;
   3404 
   3405 			KMALLOC(old11, frauth_4_1_11_t *);
   3406 			if (old11 == NULL) {
   3407 				IPFERROR(140089);
   3408 				error = ENOMEM;
   3409 				break;
   3410 			}
   3411 			frauth_current_to_4_1_11(ptr, old11);
   3412 			error = COPYOUT(old11, obj->ipfo_ptr, sizeof(*old11));
   3413 			if (error != 0) {
   3414 				IPFERROR(140090);
   3415 			}
   3416 			KFREE(old11);
   3417 		}
   3418 		break;
   3419 
   3420 	case IPFOBJ_NAT :
   3421 		if (obj->ipfo_rev >= 4012500) {
   3422 			nat_4_1_25_t *old;
   3423 
   3424 			KMALLOC(old, nat_4_1_25_t *);
   3425 			if (old == NULL) {
   3426 				IPFERROR(140091);
   3427 				error = ENOMEM;
   3428 				break;
   3429 			}
   3430 			nat_current_to_4_1_25(ptr, old);
   3431 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3432 			if (error != 0) {
   3433 				IPFERROR(140092);
   3434 			}
   3435 			KFREE(old);
   3436 		} else if (obj->ipfo_rev >= 4011400) {
   3437 			nat_4_1_14_t *old;
   3438 
   3439 			KMALLOC(old, nat_4_1_14_t *);
   3440 			if (old == NULL) {
   3441 				IPFERROR(140093);
   3442 				error = ENOMEM;
   3443 				break;
   3444 			}
   3445 			nat_current_to_4_1_14(ptr, old);
   3446 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3447 			if (error != 0) {
   3448 				IPFERROR(140094);
   3449 			}
   3450 			KFREE(old);
   3451 		} else if (obj->ipfo_rev >= 4010300) {
   3452 			nat_4_1_3_t *old;
   3453 
   3454 			KMALLOC(old, nat_4_1_3_t *);
   3455 			if (old == NULL) {
   3456 				IPFERROR(140095);
   3457 				error = ENOMEM;
   3458 				break;
   3459 			}
   3460 			nat_current_to_4_1_3(ptr, old);
   3461 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3462 			if (error != 0) {
   3463 				IPFERROR(140096);
   3464 			}
   3465 			KFREE(old);
   3466 		}
   3467 		break;
   3468 
   3469 	case IPFOBJ_FRIPF :
   3470 		if (obj->ipfo_rev < 5000000) {
   3471 			fripf4_t *old;
   3472 
   3473 			KMALLOC(old, fripf4_t *);
   3474 			if (old == NULL) {
   3475 				IPFERROR(140097);
   3476 				error = ENOMEM;
   3477 				break;
   3478 			}
   3479 			ipf_v5fripftov4(ptr, old);
   3480 			error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old));
   3481 			if (error != 0) {
   3482 				IPFERROR(140098);
   3483 			}
   3484 			KFREE(old);
   3485 		}
   3486 		break;
   3487 	}
   3488 	return error;
   3489 }
   3490 
   3491 
   3492 static void
   3493 friostat_current_to_4_1_33(void *current, friostat_4_1_33_t *old, int rev)
   3494 {
   3495 	friostat_t *fiop = (friostat_t *)current;
   3496 
   3497 	bcopy(&fiop->f_st[0].fr_pass, &old->of_st[0], sizeof(old->of_st[0]));
   3498 	bcopy(&fiop->f_st[1].fr_pass, &old->of_st[1], sizeof(old->of_st[1]));
   3499 
   3500 	old->f_ipf[0][0] = fiop->f_ipf[0][0];
   3501 	old->f_ipf[0][1] = fiop->f_ipf[0][1];
   3502 	old->f_ipf[1][0] = fiop->f_ipf[1][0];
   3503 	old->f_ipf[1][1] = fiop->f_ipf[1][1];
   3504 	old->f_acct[0][0] = fiop->f_acct[0][0];
   3505 	old->f_acct[0][1] = fiop->f_acct[0][1];
   3506 	old->f_acct[1][0] = fiop->f_acct[1][0];
   3507 	old->f_acct[1][1] = fiop->f_acct[1][1];
   3508 	old->f_ipf6[0][0] = NULL;
   3509 	old->f_ipf6[0][1] = NULL;
   3510 	old->f_ipf6[1][0] = NULL;
   3511 	old->f_ipf6[1][1] = NULL;
   3512 	old->f_acct6[0][0] = NULL;
   3513 	old->f_acct6[0][1] = NULL;
   3514 	old->f_acct6[1][0] = NULL;
   3515 	old->f_acct6[1][1] = NULL;
   3516 	old->f_auth = fiop->f_auth;
   3517 	bcopy(&fiop->f_groups, &old->f_groups, sizeof(old->f_groups));
   3518 	bcopy(&fiop->f_froute, &old->f_froute, sizeof(old->f_froute));
   3519 	old->f_ticks = fiop->f_ticks;
   3520 	bcopy(&fiop->f_locks, &old->f_locks, sizeof(old->f_locks));
   3521 	old->f_kmutex_sz = 0;
   3522 	old->f_krwlock_sz = 0;
   3523 	old->f_defpass = fiop->f_defpass;
   3524 	old->f_active = fiop->f_active;
   3525 	old->f_running = fiop->f_running;
   3526 	old->f_logging = fiop->f_logging;
   3527 	old->f_features = fiop->f_features;
   3528 	snprintf(old->f_version, sizeof(old->f_version), "IP Filter: v%d.%d.%d",
   3529 		(rev / 1000000) % 100, (rev / 10000) % 100, (rev / 100) % 100);
   3530 }
   3531 
   3532 
   3533 static void
   3534 friostat_current_to_4_1_0(void *current, friostat_4_1_0_t *old, int rev)
   3535 {
   3536 	friostat_t *fiop = (friostat_t *)current;
   3537 
   3538 	bcopy(&fiop->f_st[0].fr_pass, &old->of_st[0], sizeof(old->of_st[0]));
   3539 	bcopy(&fiop->f_st[1].fr_pass, &old->of_st[1], sizeof(old->of_st[1]));
   3540 
   3541 	old->f_ipf[0][0] = fiop->f_ipf[0][0];
   3542 	old->f_ipf[0][1] = fiop->f_ipf[0][1];
   3543 	old->f_ipf[1][0] = fiop->f_ipf[1][0];
   3544 	old->f_ipf[1][1] = fiop->f_ipf[1][1];
   3545 	old->f_acct[0][0] = fiop->f_acct[0][0];
   3546 	old->f_acct[0][1] = fiop->f_acct[0][1];
   3547 	old->f_acct[1][0] = fiop->f_acct[1][0];
   3548 	old->f_acct[1][1] = fiop->f_acct[1][1];
   3549 	old->f_ipf6[0][0] = NULL;
   3550 	old->f_ipf6[0][1] = NULL;
   3551 	old->f_ipf6[1][0] = NULL;
   3552 	old->f_ipf6[1][1] = NULL;
   3553 	old->f_acct6[0][0] = NULL;
   3554 	old->f_acct6[0][1] = NULL;
   3555 	old->f_acct6[1][0] = NULL;
   3556 	old->f_acct6[1][1] = NULL;
   3557 	old->f_auth = fiop->f_auth;
   3558 	bcopy(&fiop->f_groups, &old->f_groups, sizeof(old->f_groups));
   3559 	bcopy(&fiop->f_froute, &old->f_froute, sizeof(old->f_froute));
   3560 	old->f_ticks = fiop->f_ticks;
   3561 	old->f_ipf[0][0] = fiop->f_ipf[0][0];
   3562 	old->f_ipf[0][1] = fiop->f_ipf[0][1];
   3563 	old->f_ipf[1][0] = fiop->f_ipf[1][0];
   3564 	old->f_ipf[1][1] = fiop->f_ipf[1][1];
   3565 	old->f_acct[0][0] = fiop->f_acct[0][0];
   3566 	old->f_acct[0][1] = fiop->f_acct[0][1];
   3567 	old->f_acct[1][0] = fiop->f_acct[1][0];
   3568 	old->f_acct[1][1] = fiop->f_acct[1][1];
   3569 	old->f_ipf6[0][0] = NULL;
   3570 	old->f_ipf6[0][1] = NULL;
   3571 	old->f_ipf6[1][0] = NULL;
   3572 	old->f_ipf6[1][1] = NULL;
   3573 	old->f_acct6[0][0] = NULL;
   3574 	old->f_acct6[0][1] = NULL;
   3575 	old->f_acct6[1][0] = NULL;
   3576 	old->f_acct6[1][1] = NULL;
   3577 	old->f_auth = fiop->f_auth;
   3578 	bcopy(&fiop->f_groups, &old->f_groups, sizeof(old->f_groups));
   3579 	bcopy(&fiop->f_froute, &old->f_froute, sizeof(old->f_froute));
   3580 	old->f_ticks = fiop->f_ticks;
   3581 	bcopy(&fiop->f_locks, &old->f_locks, sizeof(old->f_locks));
   3582 	old->f_kmutex_sz = 0;
   3583 	old->f_krwlock_sz = 0;
   3584 	old->f_defpass = fiop->f_defpass;
   3585 	old->f_active = fiop->f_active;
   3586 	old->f_running = fiop->f_running;
   3587 	old->f_logging = fiop->f_logging;
   3588 	old->f_features = fiop->f_features;
   3589 	snprintf(old->f_version, sizeof(old->f_version), "IP Filter: v%d.%d.%d",
   3590 		(rev / 1000000) % 100, (rev / 10000) % 100, (rev / 100) % 100);
   3591 }
   3592 
   3593 
   3594 /*
   3595  * nflags is v5 flags, returns v4 flags.
   3596  */
   3597 static int
   3598 fr_frflags5to4(u_32_t nflags)
   3599 {
   3600 	u_32_t oflags = 0;
   3601 
   3602 	switch (nflags & FR_CMDMASK) {
   3603 	case FR_CALL :
   3604 		oflags = 0x0;
   3605 		break;
   3606 	case FR_BLOCK :
   3607 		oflags = 0x1;
   3608 		break;
   3609 	case FR_PASS :
   3610 		oflags = 0x2;
   3611 		break;
   3612 	case FR_AUTH :
   3613 		oflags = 0x3;
   3614 		break;
   3615 	case FR_PREAUTH :
   3616 		oflags = 0x4;
   3617 		break;
   3618 	case FR_ACCOUNT :
   3619 		oflags = 0x5;
   3620 		break;
   3621 	case FR_SKIP :
   3622 		oflags = 0x6;
   3623 		break;
   3624 	default :
   3625 		break;
   3626 	}
   3627 
   3628 	if (nflags & FR_LOG)
   3629 		oflags |= 0x00010;
   3630 	if (nflags & FR_CALLNOW)
   3631 		oflags |= 0x00020;
   3632 	if (nflags & FR_NOTSRCIP)
   3633 		oflags |= 0x00080;
   3634 	if (nflags & FR_NOTDSTIP)
   3635 		oflags |= 0x00040;
   3636 	if (nflags & FR_QUICK)
   3637 		oflags |= 0x00100;
   3638 	if (nflags & FR_KEEPFRAG)
   3639 		oflags |= 0x00200;
   3640 	if (nflags & FR_KEEPSTATE)
   3641 		oflags |= 0x00400;
   3642 	if (nflags & FR_FASTROUTE)
   3643 		oflags |= 0x00800;
   3644 	if (nflags & FR_RETRST)
   3645 		oflags |= 0x01000;
   3646 	if (nflags & FR_RETICMP)
   3647 		oflags |= 0x02000;
   3648 	if (nflags & FR_FAKEICMP)
   3649 		oflags |= 0x03000;
   3650 	if (nflags & FR_OUTQUE)
   3651 		oflags |= 0x04000;
   3652 	if (nflags & FR_INQUE)
   3653 		oflags |= 0x08000;
   3654 	if (nflags & FR_LOGBODY)
   3655 		oflags |= 0x10000;
   3656 	if (nflags & FR_LOGFIRST)
   3657 		oflags |= 0x20000;
   3658 	if (nflags & FR_LOGORBLOCK)
   3659 		oflags |= 0x40000;
   3660 	if (nflags & FR_FRSTRICT)
   3661 		oflags |= 0x100000;
   3662 	if (nflags & FR_STSTRICT)
   3663 		oflags |= 0x200000;
   3664 	if (nflags & FR_NEWISN)
   3665 		oflags |= 0x400000;
   3666 	if (nflags & FR_NOICMPERR)
   3667 		oflags |= 0x800000;
   3668 	if (nflags & FR_STATESYNC)
   3669 		oflags |= 0x1000000;
   3670 	if (nflags & FR_NOMATCH)
   3671 		oflags |= 0x8000000;
   3672 	if (nflags & FR_COPIED)
   3673 		oflags |= 0x40000000;
   3674 	if (nflags & FR_INACTIVE)
   3675 		oflags |= 0x80000000;
   3676 
   3677 	return oflags;
   3678 }
   3679 
   3680 
   3681 static void
   3682 frentry_current_to_4_1_34(void *current, frentry_4_1_34_t *old)
   3683 {
   3684 	frentry_t *fr = (frentry_t *)current;
   3685 
   3686 	old->fr_lock = fr->fr_lock;
   3687 	old->fr_next = fr->fr_next;
   3688 	old->fr_grp = (void *)fr->fr_grp;
   3689 	old->fr_isc = fr->fr_isc;
   3690 	old->fr_ifas[0] = fr->fr_ifas[0];
   3691 	old->fr_ifas[1] = fr->fr_ifas[1];
   3692 	old->fr_ifas[2] = fr->fr_ifas[2];
   3693 	old->fr_ifas[3] = fr->fr_ifas[3];
   3694 	old->fr_ptr = fr->fr_ptr;
   3695 	old->fr_comment = NULL;
   3696 	old->fr_ref = fr->fr_ref;
   3697 	old->fr_statecnt = fr->fr_statecnt;
   3698 	old->fr_hits = fr->fr_hits;
   3699 	old->fr_bytes = fr->fr_bytes;
   3700 	old->fr_lastpkt.tv_sec = fr->fr_lastpkt.tv_sec;
   3701 	old->fr_lastpkt.tv_usec = fr->fr_lastpkt.tv_usec;
   3702 	old->fr_curpps = fr->fr_curpps;
   3703 	old->fr_dun.fru_data = fr->fr_dun.fru_data;
   3704 	old->fr_func = fr->fr_func;
   3705 	old->fr_dsize = fr->fr_dsize;
   3706 	old->fr_pps = fr->fr_pps;
   3707 	old->fr_statemax = fr->fr_statemax;
   3708 	old->fr_flineno = fr->fr_flineno;
   3709 	old->fr_type = fr->fr_type;
   3710 	old->fr_flags = fr_frflags5to4(fr->fr_flags);
   3711 	old->fr_logtag = fr->fr_logtag;
   3712 	old->fr_collect = fr->fr_collect;
   3713 	old->fr_arg = fr->fr_arg;
   3714 	old->fr_loglevel = fr->fr_loglevel;
   3715 	old->fr_age[0] = fr->fr_age[0];
   3716 	old->fr_age[1] = fr->fr_age[1];
   3717 	if (fr->fr_family == AF_INET)
   3718 		old->fr_v = 4;
   3719 	if (fr->fr_family == AF_INET6)
   3720 		old->fr_v = 6;
   3721 	old->fr_icode = fr->fr_icode;
   3722 	old->fr_cksum = fr->fr_cksum;
   3723 	old->fr_tifs[0].ofd_ip6 = fr->fr_tifs[0].fd_ip6;
   3724 	old->fr_tifs[1].ofd_ip6 = fr->fr_tifs[0].fd_ip6;
   3725 	old->fr_dif.ofd_ip6 = fr->fr_dif.fd_ip6;
   3726 	if (fr->fr_ifnames[0] >= 0) {
   3727 		strncpy(old->fr_ifnames[0], fr->fr_names + fr->fr_ifnames[0],
   3728 			LIFNAMSIZ);
   3729 		old->fr_ifnames[0][LIFNAMSIZ - 1] = '\0';
   3730 	}
   3731 	if (fr->fr_ifnames[1] >= 0) {
   3732 		strncpy(old->fr_ifnames[1], fr->fr_names + fr->fr_ifnames[1],
   3733 			LIFNAMSIZ);
   3734 		old->fr_ifnames[1][LIFNAMSIZ - 1] = '\0';
   3735 	}
   3736 	if (fr->fr_ifnames[2] >= 0) {
   3737 		strncpy(old->fr_ifnames[2], fr->fr_names + fr->fr_ifnames[2],
   3738 			LIFNAMSIZ);
   3739 		old->fr_ifnames[2][LIFNAMSIZ - 1] = '\0';
   3740 	}
   3741 	if (fr->fr_ifnames[3] >= 0) {
   3742 		strncpy(old->fr_ifnames[3], fr->fr_names + fr->fr_ifnames[3],
   3743 			LIFNAMSIZ);
   3744 		old->fr_ifnames[3][LIFNAMSIZ - 1] = '\0';
   3745 	}
   3746 	if (fr->fr_tifs[0].fd_name >= 0) {
   3747 		strncpy(old->fr_tifs[0].fd_ifname,
   3748 			fr->fr_names + fr->fr_tifs[0].fd_name, LIFNAMSIZ);
   3749 		old->fr_tifs[0].fd_ifname[LIFNAMSIZ - 1] = '\0';
   3750 	}
   3751 	if (fr->fr_tifs[1].fd_name >= 0) {
   3752 		strncpy(old->fr_tifs[1].fd_ifname,
   3753 			fr->fr_names + fr->fr_tifs[1].fd_name, LIFNAMSIZ);
   3754 		old->fr_tifs[1].fd_ifname[LIFNAMSIZ - 1] = '\0';
   3755 	}
   3756 	if (fr->fr_dif.fd_name >= 0) {
   3757 		strncpy(old->fr_dif.fd_ifname,
   3758 			fr->fr_names + fr->fr_dif.fd_name, LIFNAMSIZ);
   3759 		old->fr_dif.fd_ifname[LIFNAMSIZ - 1] = '\0';
   3760 	}
   3761 	if (fr->fr_group >= 0) {
   3762 		strncpy(old->fr_group, fr->fr_names + fr->fr_group,
   3763 			FR_GROUPLEN);
   3764 		old->fr_group[FR_GROUPLEN - 1] = '\0';
   3765 	}
   3766 	if (fr->fr_grhead >= 0) {
   3767 		strncpy(old->fr_grhead, fr->fr_names + fr->fr_grhead,
   3768 			FR_GROUPLEN);
   3769 		old->fr_grhead[FR_GROUPLEN - 1] = '\0';
   3770 	}
   3771 }
   3772 
   3773 
   3774 static void
   3775 frentry_current_to_4_1_16(void *current, frentry_4_1_16_t *old)
   3776 {
   3777 	frentry_t *fr = (frentry_t *)current;
   3778 
   3779 	old->fr_lock = fr->fr_lock;
   3780 	old->fr_next = fr->fr_next;
   3781 	old->fr_grp = (void *)fr->fr_grp;
   3782 	old->fr_isc = fr->fr_isc;
   3783 	old->fr_ifas[0] = fr->fr_ifas[0];
   3784 	old->fr_ifas[1] = fr->fr_ifas[1];
   3785 	old->fr_ifas[2] = fr->fr_ifas[2];
   3786 	old->fr_ifas[3] = fr->fr_ifas[3];
   3787 	old->fr_ptr = fr->fr_ptr;
   3788 	old->fr_comment = NULL;
   3789 	old->fr_ref = fr->fr_ref;
   3790 	old->fr_statecnt = fr->fr_statecnt;
   3791 	old->fr_hits = fr->fr_hits;
   3792 	old->fr_bytes = fr->fr_bytes;
   3793 	old->fr_lastpkt.tv_sec = fr->fr_lastpkt.tv_sec;
   3794 	old->fr_lastpkt.tv_usec = fr->fr_lastpkt.tv_usec;
   3795 	old->fr_curpps = fr->fr_curpps;
   3796 	old->fr_dun.fru_data = fr->fr_dun.fru_data;
   3797 	old->fr_func = fr->fr_func;
   3798 	old->fr_dsize = fr->fr_dsize;
   3799 	old->fr_pps = fr->fr_pps;
   3800 	old->fr_statemax = fr->fr_statemax;
   3801 	old->fr_flineno = fr->fr_flineno;
   3802 	old->fr_type = fr->fr_type;
   3803 	old->fr_flags = fr_frflags5to4(fr->fr_flags);
   3804 	old->fr_logtag = fr->fr_logtag;
   3805 	old->fr_collect = fr->fr_collect;
   3806 	old->fr_arg = fr->fr_arg;
   3807 	old->fr_loglevel = fr->fr_loglevel;
   3808 	old->fr_age[0] = fr->fr_age[0];
   3809 	old->fr_age[1] = fr->fr_age[1];
   3810 	if (old->fr_v == 4)
   3811 		fr->fr_family = AF_INET;
   3812 	if (old->fr_v == 6)
   3813 		fr->fr_family = AF_INET6;
   3814 	old->fr_icode = fr->fr_icode;
   3815 	old->fr_cksum = fr->fr_cksum;
   3816 	old->fr_tifs[0].ofd_ip6 = fr->fr_tifs[0].fd_ip6;
   3817 	old->fr_tifs[1].ofd_ip6 = fr->fr_tifs[0].fd_ip6;
   3818 	old->fr_dif.ofd_ip6 = fr->fr_dif.fd_ip6;
   3819 	if (fr->fr_ifnames[0] >= 0) {
   3820 		strncpy(old->fr_ifnames[0], fr->fr_names + fr->fr_ifnames[0],
   3821 			LIFNAMSIZ);
   3822 		old->fr_ifnames[0][LIFNAMSIZ - 1] = '\0';
   3823 	}
   3824 	if (fr->fr_ifnames[1] >= 0) {
   3825 		strncpy(old->fr_ifnames[1], fr->fr_names + fr->fr_ifnames[1],
   3826 			LIFNAMSIZ);
   3827 		old->fr_ifnames[1][LIFNAMSIZ - 1] = '\0';
   3828 	}
   3829 	if (fr->fr_ifnames[2] >= 0) {
   3830 		strncpy(old->fr_ifnames[2], fr->fr_names + fr->fr_ifnames[2],
   3831 			LIFNAMSIZ);
   3832 		old->fr_ifnames[2][LIFNAMSIZ - 1] = '\0';
   3833 	}
   3834 	if (fr->fr_ifnames[3] >= 0) {
   3835 		strncpy(old->fr_ifnames[3], fr->fr_names + fr->fr_ifnames[3],
   3836 			LIFNAMSIZ);
   3837 		old->fr_ifnames[3][LIFNAMSIZ - 1] = '\0';
   3838 	}
   3839 	if (fr->fr_tifs[0].fd_name >= 0) {
   3840 		strncpy(old->fr_tifs[0].fd_ifname,
   3841 			fr->fr_names + fr->fr_tifs[0].fd_name, LIFNAMSIZ);
   3842 		old->fr_tifs[0].fd_ifname[LIFNAMSIZ - 1] = '\0';
   3843 	}
   3844 	if (fr->fr_tifs[1].fd_name >= 0) {
   3845 		strncpy(old->fr_tifs[1].fd_ifname,
   3846 			fr->fr_names + fr->fr_tifs[1].fd_name, LIFNAMSIZ);
   3847 		old->fr_tifs[1].fd_ifname[LIFNAMSIZ - 1] = '\0';
   3848 	}
   3849 	if (fr->fr_dif.fd_name >= 0) {
   3850 		strncpy(old->fr_dif.fd_ifname,
   3851 			fr->fr_names + fr->fr_dif.fd_name, LIFNAMSIZ);
   3852 		old->fr_dif.fd_ifname[LIFNAMSIZ - 1] = '\0';
   3853 	}
   3854 	if (fr->fr_group >= 0) {
   3855 		strncpy(old->fr_group, fr->fr_names + fr->fr_group,
   3856 			FR_GROUPLEN);
   3857 		old->fr_group[FR_GROUPLEN - 1] = '\0';
   3858 	}
   3859 	if (fr->fr_grhead >= 0) {
   3860 		strncpy(old->fr_grhead, fr->fr_names + fr->fr_grhead,
   3861 			FR_GROUPLEN);
   3862 		old->fr_grhead[FR_GROUPLEN - 1] = '\0';
   3863 	}
   3864 }
   3865 
   3866 
   3867 static void
   3868 frentry_current_to_4_1_0(void *current, frentry_4_1_0_t *old)
   3869 {
   3870 	frentry_t *fr = (frentry_t *)current;
   3871 
   3872 	old->fr_lock = fr->fr_lock;
   3873 	old->fr_next = fr->fr_next;
   3874 	old->fr_grp = (void *)fr->fr_grp;
   3875 	old->fr_isc = fr->fr_isc;
   3876 	old->fr_ifas[0] = fr->fr_ifas[0];
   3877 	old->fr_ifas[1] = fr->fr_ifas[1];
   3878 	old->fr_ifas[2] = fr->fr_ifas[2];
   3879 	old->fr_ifas[3] = fr->fr_ifas[3];
   3880 	old->fr_ptr = fr->fr_ptr;
   3881 	old->fr_comment = NULL;
   3882 	old->fr_ref = fr->fr_ref;
   3883 	old->fr_statecnt = fr->fr_statecnt;
   3884 	old->fr_hits = fr->fr_hits;
   3885 	old->fr_bytes = fr->fr_bytes;
   3886 	old->fr_lastpkt.tv_sec = fr->fr_lastpkt.tv_sec;
   3887 	old->fr_lastpkt.tv_usec = fr->fr_lastpkt.tv_usec;
   3888 	old->fr_curpps = fr->fr_curpps;
   3889 	old->fr_dun.fru_data = fr->fr_dun.fru_data;
   3890 	old->fr_func = fr->fr_func;
   3891 	old->fr_dsize = fr->fr_dsize;
   3892 	old->fr_pps = fr->fr_pps;
   3893 	old->fr_statemax = fr->fr_statemax;
   3894 	old->fr_flineno = fr->fr_flineno;
   3895 	old->fr_type = fr->fr_type;
   3896 	old->fr_flags = fr_frflags5to4(fr->fr_flags);
   3897 	old->fr_logtag = fr->fr_logtag;
   3898 	old->fr_collect = fr->fr_collect;
   3899 	old->fr_arg = fr->fr_arg;
   3900 	old->fr_loglevel = fr->fr_loglevel;
   3901 	old->fr_age[0] = fr->fr_age[0];
   3902 	old->fr_age[1] = fr->fr_age[1];
   3903 	if (old->fr_v == 4)
   3904 		fr->fr_family = AF_INET;
   3905 	if (old->fr_v == 6)
   3906 		fr->fr_family = AF_INET6;
   3907 	old->fr_icode = fr->fr_icode;
   3908 	old->fr_cksum = fr->fr_cksum;
   3909 	old->fr_tifs[0].ofd_ip6 = fr->fr_tifs[0].fd_ip6;
   3910 	old->fr_tifs[1].ofd_ip6 = fr->fr_tifs[0].fd_ip6;
   3911 	old->fr_dif.ofd_ip6 = fr->fr_dif.fd_ip6;
   3912 	if (fr->fr_ifnames[0] >= 0) {
   3913 		strncpy(old->fr_ifnames[0], fr->fr_names + fr->fr_ifnames[0],
   3914 			LIFNAMSIZ);
   3915 		old->fr_ifnames[0][LIFNAMSIZ - 1] = '\0';
   3916 	}
   3917 	if (fr->fr_ifnames[1] >= 0) {
   3918 		strncpy(old->fr_ifnames[1], fr->fr_names + fr->fr_ifnames[1],
   3919 			LIFNAMSIZ);
   3920 		old->fr_ifnames[1][LIFNAMSIZ - 1] = '\0';
   3921 	}
   3922 	if (fr->fr_ifnames[2] >= 0) {
   3923 		strncpy(old->fr_ifnames[2], fr->fr_names + fr->fr_ifnames[2],
   3924 			LIFNAMSIZ);
   3925 		old->fr_ifnames[2][LIFNAMSIZ - 1] = '\0';
   3926 	}
   3927 	if (fr->fr_ifnames[3] >= 0) {
   3928 		strncpy(old->fr_ifnames[3], fr->fr_names + fr->fr_ifnames[3],
   3929 			LIFNAMSIZ);
   3930 		old->fr_ifnames[3][LIFNAMSIZ - 1] = '\0';
   3931 	}
   3932 	if (fr->fr_tifs[0].fd_name >= 0) {
   3933 		strncpy(old->fr_tifs[0].fd_ifname,
   3934 			fr->fr_names + fr->fr_tifs[0].fd_name, LIFNAMSIZ);
   3935 		old->fr_tifs[0].fd_ifname[LIFNAMSIZ - 1] = '\0';
   3936 	}
   3937 	if (fr->fr_tifs[1].fd_name >= 0) {
   3938 		strncpy(old->fr_tifs[1].fd_ifname,
   3939 			fr->fr_names + fr->fr_tifs[1].fd_name, LIFNAMSIZ);
   3940 		old->fr_tifs[1].fd_ifname[LIFNAMSIZ - 1] = '\0';
   3941 	}
   3942 	if (fr->fr_dif.fd_name >= 0) {
   3943 		strncpy(old->fr_dif.fd_ifname,
   3944 			fr->fr_names + fr->fr_dif.fd_name, LIFNAMSIZ);
   3945 		old->fr_dif.fd_ifname[LIFNAMSIZ - 1] = '\0';
   3946 	}
   3947 	if (fr->fr_group >= 0) {
   3948 		strncpy(old->fr_group, fr->fr_names + fr->fr_group,
   3949 			FR_GROUPLEN);
   3950 		old->fr_group[FR_GROUPLEN - 1] = '\0';
   3951 	}
   3952 	if (fr->fr_grhead >= 0) {
   3953 		strncpy(old->fr_grhead, fr->fr_names + fr->fr_grhead,
   3954 			FR_GROUPLEN);
   3955 		old->fr_grhead[FR_GROUPLEN - 1] = '\0';
   3956 	}
   3957 }
   3958 
   3959 
   3960 static void
   3961 fr_info_current_to_4_1_24(void *current, fr_info_4_1_24_t *old)
   3962 {
   3963 	fr_info_t *fin = (fr_info_t *)current;
   3964 
   3965 	old->fin_ifp = fin->fin_ifp;
   3966 	ipf_v5iptov4(&fin->fin_fi, &old->fin_fi);
   3967 	bcopy(&fin->fin_dat, &old->fin_dat, sizeof(fin->fin_dat));
   3968 	old->fin_out = fin->fin_out;
   3969 	old->fin_rev = fin->fin_rev;
   3970 	old->fin_hlen = fin->fin_hlen;
   3971 	old->ofin_tcpf = fin->fin_tcpf;
   3972 	old->fin_icode = fin->fin_icode;
   3973 	old->fin_rule = fin->fin_rule;
   3974 	bcopy(fin->fin_group, old->fin_group, sizeof(fin->fin_group));
   3975 	old->fin_fr = fin->fin_fr;
   3976 	old->fin_dp = fin->fin_dp;
   3977 	old->fin_dlen = fin->fin_dlen;
   3978 	old->fin_plen = fin->fin_plen;
   3979 	old->fin_ipoff = fin->fin_ipoff;
   3980 	old->fin_id = fin->fin_id;
   3981 	old->fin_off = fin->fin_off;
   3982 	old->fin_depth = fin->fin_depth;
   3983 	old->fin_error = fin->fin_error;
   3984 	old->fin_cksum = fin->fin_cksum;
   3985 	old->fin_state = NULL;
   3986 	old->fin_nat = NULL;
   3987 	old->fin_nattag = fin->fin_nattag;
   3988 	old->fin_exthdr = NULL;
   3989 	old->ofin_ip = fin->fin_ip;
   3990 	old->fin_mp = fin->fin_mp;
   3991 	old->fin_m = fin->fin_m;
   3992 #ifdef  MENTAT
   3993 	old->fin_qfm = fin->fin_qfm;
   3994 	old->fin_qpi = fin->fin_qpi;
   3995 	old->fin_ifname[0] = '\0';
   3996 #endif
   3997 #ifdef  __sgi
   3998 	old->fin_hbuf = fin->fin_hbuf;
   3999 #endif
   4000 }
   4001 
   4002 
   4003 static void
   4004 fr_info_current_to_4_1_23(void *current, fr_info_4_1_23_t *old)
   4005 {
   4006 	fr_info_t *fin = (fr_info_t *)current;
   4007 
   4008 	old->fin_ifp = fin->fin_ifp;
   4009 	ipf_v5iptov4(&fin->fin_fi, &old->fin_fi);
   4010 	bcopy(&fin->fin_dat, &old->fin_dat, sizeof(fin->fin_dat));
   4011 	old->fin_out = fin->fin_out;
   4012 	old->fin_rev = fin->fin_rev;
   4013 	old->fin_hlen = fin->fin_hlen;
   4014 	old->ofin_tcpf = fin->fin_tcpf;
   4015 	old->fin_icode = fin->fin_icode;
   4016 	old->fin_rule = fin->fin_rule;
   4017 	bcopy(fin->fin_group, old->fin_group, sizeof(fin->fin_group));
   4018 	old->fin_fr = fin->fin_fr;
   4019 	old->fin_dp = fin->fin_dp;
   4020 	old->fin_dlen = fin->fin_dlen;
   4021 	old->fin_plen = fin->fin_plen;
   4022 	old->fin_ipoff = fin->fin_ipoff;
   4023 	old->fin_id = fin->fin_id;
   4024 	old->fin_off = fin->fin_off;
   4025 	old->fin_depth = fin->fin_depth;
   4026 	old->fin_error = fin->fin_error;
   4027 	old->fin_state = NULL;
   4028 	old->fin_nat = NULL;
   4029 	old->fin_nattag = fin->fin_nattag;
   4030 	old->ofin_ip = fin->fin_ip;
   4031 	old->fin_mp = fin->fin_mp;
   4032 	old->fin_m = fin->fin_m;
   4033 #ifdef  MENTAT
   4034 	old->fin_qfm = fin->fin_qfm;
   4035 	old->fin_qpi = fin->fin_qpi;
   4036 	old->fin_ifname[0] = '\0';
   4037 #endif
   4038 #ifdef  __sgi
   4039 	old->fin_hbuf = fin->fin_hbuf;
   4040 #endif
   4041 }
   4042 
   4043 
   4044 static void
   4045 fr_info_current_to_4_1_11(void *current, fr_info_4_1_11_t *old)
   4046 {
   4047 	fr_info_t *fin = (fr_info_t *)current;
   4048 
   4049 	old->fin_ifp = fin->fin_ifp;
   4050 	ipf_v5iptov4(&fin->fin_fi, &old->fin_fi);
   4051 	bcopy(&fin->fin_dat, &old->fin_dat, sizeof(fin->fin_dat));
   4052 	old->fin_out = fin->fin_out;
   4053 	old->fin_rev = fin->fin_rev;
   4054 	old->fin_hlen = fin->fin_hlen;
   4055 	old->ofin_tcpf = fin->fin_tcpf;
   4056 	old->fin_icode = fin->fin_icode;
   4057 	old->fin_rule = fin->fin_rule;
   4058 	bcopy(fin->fin_group, old->fin_group, sizeof(fin->fin_group));
   4059 	old->fin_fr = fin->fin_fr;
   4060 	old->fin_dp = fin->fin_dp;
   4061 	old->fin_dlen = fin->fin_dlen;
   4062 	old->fin_plen = fin->fin_plen;
   4063 	old->fin_ipoff = fin->fin_ipoff;
   4064 	old->fin_id = fin->fin_id;
   4065 	old->fin_off = fin->fin_off;
   4066 	old->fin_depth = fin->fin_depth;
   4067 	old->fin_error = fin->fin_error;
   4068 	old->fin_state = NULL;
   4069 	old->fin_nat = NULL;
   4070 	old->fin_nattag = fin->fin_nattag;
   4071 	old->ofin_ip = fin->fin_ip;
   4072 	old->fin_mp = fin->fin_mp;
   4073 	old->fin_m = fin->fin_m;
   4074 #ifdef  MENTAT
   4075 	old->fin_qfm = fin->fin_qfm;
   4076 	old->fin_qpi = fin->fin_qpi;
   4077 	old->fin_ifname[0] = '\0';
   4078 #endif
   4079 #ifdef  __sgi
   4080 	old->fin_hbuf = fin->fin_hbuf;
   4081 #endif
   4082 }
   4083 
   4084 
   4085 static void
   4086 frauth_current_to_4_1_29(void *current, frauth_4_1_29_t *old)
   4087 {
   4088 	frauth_t *fra = (frauth_t *)current;
   4089 
   4090 	old->fra_age = fra->fra_age;
   4091 	old->fra_len = fra->fra_len;
   4092 	old->fra_index = fra->fra_index;
   4093 	old->fra_pass = fra->fra_pass;
   4094 	fr_info_current_to_4_1_24(&fra->fra_info, &old->fra_info);
   4095 	old->fra_buf = fra->fra_buf;
   4096 	old->fra_flx = fra->fra_flx;
   4097 #ifdef	MENTAT
   4098 	old->fra_q = fra->fra_q;
   4099 	old->fra_m = fra->fra_m;
   4100 #endif
   4101 }
   4102 
   4103 
   4104 static void
   4105 frauth_current_to_4_1_24(void *current, frauth_4_1_24_t *old)
   4106 {
   4107 	frauth_t *fra = (frauth_t *)current;
   4108 
   4109 	old->fra_age = fra->fra_age;
   4110 	old->fra_len = fra->fra_len;
   4111 	old->fra_index = fra->fra_index;
   4112 	old->fra_pass = fra->fra_pass;
   4113 	fr_info_current_to_4_1_24(&fra->fra_info, &old->fra_info);
   4114 	old->fra_buf = fra->fra_buf;
   4115 #ifdef	MENTAT
   4116 	old->fra_q = fra->fra_q;
   4117 	old->fra_m = fra->fra_m;
   4118 #endif
   4119 }
   4120 
   4121 
   4122 static void
   4123 frauth_current_to_4_1_23(void *current, frauth_4_1_23_t *old)
   4124 {
   4125 	frauth_t *fra = (frauth_t *)current;
   4126 
   4127 	old->fra_age = fra->fra_age;
   4128 	old->fra_len = fra->fra_len;
   4129 	old->fra_index = fra->fra_index;
   4130 	old->fra_pass = fra->fra_pass;
   4131 	fr_info_current_to_4_1_23(&fra->fra_info, &old->fra_info);
   4132 	old->fra_buf = fra->fra_buf;
   4133 #ifdef	MENTAT
   4134 	old->fra_q = fra->fra_q;
   4135 	old->fra_m = fra->fra_m;
   4136 #endif
   4137 }
   4138 
   4139 
   4140 static void
   4141 frauth_current_to_4_1_11(void *current, frauth_4_1_11_t *old)
   4142 {
   4143 	frauth_t *fra = (frauth_t *)current;
   4144 
   4145 	old->fra_age = fra->fra_age;
   4146 	old->fra_len = fra->fra_len;
   4147 	old->fra_index = fra->fra_index;
   4148 	old->fra_pass = fra->fra_pass;
   4149 	fr_info_current_to_4_1_11(&fra->fra_info, &old->fra_info);
   4150 	old->fra_buf = fra->fra_buf;
   4151 #ifdef	MENTAT
   4152 	old->fra_q = fra->fra_q;
   4153 	old->fra_m = fra->fra_m;
   4154 #endif
   4155 }
   4156 
   4157 
   4158 static void
   4159 ipnat_current_to_4_1_14(void *current, ipnat_4_1_14_t *old)
   4160 {
   4161 	ipnat_t *np = (ipnat_t *)current;
   4162 
   4163 	old->in_next = np->in_next;
   4164 	old->in_rnext = np->in_rnext;
   4165 	old->in_prnext = np->in_prnext;
   4166 	old->in_mnext = np->in_mnext;
   4167 	old->in_pmnext = np->in_pmnext;
   4168 	old->in_tqehead[0] = np->in_tqehead[0];
   4169 	old->in_tqehead[1] = np->in_tqehead[1];
   4170 	old->in_ifps[0] = np->in_ifps[0];
   4171 	old->in_ifps[1] = np->in_ifps[1];
   4172 	old->in_apr = np->in_apr;
   4173 	old->in_comment = np->in_comment;
   4174 	old->in_space = np->in_space;
   4175 	old->in_hits = np->in_hits;
   4176 	old->in_use = np->in_use;
   4177 	old->in_hv = np->in_hv[0];
   4178 	old->in_flineno = np->in_flineno;
   4179 	if (old->in_redir == NAT_REDIRECT)
   4180 		old->in_pnext = np->in_dpnext;
   4181 	else
   4182 		old->in_pnext = np->in_spnext;
   4183 	old->in_v = np->in_v[0];
   4184 	old->in_flags = np->in_flags;
   4185 	old->in_mssclamp = np->in_mssclamp;
   4186 	old->in_age[0] = np->in_age[0];
   4187 	old->in_age[1] = np->in_age[1];
   4188 	old->in_redir = np->in_redir;
   4189 	old->in_p = np->in_pr[0];
   4190 	if (np->in_redir == NAT_REDIRECT) {
   4191 		old->in_next6 = np->in_ndst.na_nextaddr;
   4192 		old->in_in[0] = np->in_ndst.na_addr[0];
   4193 		old->in_in[1] = np->in_ndst.na_addr[1];
   4194 		old->in_out[0] = np->in_odst.na_addr[0];
   4195 		old->in_out[1] = np->in_odst.na_addr[1];
   4196 		old->in_src[0] = np->in_osrc.na_addr[0];
   4197 		old->in_src[1] = np->in_osrc.na_addr[1];
   4198 	} else {
   4199 		old->in_next6 = np->in_nsrc.na_nextaddr;
   4200 		old->in_out[0] = np->in_nsrc.na_addr[0];
   4201 		old->in_out[1] = np->in_nsrc.na_addr[1];
   4202 		old->in_in[0] = np->in_osrc.na_addr[0];
   4203 		old->in_in[1] = np->in_osrc.na_addr[1];
   4204 		old->in_src[0] = np->in_odst.na_addr[0];
   4205 		old->in_src[1] = np->in_odst.na_addr[1];
   4206 	}
   4207 	ipfv5tuctov4(&np->in_tuc, &old->in_tuc);
   4208 	if (np->in_redir == NAT_REDIRECT) {
   4209 		old->in_port[0] = np->in_dpmin;
   4210 		old->in_port[1] = np->in_dpmax;
   4211 	} else {
   4212 		old->in_port[0] = np->in_spmin;
   4213 		old->in_port[1] = np->in_spmax;
   4214 	}
   4215 	old->in_ppip = np->in_ppip;
   4216 	old->in_ippip = np->in_ippip;
   4217 	bcopy(&np->in_tag, &old->in_tag, sizeof(np->in_tag));
   4218 
   4219 	if (np->in_ifnames[0] >= 0) {
   4220 		strncpy(old->in_ifnames[0], np->in_names + np->in_ifnames[0],
   4221 			LIFNAMSIZ);
   4222 		old->in_ifnames[0][LIFNAMSIZ - 1] = '\0';
   4223 	}
   4224 	if (np->in_ifnames[1] >= 0) {
   4225 		strncpy(old->in_ifnames[1], np->in_names + np->in_ifnames[1],
   4226 			LIFNAMSIZ);
   4227 		old->in_ifnames[1][LIFNAMSIZ - 1] = '\0';
   4228 	}
   4229 	if (np->in_plabel >= 0) {
   4230 		strncpy(old->in_plabel, np->in_names + np->in_plabel,
   4231 			APR_LABELLEN);
   4232 		old->in_plabel[APR_LABELLEN - 1] = '\0';
   4233 	}
   4234 }
   4235 
   4236 
   4237 static void
   4238 ipnat_current_to_4_1_0(void *current, ipnat_4_1_0_t *old)
   4239 {
   4240 	ipnat_t *np = (ipnat_t *)current;
   4241 
   4242 	old->in_next = np->in_next;
   4243 	old->in_rnext = np->in_rnext;
   4244 	old->in_prnext = np->in_prnext;
   4245 	old->in_mnext = np->in_mnext;
   4246 	old->in_pmnext = np->in_pmnext;
   4247 	old->in_tqehead[0] = np->in_tqehead[0];
   4248 	old->in_tqehead[1] = np->in_tqehead[1];
   4249 	old->in_ifps[0] = np->in_ifps[0];
   4250 	old->in_ifps[1] = np->in_ifps[1];
   4251 	old->in_apr = np->in_apr;
   4252 	old->in_comment = np->in_comment;
   4253 	old->in_space = np->in_space;
   4254 	old->in_hits = np->in_hits;
   4255 	old->in_use = np->in_use;
   4256 	old->in_hv = np->in_hv[0];
   4257 	old->in_flineno = np->in_flineno;
   4258 	if (old->in_redir == NAT_REDIRECT)
   4259 		old->in_pnext = np->in_dpnext;
   4260 	else
   4261 		old->in_pnext = np->in_spnext;
   4262 	old->in_v = np->in_v[0];
   4263 	old->in_flags = np->in_flags;
   4264 	old->in_mssclamp = np->in_mssclamp;
   4265 	old->in_age[0] = np->in_age[0];
   4266 	old->in_age[1] = np->in_age[1];
   4267 	old->in_redir = np->in_redir;
   4268 	old->in_p = np->in_pr[0];
   4269 	if (np->in_redir == NAT_REDIRECT) {
   4270 		old->in_next6 = np->in_ndst.na_nextaddr;
   4271 		old->in_in[0] = np->in_ndst.na_addr[0];
   4272 		old->in_in[1] = np->in_ndst.na_addr[1];
   4273 		old->in_out[0] = np->in_odst.na_addr[0];
   4274 		old->in_out[1] = np->in_odst.na_addr[1];
   4275 		old->in_src[0] = np->in_osrc.na_addr[0];
   4276 		old->in_src[1] = np->in_osrc.na_addr[1];
   4277 	} else {
   4278 		old->in_next6 = np->in_nsrc.na_nextaddr;
   4279 		old->in_out[0] = np->in_nsrc.na_addr[0];
   4280 		old->in_out[1] = np->in_nsrc.na_addr[1];
   4281 		old->in_in[0] = np->in_osrc.na_addr[0];
   4282 		old->in_in[1] = np->in_osrc.na_addr[1];
   4283 		old->in_src[0] = np->in_odst.na_addr[0];
   4284 		old->in_src[1] = np->in_odst.na_addr[1];
   4285 	}
   4286 	ipfv5tuctov4(&np->in_tuc, &old->in_tuc);
   4287 	if (np->in_redir == NAT_REDIRECT) {
   4288 		old->in_port[0] = np->in_dpmin;
   4289 		old->in_port[1] = np->in_dpmax;
   4290 	} else {
   4291 		old->in_port[0] = np->in_spmin;
   4292 		old->in_port[1] = np->in_spmax;
   4293 	}
   4294 	old->in_ppip = np->in_ppip;
   4295 	old->in_ippip = np->in_ippip;
   4296 	bcopy(&np->in_tag, &old->in_tag, sizeof(np->in_tag));
   4297 
   4298 	if (np->in_ifnames[0] >= 0) {
   4299 		strncpy(old->in_ifnames[0], np->in_names + np->in_ifnames[0],
   4300 			LIFNAMSIZ);
   4301 		old->in_ifnames[0][LIFNAMSIZ - 1] = '\0';
   4302 	}
   4303 	if (np->in_ifnames[1] >= 0) {
   4304 		strncpy(old->in_ifnames[1], np->in_names + np->in_ifnames[1],
   4305 			LIFNAMSIZ);
   4306 		old->in_ifnames[1][LIFNAMSIZ - 1] = '\0';
   4307 	}
   4308 	if (np->in_plabel >= 0) {
   4309 		strncpy(old->in_plabel, np->in_names + np->in_plabel,
   4310 			APR_LABELLEN);
   4311 		old->in_plabel[APR_LABELLEN - 1] = '\0';
   4312 	}
   4313 }
   4314 
   4315 
   4316 static void
   4317 ipstate_current_to_4_1_16(void *current, ipstate_4_1_16_t *old)
   4318 {
   4319 	ipstate_t *is = (ipstate_t *)current;
   4320 
   4321 	old->is_lock = is->is_lock;
   4322 	old->is_next = is->is_next;
   4323 	old->is_pnext = is->is_pnext;
   4324 	old->is_hnext = is->is_hnext;
   4325 	old->is_phnext = is->is_phnext;
   4326 	old->is_me = is->is_me;
   4327 	old->is_ifp[0] = is->is_ifp[0];
   4328 	old->is_ifp[1] = is->is_ifp[1];
   4329 	old->is_sync = is->is_sync;
   4330 	old->is_rule = is->is_rule;
   4331 	old->is_tqehead[0] = is->is_tqehead[0];
   4332 	old->is_tqehead[1] = is->is_tqehead[1];
   4333 	old->is_isc = is->is_isc;
   4334 	old->is_pkts[0] = is->is_pkts[0];
   4335 	old->is_pkts[1] = is->is_pkts[1];
   4336 	old->is_pkts[2] = is->is_pkts[2];
   4337 	old->is_pkts[3] = is->is_pkts[3];
   4338 	old->is_bytes[0] = is->is_bytes[0];
   4339 	old->is_bytes[1] = is->is_bytes[1];
   4340 	old->is_bytes[2] = is->is_bytes[2];
   4341 	old->is_bytes[3] = is->is_bytes[3];
   4342 	old->is_icmppkts[0] = is->is_icmppkts[0];
   4343 	old->is_icmppkts[1] = is->is_icmppkts[1];
   4344 	old->is_icmppkts[2] = is->is_icmppkts[2];
   4345 	old->is_icmppkts[3] = is->is_icmppkts[3];
   4346 	old->is_sti = is->is_sti;
   4347 	old->is_frage[0] = is->is_frage[0];
   4348 	old->is_frage[1] = is->is_frage[1];
   4349 	old->is_ref = is->is_ref;
   4350 	old->is_isninc[0] = is->is_isninc[0];
   4351 	old->is_isninc[1] = is->is_isninc[1];
   4352 	old->is_sumd[0] = is->is_sumd[0];
   4353 	old->is_sumd[1] = is->is_sumd[1];
   4354 	old->is_src = is->is_src;
   4355 	old->is_dst = is->is_dst;
   4356 	old->is_pass = is->is_pass;
   4357 	old->is_p = is->is_p;
   4358 	old->is_v = is->is_v;
   4359 	old->is_hv = is->is_hv;
   4360 	old->is_tag = is->is_tag;
   4361 	old->is_opt[0] = is->is_opt[0];
   4362 	old->is_opt[1] = is->is_opt[1];
   4363 	old->is_optmsk[0] = is->is_optmsk[0];
   4364 	old->is_optmsk[1] = is->is_optmsk[1];
   4365 	old->is_sec = is->is_sec;
   4366 	old->is_secmsk = is->is_secmsk;
   4367 	old->is_auth = is->is_auth;
   4368 	old->is_authmsk = is->is_authmsk;
   4369 	ipf_v5tcpinfoto4(&is->is_tcp, &old->is_tcp);
   4370 	old->is_flags = is->is_flags;
   4371 	old->is_flx[0][0] = is->is_flx[0][0];
   4372 	old->is_flx[0][1] = is->is_flx[0][1];
   4373 	old->is_flx[1][0] = is->is_flx[1][0];
   4374 	old->is_flx[1][1] = is->is_flx[1][1];
   4375 	old->is_rulen = is->is_rulen;
   4376 	old->is_s0[0] = is->is_s0[0];
   4377 	old->is_s0[1] = is->is_s0[1];
   4378 	old->is_smsk[0] = is->is_smsk[0];
   4379 	old->is_smsk[1] = is->is_smsk[1];
   4380 	bcopy(is->is_group, old->is_group, sizeof(is->is_group));
   4381 	bcopy(is->is_sbuf, old->is_sbuf, sizeof(is->is_sbuf));
   4382 	bcopy(is->is_ifname, old->is_ifname, sizeof(is->is_ifname));
   4383 }
   4384 
   4385 
   4386 static void
   4387 ipstate_current_to_4_1_0(void *current, ipstate_4_1_0_t *old)
   4388 {
   4389 	ipstate_t *is = (ipstate_t *)current;
   4390 
   4391 	old->is_lock = is->is_lock;
   4392 	old->is_next = is->is_next;
   4393 	old->is_pnext = is->is_pnext;
   4394 	old->is_hnext = is->is_hnext;
   4395 	old->is_phnext = is->is_phnext;
   4396 	old->is_me = is->is_me;
   4397 	old->is_ifp[0] = is->is_ifp[0];
   4398 	old->is_ifp[1] = is->is_ifp[1];
   4399 	old->is_sync = is->is_sync;
   4400 	bzero(&old->is_nat, sizeof(old->is_nat));
   4401 	old->is_rule = is->is_rule;
   4402 	old->is_tqehead[0] = is->is_tqehead[0];
   4403 	old->is_tqehead[1] = is->is_tqehead[1];
   4404 	old->is_isc = is->is_isc;
   4405 	old->is_pkts[0] = is->is_pkts[0];
   4406 	old->is_pkts[1] = is->is_pkts[1];
   4407 	old->is_pkts[2] = is->is_pkts[2];
   4408 	old->is_pkts[3] = is->is_pkts[3];
   4409 	old->is_bytes[0] = is->is_bytes[0];
   4410 	old->is_bytes[1] = is->is_bytes[1];
   4411 	old->is_bytes[2] = is->is_bytes[2];
   4412 	old->is_bytes[3] = is->is_bytes[3];
   4413 	old->is_icmppkts[0] = is->is_icmppkts[0];
   4414 	old->is_icmppkts[1] = is->is_icmppkts[1];
   4415 	old->is_icmppkts[2] = is->is_icmppkts[2];
   4416 	old->is_icmppkts[3] = is->is_icmppkts[3];
   4417 	old->is_sti = is->is_sti;
   4418 	old->is_frage[0] = is->is_frage[0];
   4419 	old->is_frage[1] = is->is_frage[1];
   4420 	old->is_ref = is->is_ref;
   4421 	old->is_isninc[0] = is->is_isninc[0];
   4422 	old->is_isninc[1] = is->is_isninc[1];
   4423 	old->is_sumd[0] = is->is_sumd[0];
   4424 	old->is_sumd[1] = is->is_sumd[1];
   4425 	old->is_src = is->is_src;
   4426 	old->is_dst = is->is_dst;
   4427 	old->is_pass = is->is_pass;
   4428 	old->is_p = is->is_p;
   4429 	old->is_v = is->is_v;
   4430 	old->is_hv = is->is_hv;
   4431 	old->is_tag = is->is_tag;
   4432 	old->is_opt[0] = is->is_opt[0];
   4433 	old->is_opt[1] = is->is_opt[1];
   4434 	old->is_optmsk[0] = is->is_optmsk[0];
   4435 	old->is_optmsk[1] = is->is_optmsk[1];
   4436 	old->is_sec = is->is_sec;
   4437 	old->is_secmsk = is->is_secmsk;
   4438 	old->is_auth = is->is_auth;
   4439 	old->is_authmsk = is->is_authmsk;
   4440 	ipf_v5tcpinfoto4(&is->is_tcp, &old->is_tcp);
   4441 	old->is_flags = is->is_flags;
   4442 	old->is_flx[0][0] = is->is_flx[0][0];
   4443 	old->is_flx[0][1] = is->is_flx[0][1];
   4444 	old->is_flx[1][0] = is->is_flx[1][0];
   4445 	old->is_flx[1][1] = is->is_flx[1][1];
   4446 	old->is_rulen = is->is_rulen;
   4447 	old->is_s0[0] = is->is_s0[0];
   4448 	old->is_s0[1] = is->is_s0[1];
   4449 	old->is_smsk[0] = is->is_smsk[0];
   4450 	old->is_smsk[1] = is->is_smsk[1];
   4451 	bcopy(is->is_group, old->is_group, sizeof(is->is_group));
   4452 	bcopy(is->is_sbuf, old->is_sbuf, sizeof(is->is_sbuf));
   4453 	bcopy(is->is_ifname, old->is_ifname, sizeof(is->is_ifname));
   4454 }
   4455 
   4456 
   4457 static void
   4458 ips_stat_current_to_4_1_21(void *current, ips_stat_4_1_21_t *old)
   4459 {
   4460 	ips_stat_t *st = (ips_stat_t *)current;
   4461 
   4462 	old->iss_hits = st->iss_hits;
   4463 	old->iss_miss = st->iss_check_miss;
   4464 	old->iss_max = st->iss_max;
   4465 	old->iss_maxref = st->iss_max_ref;
   4466 	old->iss_tcp = st->iss_proto[IPPROTO_TCP];
   4467 	old->iss_udp = st->iss_proto[IPPROTO_UDP];
   4468 	old->iss_icmp = st->iss_proto[IPPROTO_ICMP];
   4469 	old->iss_nomem = st->iss_nomem;
   4470 	old->iss_expire = st->iss_expire;
   4471 	old->iss_fin = st->iss_fin;
   4472 	old->iss_active = st->iss_active;
   4473 	old->iss_logged = st->iss_log_ok;
   4474 	old->iss_logfail = st->iss_log_fail;
   4475 	old->iss_inuse = st->iss_inuse;
   4476 	old->iss_wild = st->iss_wild;
   4477 	old->iss_ticks = st->iss_ticks;
   4478 	old->iss_bucketfull = st->iss_bucket_full;
   4479 	old->iss_statesize = st->iss_state_size;
   4480 	old->iss_statemax = st->iss_state_max;
   4481 	old->iss_table = st->iss_table;
   4482 	old->iss_list = st->iss_list;
   4483 	old->iss_bucketlen = (void *)st->iss_bucketlen;
   4484 	old->iss_tcptab = st->iss_tcptab;
   4485 }
   4486 
   4487 
   4488 static void
   4489 ips_stat_current_to_4_1_0(void *current, ips_stat_4_1_0_t *old)
   4490 {
   4491 	ips_stat_t *st = (ips_stat_t *)current;
   4492 
   4493 	old->iss_hits = st->iss_hits;
   4494 	old->iss_miss = st->iss_check_miss;
   4495 	old->iss_max = st->iss_max;
   4496 	old->iss_maxref = st->iss_max_ref;
   4497 	old->iss_tcp = st->iss_proto[IPPROTO_TCP];
   4498 	old->iss_udp = st->iss_proto[IPPROTO_UDP];
   4499 	old->iss_icmp = st->iss_proto[IPPROTO_ICMP];
   4500 	old->iss_nomem = st->iss_nomem;
   4501 	old->iss_expire = st->iss_expire;
   4502 	old->iss_fin = st->iss_fin;
   4503 	old->iss_active = st->iss_active;
   4504 	old->iss_logged = st->iss_log_ok;
   4505 	old->iss_logfail = st->iss_log_fail;
   4506 	old->iss_inuse = st->iss_inuse;
   4507 	old->iss_wild = st->iss_wild;
   4508 	old->iss_ticks = st->iss_ticks;
   4509 	old->iss_bucketfull = st->iss_bucket_full;
   4510 	old->iss_statesize = st->iss_state_size;
   4511 	old->iss_statemax = st->iss_state_max;
   4512 	old->iss_table = st->iss_table;
   4513 	old->iss_list = st->iss_list;
   4514 	old->iss_bucketlen = (void *)st->iss_bucketlen;
   4515 }
   4516 
   4517 
   4518 static void
   4519 nat_save_current_to_4_1_16(void *current, nat_save_4_1_16_t *old)
   4520 {
   4521 	nat_save_t *nats = (nat_save_t *)current;
   4522 
   4523 	old->ipn_next = nats->ipn_next;
   4524 	bcopy(&nats->ipn_nat, &old->ipn_nat, sizeof(old->ipn_nat));
   4525 	bcopy(&nats->ipn_ipnat, &old->ipn_ipnat, sizeof(old->ipn_ipnat));
   4526 	frentry_current_to_4_1_16(&nats->ipn_fr, &old->ipn_fr);
   4527 	old->ipn_dsize = nats->ipn_dsize;
   4528 	bcopy(nats->ipn_data, old->ipn_data, sizeof(nats->ipn_data));
   4529 }
   4530 
   4531 
   4532 static void
   4533 nat_save_current_to_4_1_14(void *current, nat_save_4_1_14_t *old)
   4534 {
   4535 	nat_save_t *nats = (nat_save_t *)current;
   4536 
   4537 	old->ipn_next = nats->ipn_next;
   4538 	bcopy(&nats->ipn_nat, &old->ipn_nat, sizeof(old->ipn_nat));
   4539 	bcopy(&nats->ipn_ipnat, &old->ipn_ipnat, sizeof(old->ipn_ipnat));
   4540 	frentry_current_to_4_1_0(&nats->ipn_fr, &old->ipn_fr);
   4541 	old->ipn_dsize = nats->ipn_dsize;
   4542 	bcopy(nats->ipn_data, old->ipn_data, sizeof(nats->ipn_data));
   4543 }
   4544 
   4545 
   4546 static void
   4547 nat_save_current_to_4_1_3(void *current, nat_save_4_1_3_t *old)
   4548 {
   4549 	nat_save_t *nats = (nat_save_t *)current;
   4550 
   4551 	old->ipn_next = nats->ipn_next;
   4552 	bcopy(&nats->ipn_nat, &old->ipn_nat, sizeof(old->ipn_nat));
   4553 	bcopy(&nats->ipn_ipnat, &old->ipn_ipnat, sizeof(old->ipn_ipnat));
   4554 	frentry_current_to_4_1_0(&nats->ipn_fr, &old->ipn_fr);
   4555 	old->ipn_dsize = nats->ipn_dsize;
   4556 	bcopy(nats->ipn_data, old->ipn_data, sizeof(nats->ipn_data));
   4557 }
   4558 
   4559 
   4560 static void
   4561 nat_current_to_4_1_25(void *current, nat_4_1_25_t *old)
   4562 {
   4563 	nat_t *nat = (nat_t *)current;
   4564 
   4565 	old->nat_lock = nat->nat_lock;
   4566 	old->nat_next = (void *)nat->nat_next;
   4567 	old->nat_pnext = (void *)nat->nat_pnext;
   4568 	old->nat_hnext[0] = (void *)nat->nat_hnext[0];
   4569 	old->nat_hnext[1] = (void *)nat->nat_hnext[1];
   4570 	old->nat_phnext[0] = (void *)nat->nat_phnext[0];
   4571 	old->nat_phnext[1] = (void *)nat->nat_phnext[1];
   4572 	old->nat_hm = nat->nat_hm;
   4573 	old->nat_data = nat->nat_data;
   4574 	old->nat_me = (void *)nat->nat_me;
   4575 	old->nat_state = nat->nat_state;
   4576 	old->nat_aps = nat->nat_aps;
   4577 	old->nat_fr = nat->nat_fr;
   4578 	old->nat_ptr = (void *)nat->nat_ptr;
   4579 	old->nat_ifps[0] = nat->nat_ifps[0];
   4580 	old->nat_ifps[1] = nat->nat_ifps[1];
   4581 	old->nat_sync = nat->nat_sync;
   4582 	old->nat_tqe = nat->nat_tqe;
   4583 	old->nat_flags = nat->nat_flags;
   4584 	old->nat_sumd[0] = nat->nat_sumd[0];
   4585 	old->nat_sumd[1] = nat->nat_sumd[1];
   4586 	old->nat_ipsumd = nat->nat_ipsumd;
   4587 	old->nat_mssclamp = nat->nat_mssclamp;
   4588 	old->nat_pkts[0] = nat->nat_pkts[0];
   4589 	old->nat_pkts[1] = nat->nat_pkts[1];
   4590 	old->nat_bytes[0] = nat->nat_bytes[0];
   4591 	old->nat_bytes[1] = nat->nat_bytes[1];
   4592 	old->nat_ref = nat->nat_ref;
   4593 	old->nat_dir = nat->nat_dir;
   4594 	old->nat_p = nat->nat_pr[0];
   4595 	old->nat_use = nat->nat_use;
   4596 	old->nat_hv[0] = nat->nat_hv[0];
   4597 	old->nat_hv[1] = nat->nat_hv[1];
   4598 	old->nat_rev = nat->nat_rev;
   4599 	old->nat_redir = nat->nat_redir;
   4600 	bcopy(nat->nat_ifnames[0], old->nat_ifnames[0], LIFNAMSIZ);
   4601 	bcopy(nat->nat_ifnames[1], old->nat_ifnames[1], LIFNAMSIZ);
   4602 
   4603 	if (nat->nat_redir == NAT_REDIRECT) {
   4604 		old->nat_inip6 = nat->nat_ndst6;
   4605 		old->nat_outip6 = nat->nat_odst6;
   4606 		old->nat_oip6 = nat->nat_osrc6;
   4607 		old->nat_un.nat_unt.ts_sport = nat->nat_ndport;
   4608 		old->nat_un.nat_unt.ts_dport = nat->nat_odport;
   4609 	} else {
   4610 		old->nat_inip6 = nat->nat_osrc6;
   4611 		old->nat_outip6 = nat->nat_nsrc6;
   4612 		old->nat_oip6 = nat->nat_odst6;
   4613 		old->nat_un.nat_unt.ts_sport = nat->nat_osport;
   4614 		old->nat_un.nat_unt.ts_dport = nat->nat_nsport;
   4615 	}
   4616 }
   4617 
   4618 
   4619 static void
   4620 nat_current_to_4_1_14(void *current, nat_4_1_14_t *old)
   4621 {
   4622 	nat_t *nat = (nat_t *)current;
   4623 
   4624 	old->nat_lock = nat->nat_lock;
   4625 	old->nat_next = nat->nat_next;
   4626 	old->nat_pnext = NULL;
   4627 	old->nat_hnext[0] = NULL;
   4628 	old->nat_hnext[1] = NULL;
   4629 	old->nat_phnext[0] = NULL;
   4630 	old->nat_phnext[1] = NULL;
   4631 	old->nat_hm = nat->nat_hm;
   4632 	old->nat_data = nat->nat_data;
   4633 	old->nat_me = (void *)nat->nat_me;
   4634 	old->nat_state = nat->nat_state;
   4635 	old->nat_aps = nat->nat_aps;
   4636 	old->nat_fr = nat->nat_fr;
   4637 	old->nat_ptr = nat->nat_ptr;
   4638 	old->nat_ifps[0] = nat->nat_ifps[0];
   4639 	old->nat_ifps[1] = nat->nat_ifps[1];
   4640 	old->nat_sync = nat->nat_sync;
   4641 	old->nat_tqe = nat->nat_tqe;
   4642 	old->nat_flags = nat->nat_flags;
   4643 	old->nat_sumd[0] = nat->nat_sumd[0];
   4644 	old->nat_sumd[1] = nat->nat_sumd[1];
   4645 	old->nat_ipsumd = nat->nat_ipsumd;
   4646 	old->nat_mssclamp = nat->nat_mssclamp;
   4647 	old->nat_pkts[0] = nat->nat_pkts[0];
   4648 	old->nat_pkts[1] = nat->nat_pkts[1];
   4649 	old->nat_bytes[0] = nat->nat_bytes[0];
   4650 	old->nat_bytes[1] = nat->nat_bytes[1];
   4651 	old->nat_ref = nat->nat_ref;
   4652 	old->nat_dir = nat->nat_dir;
   4653 	old->nat_p = nat->nat_pr[0];
   4654 	old->nat_use = nat->nat_use;
   4655 	old->nat_hv[0] = nat->nat_hv[0];
   4656 	old->nat_hv[1] = nat->nat_hv[1];
   4657 	old->nat_rev = nat->nat_rev;
   4658 	bcopy(nat->nat_ifnames[0], old->nat_ifnames[0], LIFNAMSIZ);
   4659 	bcopy(nat->nat_ifnames[1], old->nat_ifnames[1], LIFNAMSIZ);
   4660 
   4661 	if (nat->nat_redir == NAT_REDIRECT) {
   4662 		old->nat_inip6 = nat->nat_ndst6;
   4663 		old->nat_outip6 = nat->nat_odst6;
   4664 		old->nat_oip6 = nat->nat_osrc6;
   4665 		old->nat_un.nat_unt.ts_sport = nat->nat_ndport;
   4666 		old->nat_un.nat_unt.ts_dport = nat->nat_odport;
   4667 	} else {
   4668 		old->nat_inip6 = nat->nat_osrc6;
   4669 		old->nat_outip6 = nat->nat_nsrc6;
   4670 		old->nat_oip6 = nat->nat_odst6;
   4671 		old->nat_un.nat_unt.ts_sport = nat->nat_osport;
   4672 		old->nat_un.nat_unt.ts_dport = nat->nat_nsport;
   4673 	}
   4674 }
   4675 
   4676 
   4677 static void
   4678 nat_current_to_4_1_3(void *current, nat_4_1_3_t *old)
   4679 {
   4680 	nat_t *nat = (nat_t *)current;
   4681 
   4682 	old->nat_lock = nat->nat_lock;
   4683 	old->nat_next = nat->nat_next;
   4684 	old->nat_pnext = NULL;
   4685 	old->nat_hnext[0] = NULL;
   4686 	old->nat_hnext[1] = NULL;
   4687 	old->nat_phnext[0] = NULL;
   4688 	old->nat_phnext[1] = NULL;
   4689 	old->nat_hm = nat->nat_hm;
   4690 	old->nat_data = nat->nat_data;
   4691 	old->nat_me = (void *)nat->nat_me;
   4692 	old->nat_state = nat->nat_state;
   4693 	old->nat_aps = nat->nat_aps;
   4694 	old->nat_fr = nat->nat_fr;
   4695 	old->nat_ptr = nat->nat_ptr;
   4696 	old->nat_ifps[0] = nat->nat_ifps[0];
   4697 	old->nat_ifps[1] = nat->nat_ifps[1];
   4698 	old->nat_sync = nat->nat_sync;
   4699 	old->nat_tqe = nat->nat_tqe;
   4700 	old->nat_flags = nat->nat_flags;
   4701 	old->nat_sumd[0] = nat->nat_sumd[0];
   4702 	old->nat_sumd[1] = nat->nat_sumd[1];
   4703 	old->nat_ipsumd = nat->nat_ipsumd;
   4704 	old->nat_mssclamp = nat->nat_mssclamp;
   4705 	old->nat_pkts[0] = nat->nat_pkts[0];
   4706 	old->nat_pkts[1] = nat->nat_pkts[1];
   4707 	old->nat_bytes[0] = nat->nat_bytes[0];
   4708 	old->nat_bytes[1] = nat->nat_bytes[1];
   4709 	old->nat_ref = nat->nat_ref;
   4710 	old->nat_dir = nat->nat_dir;
   4711 	old->nat_p = nat->nat_pr[0];
   4712 	old->nat_use = nat->nat_use;
   4713 	old->nat_hv[0] = nat->nat_hv[0];
   4714 	old->nat_hv[1] = nat->nat_hv[1];
   4715 	old->nat_rev = nat->nat_rev;
   4716 	bcopy(nat->nat_ifnames[0], old->nat_ifnames[0], LIFNAMSIZ);
   4717 	bcopy(nat->nat_ifnames[1], old->nat_ifnames[1], LIFNAMSIZ);
   4718 
   4719 	if (nat->nat_redir == NAT_REDIRECT) {
   4720 		old->nat_inip6 = nat->nat_ndst6;
   4721 		old->nat_outip6 = nat->nat_odst6;
   4722 		old->nat_oip6 = nat->nat_osrc6;
   4723 		old->nat_un.nat_unt.ts_sport = nat->nat_ndport;
   4724 		old->nat_un.nat_unt.ts_dport = nat->nat_odport;
   4725 	} else {
   4726 		old->nat_inip6 = nat->nat_osrc6;
   4727 		old->nat_outip6 = nat->nat_nsrc6;
   4728 		old->nat_oip6 = nat->nat_odst6;
   4729 		old->nat_un.nat_unt.ts_sport = nat->nat_osport;
   4730 		old->nat_un.nat_unt.ts_dport = nat->nat_nsport;
   4731 	}
   4732 }
   4733 
   4734 #endif /* IPFILTER_COMPAT */
   4735