1254219Scy/* 2254219Scy * Copyright (C) 2002-2012 by Darren Reed. 3254219Scy * 4254219Scy * See the IPFILTER.LICENCE file for details on licencing. 5254219Scy */ 6254219Scy#if defined(KERNEL) || defined(_KERNEL) 7254219Scy# undef KERNEL 8254219Scy# undef _KERNEL 9254219Scy# define KERNEL 1 10254219Scy# define _KERNEL 1 11254219Scy#endif 12254219Scy#if defined(__osf__) 13254219Scy# define _PROTO_NET_H_ 14254219Scy#endif 15254219Scy#include <sys/param.h> 16254219Scy#include <sys/errno.h> 17254219Scy#include <sys/types.h> 18254219Scy#include <sys/time.h> 19254219Scy#include <sys/file.h> 20254219Scy#if __FreeBSD_version >= 220000 && defined(_KERNEL) 21254219Scy# include <sys/fcntl.h> 22254219Scy# include <sys/filio.h> 23254219Scy#else 24254219Scy# include <sys/ioctl.h> 25254219Scy#endif 26254219Scy#if !defined(_KERNEL) 27254219Scy# include <string.h> 28254219Scy# define _KERNEL 29254219Scy# ifdef __OpenBSD__ 30254219Scystruct file; 31254219Scy# endif 32254219Scy# include <sys/uio.h> 33254219Scy# undef _KERNEL 34254219Scy#endif 35254219Scy#include <sys/socket.h> 36254219Scy#if (defined(__osf__) || defined(AIX) || defined(__hpux) || defined(__sgi)) && defined(_KERNEL) 37254219Scy# include "radix_ipf_local.h" 38254219Scy# define _RADIX_H_ 39254219Scy#endif 40254219Scy#include <net/if.h> 41254219Scy#if defined(__FreeBSD__) 42254219Scy# include <sys/cdefs.h> 43254219Scy# include <sys/proc.h> 44254219Scy#endif 45254219Scy#if defined(_KERNEL) 46254219Scy# include <sys/systm.h> 47254219Scy# if !defined(__SVR4) && !defined(__svr4__) 48254219Scy# include <sys/mbuf.h> 49254219Scy# endif 50254219Scy#endif 51254219Scy#include <netinet/in.h> 52254219Scy 53254219Scy#include "netinet/ip_compat.h" 54254219Scy#include "netinet/ip_fil.h" 55254219Scy#include "netinet/ip_pool.h" 56254219Scy#include "netinet/ip_htable.h" 57254219Scy#include "netinet/ip_lookup.h" 58254219Scy#include "netinet/ip_nat.h" 59254219Scy#include "netinet/ip_state.h" 60254219Scy#include "netinet/ip_proxy.h" 61254219Scy#include "netinet/ip_auth.h" 62254219Scy/* END OF INCLUDES */ 63254219Scy 64254219Scy/* 65254219Scy * NetBSD has moved to 64bit time_t for all architectures. 66254219Scy * For some, such as sparc64, there is no change because long is already 67254219Scy * 64bit, but for others (i386), there is... 68254219Scy */ 69254219Scy#ifdef IPFILTER_COMPAT 70254219Scy 71254219Scy# ifdef __NetBSD__ 72254219Scytypedef struct timeval_l { 73254219Scy long tv_sec; 74254219Scy long tv_usec; 75254219Scy} timeval_l_t; 76254219Scy# endif 77254219Scy 78254219Scy/* ------------------------------------------------------------------------ */ 79254219Scy 80254219Scytypedef struct tcpinfo4 { 81254219Scy u_short ts_sport; 82254219Scy u_short ts_dport; 83254219Scy tcpdata_t ts_data[2]; 84254219Scy} tcpinfo4_t; 85254219Scy 86254219Scystatic void ipf_v5tcpinfoto4 __P((tcpinfo_t *, tcpinfo4_t *)); 87254219Scy 88254219Scystatic void 89254219Scyipf_v5tcpinfoto4(v5, v4) 90254219Scy tcpinfo_t *v5; 91254219Scy tcpinfo4_t *v4; 92254219Scy{ 93254219Scy v4->ts_sport = v5->ts_sport; 94254219Scy v4->ts_dport = v5->ts_dport; 95254219Scy v4->ts_data[0] = v5->ts_data[0]; 96254219Scy v4->ts_data[1] = v5->ts_data[1]; 97254219Scy} 98254219Scy 99254219Scytypedef struct fr_ip4 { 100254219Scy u_32_t fi_v:4; 101254219Scy u_32_t fi_xx:4; 102254219Scy u_32_t fi_tos:8; 103254219Scy u_32_t fi_ttl:8; 104254219Scy u_32_t fi_p:8; 105254219Scy u_32_t fi_optmsk; 106254219Scy i6addr_t fi_src; 107254219Scy i6addr_t fi_dst; 108254219Scy u_short ofi_secmsk; 109254219Scy u_short ofi_auth; 110254219Scy u_32_t fi_flx; 111254219Scy u_32_t fi_tcpmsk; 112254219Scy u_32_t fi_res1; 113254219Scy} frip4_t; 114254219Scy 115254219Scytypedef struct frpcmp4 { 116254219Scy int frp_cmp; 117254219Scy u_short frp_port; 118254219Scy u_short frp_top; 119254219Scy} frpcmp4_t; 120254219Scy 121254219Scytypedef struct frtuc4 { 122254219Scy u_char ftu_tcpfm; 123254219Scy u_char ftu_tcpf; 124254219Scy frpcmp4_t ftu_src; 125254219Scy frpcmp4_t ftu_dst; 126254219Scy} frtuc4_t; 127254219Scy 128254219Scytypedef struct fripf4 { 129254219Scy frip4_t fri_ip; 130254219Scy frip4_t fri_mip; 131254219Scy 132254219Scy u_short fri_icmpm; 133254219Scy u_short fri_icmp; 134254219Scy 135254219Scy frtuc4_t fri_tuc; 136254219Scy int fri_satype; 137254219Scy int fri_datype; 138254219Scy int fri_sifpidx; 139254219Scy int fri_difpidx; 140254219Scy} fripf4_t; 141254219Scy 142254219Scytypedef struct frdest_4 { 143254219Scy void *fd_ifp; 144254219Scy i6addr_t ofd_ip6; 145254219Scy char fd_ifname[LIFNAMSIZ]; 146254219Scy} frdest_4_t; 147254219Scy 148254219Scy/* ------------------------------------------------------------------------ */ 149254219Scy 150254219Scy/* 5.1.0 new release (current) 151254219Scy * 4.1.34 changed the size of the time structure used for pps 152254219Scy * 4.1.16 moved the location of fr_flineno 153254219Scy * 4.1.0 base version 154254219Scy */ 155254219Scytypedef struct frentry_4_1_34 { 156254219Scy ipfmutex_t fr_lock; 157254219Scy struct frentry *fr_next; 158254219Scy struct frentry **fr_grp; 159254219Scy struct ipscan *fr_isc; 160254219Scy void *fr_ifas[4]; 161254219Scy void *fr_ptr; /* for use with fr_arg */ 162254219Scy char *fr_comment; /* text comment for rule */ 163254219Scy int fr_ref; /* reference count - for grouping */ 164254219Scy int fr_statecnt; /* state count - for limit rules */ 165254219Scy int fr_flineno; /* line number from conf file */ 166254219Scy U_QUAD_T fr_hits; 167254219Scy U_QUAD_T fr_bytes; 168254219Scy union { 169254219Scy struct timeval frp_lastpkt; 170254219Scy char frp_bytes[12]; 171254219Scy } fr_lpu; 172254219Scy int fr_curpps; 173254219Scy union { 174254219Scy void *fru_data; 175254219Scy char *fru_caddr; 176254219Scy fripf4_t *fru_ipf; 177254219Scy frentfunc_t fru_func; 178254219Scy } fr_dun; 179254219Scy ipfunc_t fr_func; /* call this function */ 180254219Scy int fr_dsize; 181254219Scy int fr_pps; 182254219Scy int fr_statemax; /* max reference count */ 183254219Scy u_32_t fr_type; 184254219Scy u_32_t fr_flags; /* per-rule flags && options (see below) */ 185254219Scy u_32_t fr_logtag; /* user defined log tag # */ 186254219Scy u_32_t fr_collect; /* collection number */ 187254219Scy u_int fr_arg; /* misc. numeric arg for rule */ 188254219Scy u_int fr_loglevel; /* syslog log facility + priority */ 189254219Scy u_int fr_age[2]; /* non-TCP timeouts */ 190254219Scy u_char fr_v; 191254219Scy u_char fr_icode; /* return ICMP code */ 192254219Scy char fr_group[FR_GROUPLEN]; /* group to which this rule belongs */ 193254219Scy char fr_grhead[FR_GROUPLEN]; /* group # which this rule starts */ 194254219Scy ipftag_t fr_nattag; 195254219Scy char fr_ifnames[4][LIFNAMSIZ]; 196254219Scy char fr_isctag[16]; 197254219Scy frdest_4_t fr_tifs[2]; /* "to"/"reply-to" interface */ 198254219Scy frdest_4_t fr_dif; /* duplicate packet interface */ 199254219Scy u_int fr_cksum; /* checksum on filter rules for performance */ 200254219Scy} frentry_4_1_34_t; 201254219Scy 202254219Scytypedef struct frentry_4_1_16 { 203254219Scy ipfmutex_t fr_lock; 204254219Scy struct frentry *fr_next; 205254219Scy struct frentry **fr_grp; 206254219Scy struct ipscan *fr_isc; 207254219Scy void *fr_ifas[4]; 208254219Scy void *fr_ptr; 209254219Scy char *fr_comment; 210254219Scy int fr_ref; 211254219Scy int fr_statecnt; 212254219Scy int fr_flineno; 213254219Scy U_QUAD_T fr_hits; 214254219Scy U_QUAD_T fr_bytes; 215254219Scy union { 216254219Scy#ifdef __NetBSD__ 217254219Scy timeval_l_t frp_lastpkt; 218254219Scy#else 219254219Scy struct timeval frp_lastpkt; 220254219Scy#endif 221254219Scy } fr_lpu; 222254219Scy int fr_curpps; 223254219Scy union { 224254219Scy void *fru_data; 225254219Scy caddr_t fru_caddr; 226254219Scy fripf4_t *fru_ipf; 227254219Scy frentfunc_t fru_func; 228254219Scy } fr_dun; 229254219Scy ipfunc_t fr_func; 230254219Scy int fr_dsize; 231254219Scy int fr_pps; 232254219Scy int fr_statemax; 233254219Scy u_32_t fr_type; 234254219Scy u_32_t fr_flags; 235254219Scy u_32_t fr_logtag; 236254219Scy u_32_t fr_collect; 237254219Scy u_int fr_arg; 238254219Scy u_int fr_loglevel; 239254219Scy u_int fr_age[2]; 240254219Scy u_char fr_v; 241254219Scy u_char fr_icode; 242254219Scy char fr_group[FR_GROUPLEN]; 243254219Scy char fr_grhead[FR_GROUPLEN]; 244254219Scy ipftag_t fr_nattag; 245254219Scy char fr_ifnames[4][LIFNAMSIZ]; 246254219Scy char fr_isctag[16]; 247254219Scy frdest_4_t fr_tifs[2]; 248254219Scy frdest_4_t fr_dif; 249254219Scy u_int fr_cksum; 250254219Scy} frentry_4_1_16_t; 251254219Scy 252254219Scytypedef struct frentry_4_1_0 { 253254219Scy ipfmutex_t fr_lock; 254254219Scy struct frentry *fr_next; 255254219Scy struct frentry **fr_grp; 256254219Scy struct ipscan *fr_isc; 257254219Scy void *fr_ifas[4]; 258254219Scy void *fr_ptr; 259254219Scy char *fr_comment; 260254219Scy int fr_ref; 261254219Scy int fr_statecnt; 262254219Scy U_QUAD_T fr_hits; 263254219Scy U_QUAD_T fr_bytes; 264254219Scy union { 265254219Scy#ifdef __NetBSD__ 266254219Scy timeval_l_t frp_lastpkt; 267254219Scy#else 268254219Scy struct timeval frp_lastpkt; 269254219Scy#endif 270254219Scy } fr_lpu; 271254219Scy int fr_curpps; 272254219Scy 273254219Scy union { 274254219Scy void *fru_data; 275254219Scy caddr_t fru_caddr; 276254219Scy fripf4_t *fru_ipf; 277254219Scy frentfunc_t fru_func; 278254219Scy } fr_dun; 279254219Scy /* 280254219Scy * Fields after this may not change whilst in the kernel. 281254219Scy */ 282254219Scy ipfunc_t fr_func; 283254219Scy int fr_dsize; 284254219Scy int fr_pps; 285254219Scy int fr_statemax; 286254219Scy int fr_flineno; 287254219Scy u_32_t fr_type; 288254219Scy u_32_t fr_flags; 289254219Scy u_32_t fr_logtag; 290254219Scy u_32_t fr_collect; 291254219Scy u_int fr_arg; 292254219Scy u_int fr_loglevel; 293254219Scy u_int fr_age[2]; 294254219Scy u_char fr_v; 295254219Scy u_char fr_icode; 296254219Scy char fr_group[FR_GROUPLEN]; 297254219Scy char fr_grhead[FR_GROUPLEN]; 298254219Scy ipftag_t fr_nattag; 299254219Scy char fr_ifnames[4][LIFNAMSIZ]; 300254219Scy char fr_isctag[16]; 301254219Scy frdest_4_t fr_tifs[2]; 302254219Scy frdest_4_t fr_dif; 303254219Scy u_int fr_cksum; 304254219Scy} frentry_4_1_0_t; 305254219Scy 306254219Scy/* ------------------------------------------------------------------------ */ 307254219Scy 308254219Scy/* 309254219Scy * 5.1.0 new release (current) 310254219Scy * 4.1.32 removed both fin_state and fin_nat, added fin_pktnum 311254219Scy * 4.1.24 added fin_cksum 312254219Scy * 4.1.23 added fin_exthdr 313254219Scy * 4.1.11 added fin_ifname 314254219Scy * 4.1.4 added fin_hbuf 315254219Scy */ 316254219Scytypedef struct fr_info_4_1_32 { 317254219Scy void *fin_ifp; /* interface packet is `on' */ 318254219Scy frip4_t fin_fi; /* IP Packet summary */ 319254219Scy union { 320254219Scy u_short fid_16[2]; /* TCP/UDP ports, ICMP code/type */ 321254219Scy u_32_t fid_32; 322254219Scy } fin_dat; 323254219Scy int fin_out; /* in or out ? 1 == out, 0 == in */ 324254219Scy int fin_rev; /* state only: 1 = reverse */ 325254219Scy u_short fin_hlen; /* length of IP header in bytes */ 326254219Scy u_char ofin_tcpf; /* TCP header flags (SYN, ACK, etc) */ 327254219Scy u_char fin_icode; /* ICMP error to return */ 328254219Scy u_32_t fin_rule; /* rule # last matched */ 329254219Scy char fin_group[FR_GROUPLEN]; /* group number, -1 for none */ 330254219Scy struct frentry *fin_fr; /* last matching rule */ 331254219Scy void *fin_dp; /* start of data past IP header */ 332254219Scy int fin_dlen; /* length of data portion of packet */ 333254219Scy int fin_plen; 334254219Scy int fin_ipoff; /* # bytes from buffer start to hdr */ 335254219Scy u_short fin_id; /* IP packet id field */ 336254219Scy u_short fin_off; 337254219Scy int fin_depth; /* Group nesting depth */ 338254219Scy int fin_error; /* Error code to return */ 339254219Scy int fin_cksum; /* -1 bad, 1 good, 0 not done */ 340254219Scy u_int fin_pktnum; 341254219Scy void *fin_nattag; 342254219Scy void *fin_exthdr; 343254219Scy ip_t *ofin_ip; 344254219Scy mb_t **fin_mp; /* pointer to pointer to mbuf */ 345254219Scy mb_t *fin_m; /* pointer to mbuf */ 346254219Scy#ifdef MENTAT 347254219Scy mb_t *fin_qfm; /* pointer to mblk where pkt starts */ 348254219Scy void *fin_qpi; 349254219Scy char fin_ifname[LIFNAMSIZ]; 350254219Scy#endif 351254219Scy#ifdef __sgi 352254219Scy void *fin_hbuf; 353254219Scy#endif 354254219Scy} fr_info_4_1_32_t; 355254219Scy 356254219Scytypedef struct fr_info_4_1_24 { 357254219Scy void *fin_ifp; 358254219Scy frip4_t fin_fi; 359254219Scy union { 360254219Scy u_short fid_16[2]; 361254219Scy u_32_t fid_32; 362254219Scy } fin_dat; 363254219Scy int fin_out; 364254219Scy int fin_rev; 365254219Scy u_short fin_hlen; 366254219Scy u_char ofin_tcpf; 367254219Scy u_char fin_icode; 368254219Scy u_32_t fin_rule; 369254219Scy char fin_group[FR_GROUPLEN]; 370254219Scy struct frentry *fin_fr; 371254219Scy void *fin_dp; 372254219Scy int fin_dlen; 373254219Scy int fin_plen; 374254219Scy int fin_ipoff; 375254219Scy u_short fin_id; 376254219Scy u_short fin_off; 377254219Scy int fin_depth; 378254219Scy int fin_error; 379254219Scy int fin_cksum; 380254219Scy void *fin_state; 381254219Scy void *fin_nat; 382254219Scy void *fin_nattag; 383254219Scy void *fin_exthdr; 384254219Scy ip_t *ofin_ip; 385254219Scy mb_t **fin_mp; 386254219Scy mb_t *fin_m; 387254219Scy#ifdef MENTAT 388254219Scy mb_t *fin_qfm; 389254219Scy void *fin_qpi; 390254219Scy char fin_ifname[LIFNAMSIZ]; 391254219Scy#endif 392254219Scy#ifdef __sgi 393254219Scy void *fin_hbuf; 394254219Scy#endif 395254219Scy} fr_info_4_1_24_t; 396254219Scy 397254219Scytypedef struct fr_info_4_1_23 { 398254219Scy void *fin_ifp; 399254219Scy frip4_t fin_fi; 400254219Scy union { 401254219Scy u_short fid_16[2]; 402254219Scy u_32_t fid_32; 403254219Scy } fin_dat; 404254219Scy int fin_out; 405254219Scy int fin_rev; 406254219Scy u_short fin_hlen; 407254219Scy u_char ofin_tcpf; 408254219Scy u_char fin_icode; 409254219Scy u_32_t fin_rule; 410254219Scy char fin_group[FR_GROUPLEN]; 411254219Scy struct frentry *fin_fr; 412254219Scy void *fin_dp; 413254219Scy int fin_dlen; 414254219Scy int fin_plen; 415254219Scy int fin_ipoff; 416254219Scy u_short fin_id; 417254219Scy u_short fin_off; 418254219Scy int fin_depth; 419254219Scy int fin_error; 420254219Scy void *fin_state; 421254219Scy void *fin_nat; 422254219Scy void *fin_nattag; 423254219Scy void *fin_exthdr; 424254219Scy ip_t *ofin_ip; 425254219Scy mb_t **fin_mp; 426254219Scy mb_t *fin_m; 427254219Scy#ifdef MENTAT 428254219Scy mb_t *fin_qfm; 429254219Scy void *fin_qpi; 430254219Scy char fin_ifname[LIFNAMSIZ]; 431254219Scy#endif 432254219Scy#ifdef __sgi 433254219Scy void *fin_hbuf; 434254219Scy#endif 435254219Scy} fr_info_4_1_23_t; 436254219Scy 437254219Scytypedef struct fr_info_4_1_11 { 438254219Scy void *fin_ifp; 439254219Scy frip4_t fin_fi; 440254219Scy union { 441254219Scy u_short fid_16[2]; 442254219Scy u_32_t fid_32; 443254219Scy } fin_dat; 444254219Scy int fin_out; 445254219Scy int fin_rev; 446254219Scy u_short fin_hlen; 447254219Scy u_char ofin_tcpf; 448254219Scy u_char fin_icode; 449254219Scy u_32_t fin_rule; 450254219Scy char fin_group[FR_GROUPLEN]; 451254219Scy struct frentry *fin_fr; 452254219Scy void *fin_dp; 453254219Scy int fin_dlen; 454254219Scy int fin_plen; 455254219Scy int fin_ipoff; 456254219Scy u_short fin_id; 457254219Scy u_short fin_off; 458254219Scy int fin_depth; 459254219Scy int fin_error; 460254219Scy void *fin_state; 461254219Scy void *fin_nat; 462254219Scy void *fin_nattag; 463254219Scy ip_t *ofin_ip; 464254219Scy mb_t **fin_mp; 465254219Scy mb_t *fin_m; 466254219Scy#ifdef MENTAT 467254219Scy mb_t *fin_qfm; 468254219Scy void *fin_qpi; 469254219Scy char fin_ifname[LIFNAMSIZ]; 470254219Scy#endif 471254219Scy#ifdef __sgi 472254219Scy void *fin_hbuf; 473254219Scy#endif 474254219Scy} fr_info_4_1_11_t; 475254219Scy 476254219Scy/* ------------------------------------------------------------------------ */ 477254219Scy 478254219Scytypedef struct filterstats_4_1 { 479254219Scy u_long fr_pass; /* packets allowed */ 480254219Scy u_long fr_block; /* packets denied */ 481254219Scy u_long fr_nom; /* packets which don't match any rule */ 482254219Scy u_long fr_short; /* packets which are short */ 483254219Scy u_long fr_ppkl; /* packets allowed and logged */ 484254219Scy u_long fr_bpkl; /* packets denied and logged */ 485254219Scy u_long fr_npkl; /* packets unmatched and logged */ 486254219Scy u_long fr_pkl; /* packets logged */ 487254219Scy u_long fr_skip; /* packets to be logged but buffer full */ 488254219Scy u_long fr_ret; /* packets for which a return is sent */ 489254219Scy u_long fr_acct; /* packets for which counting was performed */ 490254219Scy u_long fr_bnfr; /* bad attempts to allocate fragment state */ 491254219Scy u_long fr_nfr; /* new fragment state kept */ 492254219Scy u_long fr_cfr; /* add new fragment state but complete pkt */ 493254219Scy u_long fr_bads; /* bad attempts to allocate packet state */ 494254219Scy u_long fr_ads; /* new packet state kept */ 495254219Scy u_long fr_chit; /* cached hit */ 496254219Scy u_long fr_tcpbad; /* TCP checksum check failures */ 497254219Scy u_long fr_pull[2]; /* good and bad pullup attempts */ 498254219Scy u_long fr_badsrc; /* source received doesn't match route */ 499254219Scy u_long fr_badttl; /* TTL in packet doesn't reach minimum */ 500254219Scy u_long fr_bad; /* bad IP packets to the filter */ 501254219Scy u_long fr_ipv6; /* IPv6 packets in/out */ 502254219Scy u_long fr_ppshit; /* dropped because of pps ceiling */ 503254219Scy u_long fr_ipud; /* IP id update failures */ 504254219Scy} filterstats_4_1_t; 505254219Scy 506254219Scy/* 507254219Scy * 5.1.0 new release (current) 508254219Scy * 4.1.33 changed the size of f_locks from IPL_LOGMAX to IPL_LOGSIZE 509254219Scy */ 510254219Scytypedef struct friostat_4_1_33 { 511254219Scy struct filterstats_4_1 of_st[2]; 512254219Scy struct frentry *f_ipf[2][2]; 513254219Scy struct frentry *f_acct[2][2]; 514254219Scy struct frentry *f_ipf6[2][2]; 515254219Scy struct frentry *f_acct6[2][2]; 516254219Scy struct frentry *f_auth; 517254219Scy struct frgroup *f_groups[IPL_LOGSIZE][2]; 518254219Scy u_long f_froute[2]; 519254219Scy u_long f_ticks; 520254219Scy int f_locks[IPL_LOGSIZE]; 521254219Scy size_t f_kmutex_sz; 522254219Scy size_t f_krwlock_sz; 523254219Scy int f_defpass; /* default pass - from fr_pass */ 524254219Scy int f_active; /* 1 or 0 - active rule set */ 525254219Scy int f_running; /* 1 if running, else 0 */ 526254219Scy int f_logging; /* 1 if enabled, else 0 */ 527254219Scy int f_features; 528254219Scy char f_version[32]; /* version string */ 529254219Scy} friostat_4_1_33_t; 530254219Scy 531254219Scytypedef struct friostat_4_1_0 { 532254219Scy struct filterstats_4_1 of_st[2]; 533254219Scy struct frentry *f_ipf[2][2]; 534254219Scy struct frentry *f_acct[2][2]; 535254219Scy struct frentry *f_ipf6[2][2]; 536254219Scy struct frentry *f_acct6[2][2]; 537254219Scy struct frentry *f_auth; 538254219Scy struct frgroup *f_groups[IPL_LOGSIZE][2]; 539254219Scy u_long f_froute[2]; 540254219Scy u_long f_ticks; 541254219Scy int f_locks[IPL_LOGMAX]; 542254219Scy size_t f_kmutex_sz; 543254219Scy size_t f_krwlock_sz; 544254219Scy int f_defpass; 545254219Scy int f_active; 546254219Scy int f_running; 547254219Scy int f_logging; 548254219Scy int f_features; 549254219Scy char f_version[32]; 550254219Scy} friostat_4_1_0_t; 551254219Scy 552254219Scy/* ------------------------------------------------------------------------ */ 553254219Scy 554254219Scy/* 555254219Scy * 5.1.0 new release (current) 556254219Scy * 4.1.14 added in_lock 557254219Scy */ 558254219Scytypedef struct ipnat_4_1_14 { 559254219Scy ipfmutex_t in_lock; 560254219Scy struct ipnat *in_next; /* NAT rule list next */ 561254219Scy struct ipnat *in_rnext; /* rdr rule hash next */ 562254219Scy struct ipnat **in_prnext; /* prior rdr next ptr */ 563254219Scy struct ipnat *in_mnext; /* map rule hash next */ 564254219Scy struct ipnat **in_pmnext; /* prior map next ptr */ 565254219Scy struct ipftq *in_tqehead[2]; 566254219Scy void *in_ifps[2]; 567254219Scy void *in_apr; 568254219Scy char *in_comment; 569254219Scy i6addr_t in_next6; 570254219Scy u_long in_space; 571254219Scy u_long in_hits; 572254219Scy u_int in_use; 573254219Scy u_int in_hv; 574254219Scy int in_flineno; /* conf. file line number */ 575254219Scy u_short in_pnext; 576254219Scy u_char in_v; 577254219Scy u_char in_xxx; 578254219Scy /* From here to the end is covered by IPN_CMPSIZ */ 579254219Scy u_32_t in_flags; 580254219Scy u_32_t in_mssclamp; /* if != 0 clamp MSS to this */ 581254219Scy u_int in_age[2]; 582254219Scy int in_redir; /* see below for values */ 583254219Scy int in_p; /* protocol. */ 584254219Scy i6addr_t in_in[2]; 585254219Scy i6addr_t in_out[2]; 586254219Scy i6addr_t in_src[2]; 587254219Scy frtuc4_t in_tuc; 588254219Scy u_short in_port[2]; 589254219Scy u_short in_ppip; /* ports per IP. */ 590254219Scy u_short in_ippip; /* IP #'s per IP# */ 591254219Scy char in_ifnames[2][LIFNAMSIZ]; 592254219Scy char in_plabel[APR_LABELLEN]; /* proxy label. */ 593254219Scy ipftag_t in_tag; 594254219Scy} ipnat_4_1_14_t; 595254219Scy 596254219Scytypedef struct ipnat_4_1_0 { 597254219Scy struct ipnat *in_next; 598254219Scy struct ipnat *in_rnext; 599254219Scy struct ipnat **in_prnext; 600254219Scy struct ipnat *in_mnext; 601254219Scy struct ipnat **in_pmnext; 602254219Scy struct ipftq *in_tqehead[2]; 603254219Scy void *in_ifps[2]; 604254219Scy void *in_apr; 605254219Scy char *in_comment; 606254219Scy i6addr_t in_next6; 607254219Scy u_long in_space; 608254219Scy u_long in_hits; 609254219Scy u_int in_use; 610254219Scy u_int in_hv; 611254219Scy int in_flineno; 612254219Scy u_short in_pnext; 613254219Scy u_char in_v; 614254219Scy u_char in_xxx; 615254219Scy u_32_t in_flags; 616254219Scy u_32_t in_mssclamp; 617254219Scy u_int in_age[2]; 618254219Scy int in_redir; 619254219Scy int in_p; 620254219Scy i6addr_t in_in[2]; 621254219Scy i6addr_t in_out[2]; 622254219Scy i6addr_t in_src[2]; 623254219Scy frtuc4_t in_tuc; 624254219Scy u_short in_port[2]; 625254219Scy u_short in_ppip; 626254219Scy u_short in_ippip; 627254219Scy char in_ifnames[2][LIFNAMSIZ]; 628254219Scy char in_plabel[APR_LABELLEN]; 629254219Scy ipftag_t in_tag; 630254219Scy} ipnat_4_1_0_t; 631254219Scy 632254219Scy/* ------------------------------------------------------------------------ */ 633254219Scy 634254219Scytypedef struct natlookup_4_1_1 { 635254219Scy struct in_addr onl_inip; 636254219Scy struct in_addr onl_outip; 637254219Scy struct in_addr onl_realip; 638254219Scy int nl_flags; 639254219Scy u_short nl_inport; 640254219Scy u_short nl_outport; 641254219Scy u_short nl_realport; 642254219Scy} natlookup_4_1_1_t; 643254219Scy 644254219Scy/* ------------------------------------------------------------------------ */ 645254219Scy 646254219Scy/* 647254219Scy * 4.1.25 added nat_seqnext (current) 648254219Scy * 4.1.14 added nat_redir 649254219Scy * 4.1.3 moved nat_rev 650254219Scy * 4.1.2 added nat_rev 651254219Scy */ 652254219Scytypedef struct nat_4_1_25 { 653254219Scy ipfmutex_t nat_lock; 654254219Scy struct nat_4_1_25 *nat_next; 655254219Scy struct nat_4_1_25 **nat_pnext; 656254219Scy struct nat_4_1_25 *nat_hnext[2]; 657254219Scy struct nat_4_1_25 **nat_phnext[2]; 658254219Scy struct hostmap *nat_hm; 659254219Scy void *nat_data; 660254219Scy struct nat_4_1_25 **nat_me; 661254219Scy struct ipstate *nat_state; 662254219Scy struct ap_session *nat_aps; 663254219Scy frentry_t *nat_fr; 664254219Scy struct ipnat_4_1_14 *nat_ptr; 665254219Scy void *nat_ifps[2]; 666254219Scy void *nat_sync; 667254219Scy ipftqent_t nat_tqe; 668254219Scy u_32_t nat_flags; 669254219Scy u_32_t nat_sumd[2]; 670254219Scy u_32_t nat_ipsumd; 671254219Scy u_32_t nat_mssclamp; 672254219Scy i6addr_t nat_inip6; 673254219Scy i6addr_t nat_outip6; 674254219Scy i6addr_t nat_oip6; 675254219Scy U_QUAD_T nat_pkts[2]; 676254219Scy U_QUAD_T nat_bytes[2]; 677254219Scy union { 678254219Scy udpinfo_t nat_unu; 679254219Scy tcpinfo4_t nat_unt; 680254219Scy icmpinfo_t nat_uni; 681254219Scy greinfo_t nat_ugre; 682254219Scy } nat_un; 683254219Scy u_short nat_oport; 684254219Scy u_short nat_use; 685254219Scy u_char nat_p; 686254219Scy int nat_dir; 687254219Scy int nat_ref; 688254219Scy int nat_hv[2]; 689254219Scy char nat_ifnames[2][LIFNAMSIZ]; 690254219Scy int nat_rev; 691254219Scy int nat_redir; 692254219Scy u_32_t nat_seqnext[2]; 693254219Scy} nat_4_1_25_t; 694254219Scy 695254219Scytypedef struct nat_4_1_14 { 696254219Scy ipfmutex_t nat_lock; 697254219Scy struct nat *nat_next; 698254219Scy struct nat **nat_pnext; 699254219Scy struct nat *nat_hnext[2]; 700254219Scy struct nat **nat_phnext[2]; 701254219Scy struct hostmap *nat_hm; 702254219Scy void *nat_data; 703254219Scy struct nat **nat_me; 704254219Scy struct ipstate *nat_state; 705254219Scy struct ap_session *nat_aps; 706254219Scy frentry_t *nat_fr; 707254219Scy struct ipnat *nat_ptr; 708254219Scy void *nat_ifps[2]; 709254219Scy void *nat_sync; 710254219Scy ipftqent_t nat_tqe; 711254219Scy u_32_t nat_flags; 712254219Scy u_32_t nat_sumd[2]; 713254219Scy u_32_t nat_ipsumd; 714254219Scy u_32_t nat_mssclamp; 715254219Scy i6addr_t nat_inip6; 716254219Scy i6addr_t nat_outip6; 717254219Scy i6addr_t nat_oip6; 718254219Scy U_QUAD_T nat_pkts[2]; 719254219Scy U_QUAD_T nat_bytes[2]; 720254219Scy union { 721254219Scy udpinfo_t nat_unu; 722254219Scy tcpinfo4_t nat_unt; 723254219Scy icmpinfo_t nat_uni; 724254219Scy greinfo_t nat_ugre; 725254219Scy } nat_un; 726254219Scy u_short nat_oport; 727254219Scy u_short nat_use; 728254219Scy u_char nat_p; 729254219Scy int nat_dir; 730254219Scy int nat_ref; 731254219Scy int nat_hv[2]; 732254219Scy char nat_ifnames[2][LIFNAMSIZ]; 733254219Scy int nat_rev; 734254219Scy int nat_redir; 735254219Scy} nat_4_1_14_t; 736254219Scy 737254219Scytypedef struct nat_4_1_3 { 738254219Scy ipfmutex_t nat_lock; 739254219Scy struct nat *nat_next; 740254219Scy struct nat **nat_pnext; 741254219Scy struct nat *nat_hnext[2]; 742254219Scy struct nat **nat_phnext[2]; 743254219Scy struct hostmap *nat_hm; 744254219Scy void *nat_data; 745254219Scy struct nat **nat_me; 746254219Scy struct ipstate *nat_state; 747254219Scy struct ap_session *nat_aps; 748254219Scy frentry_t *nat_fr; 749254219Scy struct ipnat *nat_ptr; 750254219Scy void *nat_ifps[2]; 751254219Scy void *nat_sync; 752254219Scy ipftqent_t nat_tqe; 753254219Scy u_32_t nat_flags; 754254219Scy u_32_t nat_sumd[2]; 755254219Scy u_32_t nat_ipsumd; 756254219Scy u_32_t nat_mssclamp; 757254219Scy i6addr_t nat_inip6; 758254219Scy i6addr_t nat_outip6; 759254219Scy i6addr_t nat_oip6; 760254219Scy U_QUAD_T nat_pkts[2]; 761254219Scy U_QUAD_T nat_bytes[2]; 762254219Scy union { 763254219Scy udpinfo_t nat_unu; 764254219Scy tcpinfo4_t nat_unt; 765254219Scy icmpinfo_t nat_uni; 766254219Scy greinfo_t nat_ugre; 767254219Scy } nat_un; 768254219Scy u_short nat_oport; 769254219Scy u_short nat_use; 770254219Scy u_char nat_p; 771254219Scy int nat_dir; 772254219Scy int nat_ref; 773254219Scy int nat_hv[2]; 774254219Scy char nat_ifnames[2][LIFNAMSIZ]; 775254219Scy int nat_rev; 776254219Scy} nat_4_1_3_t; 777254219Scy 778254219Scy 779254219Scy 780254219Scytypedef struct nat_save_4_1_34 { 781254219Scy void *ipn_next; 782254219Scy struct nat_4_1_25 ipn_nat; 783254219Scy struct ipnat_4_1_14 ipn_ipnat; 784254219Scy struct frentry_4_1_34 ipn_fr; 785254219Scy int ipn_dsize; 786254219Scy char ipn_data[4]; 787254219Scy} nat_save_4_1_34_t; 788254219Scy 789254219Scytypedef struct nat_save_4_1_16 { 790254219Scy void *ipn_next; 791254219Scy nat_4_1_14_t ipn_nat; 792254219Scy ipnat_t ipn_ipnat; 793254219Scy frentry_4_1_16_t ipn_fr; 794254219Scy int ipn_dsize; 795254219Scy char ipn_data[4]; 796254219Scy} nat_save_4_1_16_t; 797254219Scy 798254219Scytypedef struct nat_save_4_1_14 { 799254219Scy void *ipn_next; 800254219Scy nat_4_1_14_t ipn_nat; 801254219Scy ipnat_t ipn_ipnat; 802254219Scy frentry_4_1_0_t ipn_fr; 803254219Scy int ipn_dsize; 804254219Scy char ipn_data[4]; 805254219Scy} nat_save_4_1_14_t; 806254219Scy 807254219Scytypedef struct nat_save_4_1_3 { 808254219Scy void *ipn_next; 809254219Scy nat_4_1_3_t ipn_nat; 810254219Scy ipnat_4_1_0_t ipn_ipnat; 811254219Scy frentry_4_1_0_t ipn_fr; 812254219Scy int ipn_dsize; 813254219Scy char ipn_data[4]; 814254219Scy} nat_save_4_1_3_t; 815254219Scy 816254219Scy/* ------------------------------------------------------------------------ */ 817254219Scy 818254219Scy/* 819254219Scy * 5.1.0 new release (current) 820254219Scy * 4.1.32 added ns_uncreate 821254219Scy * 4.1.27 added ns_orphans 822254219Scy * 4.1.16 added ns_ticks 823254219Scy */ 824254219Scytypedef struct natstat_4_1_32 { 825254219Scy u_long ns_mapped[2]; 826254219Scy u_long ns_rules; 827254219Scy u_long ns_added; 828254219Scy u_long ns_expire; 829254219Scy u_long ns_inuse; 830254219Scy u_long ns_logged; 831254219Scy u_long ns_logfail; 832254219Scy u_long ns_memfail; 833254219Scy u_long ns_badnat; 834254219Scy u_long ns_addtrpnt; 835254219Scy nat_t **ns_table[2]; 836254219Scy hostmap_t **ns_maptable; 837254219Scy ipnat_t *ns_list; 838254219Scy void *ns_apslist; 839254219Scy u_int ns_wilds; 840254219Scy u_int ns_nattab_sz; 841254219Scy u_int ns_nattab_max; 842254219Scy u_int ns_rultab_sz; 843254219Scy u_int ns_rdrtab_sz; 844254219Scy u_int ns_trpntab_sz; 845254219Scy u_int ns_hostmap_sz; 846254219Scy nat_t *ns_instances; 847254219Scy hostmap_t *ns_maplist; 848254219Scy u_long *ns_bucketlen[2]; 849254219Scy u_long ns_ticks; 850254219Scy u_int ns_orphans; 851254219Scy u_long ns_uncreate[2][2]; 852254219Scy} natstat_4_1_32_t; 853254219Scy 854254219Scytypedef struct natstat_4_1_27 { 855254219Scy u_long ns_mapped[2]; 856254219Scy u_long ns_rules; 857254219Scy u_long ns_added; 858254219Scy u_long ns_expire; 859254219Scy u_long ns_inuse; 860254219Scy u_long ns_logged; 861254219Scy u_long ns_logfail; 862254219Scy u_long ns_memfail; 863254219Scy u_long ns_badnat; 864254219Scy u_long ns_addtrpnt; 865254219Scy nat_t **ns_table[2]; 866254219Scy hostmap_t **ns_maptable; 867254219Scy ipnat_t *ns_list; 868254219Scy void *ns_apslist; 869254219Scy u_int ns_wilds; 870254219Scy u_int ns_nattab_sz; 871254219Scy u_int ns_nattab_max; 872254219Scy u_int ns_rultab_sz; 873254219Scy u_int ns_rdrtab_sz; 874254219Scy u_int ns_trpntab_sz; 875254219Scy u_int ns_hostmap_sz; 876254219Scy nat_t *ns_instances; 877254219Scy hostmap_t *ns_maplist; 878254219Scy u_long *ns_bucketlen[2]; 879254219Scy u_long ns_ticks; 880254219Scy u_int ns_orphans; 881254219Scy} natstat_4_1_27_t; 882254219Scy 883254219Scytypedef struct natstat_4_1_16 { 884254219Scy u_long ns_mapped[2]; 885254219Scy u_long ns_rules; 886254219Scy u_long ns_added; 887254219Scy u_long ns_expire; 888254219Scy u_long ns_inuse; 889254219Scy u_long ns_logged; 890254219Scy u_long ns_logfail; 891254219Scy u_long ns_memfail; 892254219Scy u_long ns_badnat; 893254219Scy u_long ns_addtrpnt; 894254219Scy nat_t **ns_table[2]; 895254219Scy hostmap_t **ns_maptable; 896254219Scy ipnat_t *ns_list; 897254219Scy void *ns_apslist; 898254219Scy u_int ns_wilds; 899254219Scy u_int ns_nattab_sz; 900254219Scy u_int ns_nattab_max; 901254219Scy u_int ns_rultab_sz; 902254219Scy u_int ns_rdrtab_sz; 903254219Scy u_int ns_trpntab_sz; 904254219Scy u_int ns_hostmap_sz; 905254219Scy nat_t *ns_instances; 906254219Scy hostmap_t *ns_maplist; 907254219Scy u_long *ns_bucketlen[2]; 908254219Scy u_long ns_ticks; 909254219Scy} natstat_4_1_16_t; 910254219Scy 911254219Scytypedef struct natstat_4_1_0 { 912254219Scy u_long ns_mapped[2]; 913254219Scy u_long ns_rules; 914254219Scy u_long ns_added; 915254219Scy u_long ns_expire; 916254219Scy u_long ns_inuse; 917254219Scy u_long ns_logged; 918254219Scy u_long ns_logfail; 919254219Scy u_long ns_memfail; 920254219Scy u_long ns_badnat; 921254219Scy u_long ns_addtrpnt; 922254219Scy nat_t **ns_table[2]; 923254219Scy hostmap_t **ns_maptable; 924254219Scy ipnat_t *ns_list; 925254219Scy void *ns_apslist; 926254219Scy u_int ns_wilds; 927254219Scy u_int ns_nattab_sz; 928254219Scy u_int ns_nattab_max; 929254219Scy u_int ns_rultab_sz; 930254219Scy u_int ns_rdrtab_sz; 931254219Scy u_int ns_trpntab_sz; 932254219Scy u_int ns_hostmap_sz; 933254219Scy nat_t *ns_instances; 934254219Scy hostmap_t *ns_maplist; 935254219Scy u_long *ns_bucketlen[2]; 936254219Scy} natstat_4_1_0_t; 937254219Scy 938254219Scy/* ------------------------------------------------------------------------ */ 939254219Scy 940254219Scy/* 941254219Scy * 5.1.0 new release (current) 942254219Scy * 4.1.32 fra_info:removed both fin_state & fin_nat, added fin_pktnum 943254219Scy * 4.1.29 added fra_flx 944254219Scy * 4.1.24 fra_info:added fin_cksum 945254219Scy * 4.1.23 fra_info:added fin_exthdr 946254219Scy * 4.1.11 fra_info:added fin_ifname 947254219Scy * 4.1.4 fra_info:added fin_hbuf 948254219Scy */ 949254219Scy 950254219Scytypedef struct frauth_4_1_32 { 951254219Scy int fra_age; 952254219Scy int fra_len; 953254219Scy int fra_index; 954254219Scy u_32_t fra_pass; 955254219Scy fr_info_4_1_32_t fra_info; 956254219Scy char *fra_buf; 957254219Scy u_32_t fra_flx; 958254219Scy#ifdef MENTAT 959254219Scy queue_t *fra_q; 960254219Scy mb_t *fra_m; 961254219Scy#endif 962254219Scy} frauth_4_1_32_t; 963254219Scy 964254219Scytypedef struct frauth_4_1_29 { 965254219Scy int fra_age; 966254219Scy int fra_len; 967254219Scy int fra_index; 968254219Scy u_32_t fra_pass; 969254219Scy fr_info_4_1_24_t fra_info; 970254219Scy char *fra_buf; 971254219Scy u_32_t fra_flx; 972254219Scy#ifdef MENTAT 973254219Scy queue_t *fra_q; 974254219Scy mb_t *fra_m; 975254219Scy#endif 976254219Scy} frauth_4_1_29_t; 977254219Scy 978254219Scytypedef struct frauth_4_1_24 { 979254219Scy int fra_age; 980254219Scy int fra_len; 981254219Scy int fra_index; 982254219Scy u_32_t fra_pass; 983254219Scy fr_info_4_1_24_t fra_info; 984254219Scy char *fra_buf; 985254219Scy#ifdef MENTAT 986254219Scy queue_t *fra_q; 987254219Scy mb_t *fra_m; 988254219Scy#endif 989254219Scy} frauth_4_1_24_t; 990254219Scy 991254219Scytypedef struct frauth_4_1_23 { 992254219Scy int fra_age; 993254219Scy int fra_len; 994254219Scy int fra_index; 995254219Scy u_32_t fra_pass; 996254219Scy fr_info_4_1_23_t fra_info; 997254219Scy char *fra_buf; 998254219Scy#ifdef MENTAT 999254219Scy queue_t *fra_q; 1000254219Scy mb_t *fra_m; 1001254219Scy#endif 1002254219Scy} frauth_4_1_23_t; 1003254219Scy 1004254219Scytypedef struct frauth_4_1_11 { 1005254219Scy int fra_age; 1006254219Scy int fra_len; 1007254219Scy int fra_index; 1008254219Scy u_32_t fra_pass; 1009254219Scy fr_info_4_1_11_t fra_info; 1010254219Scy char *fra_buf; 1011254219Scy#ifdef MENTAT 1012254219Scy queue_t *fra_q; 1013254219Scy mb_t *fra_m; 1014254219Scy#endif 1015254219Scy} frauth_4_1_11_t; 1016254219Scy 1017254219Scy/* ------------------------------------------------------------------------ */ 1018254219Scy 1019254219Scy/* 1020254219Scy * 5.1.0 new release (current) 1021254219Scy * 4.1.16 removed is_nat 1022254219Scy */ 1023254219Scytypedef struct ipstate_4_1_16 { 1024254219Scy ipfmutex_t is_lock; 1025254219Scy struct ipstate *is_next; 1026254219Scy struct ipstate **is_pnext; 1027254219Scy struct ipstate *is_hnext; 1028254219Scy struct ipstate **is_phnext; 1029254219Scy struct ipstate **is_me; 1030254219Scy void *is_ifp[4]; 1031254219Scy void *is_sync; 1032254219Scy frentry_t *is_rule; 1033254219Scy struct ipftq *is_tqehead[2]; 1034254219Scy struct ipscan *is_isc; 1035254219Scy U_QUAD_T is_pkts[4]; 1036254219Scy U_QUAD_T is_bytes[4]; 1037254219Scy U_QUAD_T is_icmppkts[4]; 1038254219Scy struct ipftqent is_sti; 1039254219Scy u_int is_frage[2]; 1040254219Scy int is_ref; /* reference count */ 1041254219Scy int is_isninc[2]; 1042254219Scy u_short is_sumd[2]; 1043254219Scy i6addr_t is_src; 1044254219Scy i6addr_t is_dst; 1045254219Scy u_int is_pass; 1046254219Scy u_char is_p; /* Protocol */ 1047254219Scy u_char is_v; 1048254219Scy u_32_t is_hv; 1049254219Scy u_32_t is_tag; 1050254219Scy u_32_t is_opt[2]; /* packet options set */ 1051254219Scy u_32_t is_optmsk[2]; /* " " mask */ 1052254219Scy u_short is_sec; /* security options set */ 1053254219Scy u_short is_secmsk; /* " " mask */ 1054254219Scy u_short is_auth; /* authentication options set */ 1055254219Scy u_short is_authmsk; /* " " mask */ 1056254219Scy union { 1057254219Scy icmpinfo_t is_ics; 1058254219Scy tcpinfo4_t is_ts; 1059254219Scy udpinfo_t is_us; 1060254219Scy greinfo_t is_ug; 1061254219Scy } is_ps; 1062254219Scy u_32_t is_flags; 1063254219Scy int is_flx[2][2]; 1064254219Scy u_32_t is_rulen; /* rule number when created */ 1065254219Scy u_32_t is_s0[2]; 1066254219Scy u_short is_smsk[2]; 1067254219Scy char is_group[FR_GROUPLEN]; 1068254219Scy char is_sbuf[2][16]; 1069254219Scy char is_ifname[4][LIFNAMSIZ]; 1070254219Scy} ipstate_4_1_16_t; 1071254219Scy 1072254219Scytypedef struct ipstate_4_1_0 { 1073254219Scy ipfmutex_t is_lock; 1074254219Scy struct ipstate *is_next; 1075254219Scy struct ipstate **is_pnext; 1076254219Scy struct ipstate *is_hnext; 1077254219Scy struct ipstate **is_phnext; 1078254219Scy struct ipstate **is_me; 1079254219Scy void *is_ifp[4]; 1080254219Scy void *is_sync; 1081254219Scy void *is_nat[2]; 1082254219Scy frentry_t *is_rule; 1083254219Scy struct ipftq *is_tqehead[2]; 1084254219Scy struct ipscan *is_isc; 1085254219Scy U_QUAD_T is_pkts[4]; 1086254219Scy U_QUAD_T is_bytes[4]; 1087254219Scy U_QUAD_T is_icmppkts[4]; 1088254219Scy struct ipftqent is_sti; 1089254219Scy u_int is_frage[2]; 1090254219Scy int is_ref; 1091254219Scy int is_isninc[2]; 1092254219Scy u_short is_sumd[2]; 1093254219Scy i6addr_t is_src; 1094254219Scy i6addr_t is_dst; 1095254219Scy u_int is_pass; 1096254219Scy u_char is_p; 1097254219Scy u_char is_v; 1098254219Scy u_32_t is_hv; 1099254219Scy u_32_t is_tag; 1100254219Scy u_32_t is_opt[2]; 1101254219Scy u_32_t is_optmsk[2]; 1102254219Scy u_short is_sec; 1103254219Scy u_short is_secmsk; 1104254219Scy u_short is_auth; 1105254219Scy u_short is_authmsk; 1106254219Scy union { 1107254219Scy icmpinfo_t is_ics; 1108254219Scy tcpinfo4_t is_ts; 1109254219Scy udpinfo_t is_us; 1110254219Scy greinfo_t is_ug; 1111254219Scy } is_ps; 1112254219Scy u_32_t is_flags; 1113254219Scy int is_flx[2][2]; 1114254219Scy u_32_t is_rulen; 1115254219Scy u_32_t is_s0[2]; 1116254219Scy u_short is_smsk[2]; 1117254219Scy char is_group[FR_GROUPLEN]; 1118254219Scy char is_sbuf[2][16]; 1119254219Scy char is_ifname[4][LIFNAMSIZ]; 1120254219Scy} ipstate_4_1_0_t; 1121254219Scy 1122254219Scytypedef struct ipstate_save_4_1_34 { 1123254219Scy void *ips_next; 1124254219Scy struct ipstate_4_1_16 ips_is; 1125254219Scy struct frentry_4_1_34 ips_fr; 1126254219Scy} ipstate_save_4_1_34_t; 1127254219Scy 1128254219Scytypedef struct ipstate_save_4_1_16 { 1129254219Scy void *ips_next; 1130254219Scy ipstate_4_1_0_t ips_is; 1131254219Scy frentry_4_1_16_t ips_fr; 1132254219Scy} ipstate_save_4_1_16_t; 1133254219Scy 1134254219Scytypedef struct ipstate_save_4_1_0 { 1135254219Scy void *ips_next; 1136254219Scy ipstate_4_1_0_t ips_is; 1137254219Scy frentry_4_1_0_t ips_fr; 1138254219Scy} ipstate_save_4_1_0_t; 1139254219Scy 1140254219Scy/* ------------------------------------------------------------------------ */ 1141254219Scy 1142254219Scy/* 1143254219Scy * 5.1.0 new release (current) 1144254219Scy * 4.1.21 added iss_tcptab 1145254219Scy */ 1146254219Scytypedef struct ips_stat_4_1_21 { 1147254219Scy u_long iss_hits; 1148254219Scy u_long iss_miss; 1149254219Scy u_long iss_max; 1150254219Scy u_long iss_maxref; 1151254219Scy u_long iss_tcp; 1152254219Scy u_long iss_udp; 1153254219Scy u_long iss_icmp; 1154254219Scy u_long iss_nomem; 1155254219Scy u_long iss_expire; 1156254219Scy u_long iss_fin; 1157254219Scy u_long iss_active; 1158254219Scy u_long iss_logged; 1159254219Scy u_long iss_logfail; 1160254219Scy u_long iss_inuse; 1161254219Scy u_long iss_wild; 1162254219Scy u_long iss_killed; 1163254219Scy u_long iss_ticks; 1164254219Scy u_long iss_bucketfull; 1165254219Scy int iss_statesize; 1166254219Scy int iss_statemax; 1167254219Scy ipstate_t **iss_table; 1168254219Scy ipstate_t *iss_list; 1169254219Scy u_long *iss_bucketlen; 1170254219Scy ipftq_t *iss_tcptab; 1171254219Scy} ips_stat_4_1_21_t; 1172254219Scy 1173254219Scytypedef struct ips_stat_4_1_0 { 1174254219Scy u_long iss_hits; 1175254219Scy u_long iss_miss; 1176254219Scy u_long iss_max; 1177254219Scy u_long iss_maxref; 1178254219Scy u_long iss_tcp; 1179254219Scy u_long iss_udp; 1180254219Scy u_long iss_icmp; 1181254219Scy u_long iss_nomem; 1182254219Scy u_long iss_expire; 1183254219Scy u_long iss_fin; 1184254219Scy u_long iss_active; 1185254219Scy u_long iss_logged; 1186254219Scy u_long iss_logfail; 1187254219Scy u_long iss_inuse; 1188254219Scy u_long iss_wild; 1189254219Scy u_long iss_killed; 1190254219Scy u_long iss_ticks; 1191254219Scy u_long iss_bucketfull; 1192254219Scy int iss_statesize; 1193254219Scy int iss_statemax; 1194254219Scy ipstate_t **iss_table; 1195254219Scy ipstate_t *iss_list; 1196254219Scy u_long *iss_bucketlen; 1197254219Scy} ips_stat_4_1_0_t; 1198254219Scy 1199254219Scy/* ------------------------------------------------------------------------ */ 1200254219Scy 1201254219Scytypedef struct ipfrstat_4_1_1 { 1202254219Scy u_long ifs_exists; /* add & already exists */ 1203254219Scy u_long ifs_nomem; 1204254219Scy u_long ifs_new; 1205254219Scy u_long ifs_hits; 1206254219Scy u_long ifs_expire; 1207254219Scy u_long ifs_inuse; 1208254219Scy u_long ifs_retrans0; 1209254219Scy u_long ifs_short; 1210254219Scy struct ipfr **ifs_table; 1211254219Scy struct ipfr **ifs_nattab; 1212254219Scy} ipfrstat_4_1_1_t; 1213254219Scy 1214254219Scy/* ------------------------------------------------------------------------ */ 1215254219Scystatic int ipf_addfrstr __P((char *, int, char *, int)); 1216254219Scystatic void ipf_v4iptov5 __P((frip4_t *, fr_ip_t *)); 1217254219Scystatic void ipf_v5iptov4 __P((fr_ip_t *, frip4_t *)); 1218254219Scystatic void ipfv4tuctov5 __P((frtuc4_t *, frtuc_t *)); 1219254219Scystatic void ipfv5tuctov4 __P((frtuc_t *, frtuc4_t *)); 1220254219Scystatic int ipf_v4fripftov5 __P((fripf4_t *, char *)); 1221254219Scystatic void ipf_v5fripftov4 __P((fripf_t *, fripf4_t *)); 1222254219Scystatic int fr_frflags4to5 __P((u_32_t)); 1223254219Scystatic int fr_frflags5to4 __P((u_32_t)); 1224254219Scy 1225254219Scystatic void friostat_current_to_4_1_0 __P((void *, friostat_4_1_0_t *, int)); 1226254219Scystatic void friostat_current_to_4_1_33 __P((void *, friostat_4_1_33_t *, int)); 1227254219Scystatic void ipstate_current_to_4_1_0 __P((void *, ipstate_4_1_0_t *)); 1228254219Scystatic void ipstate_current_to_4_1_16 __P((void *, ipstate_4_1_16_t *)); 1229254219Scystatic void ipnat_current_to_4_1_0 __P((void *, ipnat_4_1_0_t *)); 1230254219Scystatic void ipnat_current_to_4_1_14 __P((void *, ipnat_4_1_14_t *)); 1231254219Scystatic void frauth_current_to_4_1_11 __P((void *, frauth_4_1_11_t *)); 1232254219Scystatic void frauth_current_to_4_1_23 __P((void *, frauth_4_1_23_t *)); 1233254219Scystatic void frauth_current_to_4_1_24 __P((void *, frauth_4_1_24_t *)); 1234254219Scystatic void frauth_current_to_4_1_29 __P((void *, frauth_4_1_29_t *)); 1235254219Scystatic void frentry_current_to_4_1_0 __P((void *, frentry_4_1_0_t *)); 1236254219Scystatic void frentry_current_to_4_1_16 __P((void *, frentry_4_1_16_t *)); 1237254219Scystatic void frentry_current_to_4_1_34 __P((void *, frentry_4_1_34_t *)); 1238254219Scystatic void fr_info_current_to_4_1_11 __P((void *, fr_info_4_1_11_t *)); 1239254219Scystatic void fr_info_current_to_4_1_23 __P((void *, fr_info_4_1_23_t *)); 1240254219Scystatic void fr_info_current_to_4_1_24 __P((void *, fr_info_4_1_24_t *)); 1241254219Scystatic void nat_save_current_to_4_1_3 __P((void *, nat_save_4_1_3_t *)); 1242254219Scystatic void nat_save_current_to_4_1_14 __P((void *, nat_save_4_1_14_t *)); 1243254219Scystatic void nat_save_current_to_4_1_16 __P((void *, nat_save_4_1_16_t *)); 1244254219Scystatic void ipstate_save_current_to_4_1_0 __P((void *, ipstate_save_4_1_0_t *)); 1245254219Scystatic void ipstate_save_current_to_4_1_16 __P((void *, ipstate_save_4_1_16_t *)); 1246254219Scystatic void ips_stat_current_to_4_1_0 __P((void *, ips_stat_4_1_0_t *)); 1247254219Scystatic void ips_stat_current_to_4_1_21 __P((void *, ips_stat_4_1_21_t *)); 1248254219Scystatic void natstat_current_to_4_1_0 __P((void *, natstat_4_1_0_t *)); 1249254219Scystatic void natstat_current_to_4_1_16 __P((void *, natstat_4_1_16_t *)); 1250254219Scystatic void natstat_current_to_4_1_27 __P((void *, natstat_4_1_27_t *)); 1251254219Scystatic void natstat_current_to_4_1_32 __P((void *, natstat_4_1_32_t *)); 1252254219Scystatic void nat_current_to_4_1_3 __P((void *, nat_4_1_3_t *)); 1253254219Scystatic void nat_current_to_4_1_14 __P((void *, nat_4_1_14_t *)); 1254254219Scystatic void nat_current_to_4_1_25 __P((void *, nat_4_1_25_t *)); 1255254219Scy 1256254219Scystatic void friostat_4_1_0_to_current __P((friostat_4_1_0_t *, void *)); 1257254219Scystatic void friostat_4_1_33_to_current __P((friostat_4_1_33_t *, void *)); 1258254219Scystatic void ipnat_4_1_0_to_current __P((ipnat_4_1_0_t *, void *, int)); 1259254219Scystatic void ipnat_4_1_14_to_current __P((ipnat_4_1_14_t *, void *, int)); 1260254219Scystatic void frauth_4_1_11_to_current __P((frauth_4_1_11_t *, void *)); 1261254219Scystatic void frauth_4_1_23_to_current __P((frauth_4_1_23_t *, void *)); 1262254219Scystatic void frauth_4_1_24_to_current __P((frauth_4_1_24_t *, void *)); 1263254219Scystatic void frauth_4_1_29_to_current __P((frauth_4_1_29_t *, void *)); 1264254219Scystatic void frauth_4_1_32_to_current __P((frauth_4_1_32_t *, void *)); 1265254219Scystatic void frentry_4_1_0_to_current __P((ipf_main_softc_t *, frentry_4_1_0_t *, void *, int)); 1266254219Scystatic void frentry_4_1_16_to_current __P((ipf_main_softc_t *, frentry_4_1_16_t *, void *, int)); 1267254219Scystatic void frentry_4_1_34_to_current __P((ipf_main_softc_t *, frentry_4_1_34_t *, void *, int)); 1268254219Scystatic void fr_info_4_1_11_to_current __P((fr_info_4_1_11_t *, void *)); 1269254219Scystatic void fr_info_4_1_23_to_current __P((fr_info_4_1_23_t *, void *)); 1270254219Scystatic void fr_info_4_1_24_to_current __P((fr_info_4_1_24_t *, void *)); 1271254219Scystatic void fr_info_4_1_32_to_current __P((fr_info_4_1_32_t *, void *)); 1272254219Scystatic void nat_save_4_1_3_to_current __P((ipf_main_softc_t *, nat_save_4_1_3_t *, void *)); 1273254219Scystatic void nat_save_4_1_14_to_current __P((ipf_main_softc_t *, nat_save_4_1_14_t *, void *)); 1274254219Scystatic void nat_save_4_1_16_to_current __P((ipf_main_softc_t *, nat_save_4_1_16_t *, void *)); 1275254219Scy 1276254219Scy/* ------------------------------------------------------------------------ */ 1277254219Scy/* In this section is a series of short routines that deal with translating */ 1278254219Scy/* the smaller data structures used above as their internal changes make */ 1279254219Scy/* them inappropriate for simple assignment. */ 1280254219Scy/* ------------------------------------------------------------------------ */ 1281254219Scy 1282254219Scy 1283254219Scystatic int 1284254219Scyipf_addfrstr(char *names, int namelen, char *str, int maxlen) 1285254219Scy{ 1286254219Scy char *t; 1287254219Scy int i; 1288254219Scy 1289254219Scy for (i = maxlen, t = str; (*t != '\0') && (i > 0); i--) { 1290254219Scy names[namelen++] = *t++; 1291254219Scy } 1292254219Scy names[namelen++] = '\0'; 1293254219Scy return namelen; 1294254219Scy} 1295254219Scy 1296254219Scy 1297254219Scystatic void 1298254219Scyipf_v4iptov5(v4, v5) 1299254219Scy frip4_t *v4; 1300254219Scy fr_ip_t *v5; 1301254219Scy{ 1302254219Scy v5->fi_v = v4->fi_v; 1303254219Scy v5->fi_p = v4->fi_p; 1304254219Scy v5->fi_xx = v4->fi_xx; 1305254219Scy v5->fi_tos = v4->fi_tos; 1306254219Scy v5->fi_ttl = v4->fi_ttl; 1307254219Scy v5->fi_p = v4->fi_p; 1308254219Scy v5->fi_optmsk = v4->fi_optmsk; 1309254219Scy v5->fi_src = v4->fi_src; 1310254219Scy v5->fi_dst = v4->fi_dst; 1311254219Scy v5->fi_secmsk = v4->ofi_secmsk; 1312254219Scy v5->fi_auth = v4->ofi_auth; 1313254219Scy v5->fi_flx = v4->fi_flx; 1314254219Scy v5->fi_tcpmsk = v4->fi_tcpmsk; 1315254219Scy} 1316254219Scy 1317254219Scystatic void 1318254219Scyipf_v5iptov4(v5, v4) 1319254219Scy fr_ip_t *v5; 1320254219Scy frip4_t *v4; 1321254219Scy{ 1322254219Scy v4->fi_v = v5->fi_v; 1323254219Scy v4->fi_p = v5->fi_p; 1324254219Scy v4->fi_xx = v5->fi_xx; 1325254219Scy v4->fi_tos = v5->fi_tos; 1326254219Scy v4->fi_ttl = v5->fi_ttl; 1327254219Scy v4->fi_p = v5->fi_p; 1328254219Scy v4->fi_optmsk = v5->fi_optmsk; 1329254219Scy v4->fi_src = v5->fi_src; 1330254219Scy v4->fi_dst = v5->fi_dst; 1331254219Scy v4->ofi_secmsk = v5->fi_secmsk; 1332254219Scy v4->ofi_auth = v5->fi_auth; 1333254219Scy v4->fi_flx = v5->fi_flx; 1334254219Scy v4->fi_tcpmsk = v5->fi_tcpmsk; 1335254219Scy} 1336254219Scy 1337254219Scy 1338254219Scystatic void 1339254219Scyipfv4tuctov5(v4, v5) 1340254219Scy frtuc4_t *v4; 1341254219Scy frtuc_t *v5; 1342254219Scy{ 1343254219Scy v5->ftu_src.frp_cmp = v4->ftu_src.frp_cmp; 1344254219Scy v5->ftu_src.frp_port = v4->ftu_src.frp_port; 1345254219Scy v5->ftu_src.frp_top = v4->ftu_src.frp_top; 1346254219Scy v5->ftu_dst.frp_cmp = v4->ftu_dst.frp_cmp; 1347254219Scy v5->ftu_dst.frp_port = v4->ftu_dst.frp_port; 1348254219Scy v5->ftu_dst.frp_top = v4->ftu_dst.frp_top; 1349254219Scy} 1350254219Scy 1351254219Scy 1352254219Scystatic void 1353254219Scyipfv5tuctov4(v5, v4) 1354254219Scy frtuc_t *v5; 1355254219Scy frtuc4_t *v4; 1356254219Scy{ 1357254219Scy v4->ftu_src.frp_cmp = v5->ftu_src.frp_cmp; 1358254219Scy v4->ftu_src.frp_port = v5->ftu_src.frp_port; 1359254219Scy v4->ftu_src.frp_top = v5->ftu_src.frp_top; 1360254219Scy v4->ftu_dst.frp_cmp = v5->ftu_dst.frp_cmp; 1361254219Scy v4->ftu_dst.frp_port = v5->ftu_dst.frp_port; 1362254219Scy v4->ftu_dst.frp_top = v5->ftu_dst.frp_top; 1363254219Scy} 1364254219Scy 1365254219Scy 1366254219Scystatic int 1367254219Scyipf_v4fripftov5(frp4, dst) 1368254219Scy fripf4_t *frp4; 1369254219Scy char *dst; 1370254219Scy{ 1371254219Scy fripf_t *frp; 1372254219Scy 1373254219Scy frp = (fripf_t *)dst; 1374254219Scy 1375254219Scy ipf_v4iptov5(&frp4->fri_ip, &frp->fri_ip); 1376254219Scy ipf_v4iptov5(&frp4->fri_mip, &frp->fri_mip); 1377254219Scy frp->fri_icmpm = frp4->fri_icmpm; 1378254219Scy frp->fri_icmp = frp4->fri_icmp; 1379254219Scy frp->fri_tuc.ftu_tcpfm = frp4->fri_tuc.ftu_tcpfm; 1380254219Scy frp->fri_tuc.ftu_tcpf = frp4->fri_tuc.ftu_tcpf; 1381254219Scy ipfv4tuctov5(&frp4->fri_tuc, &frp->fri_tuc); 1382254219Scy frp->fri_satype = frp4->fri_satype; 1383254219Scy frp->fri_datype = frp4->fri_datype; 1384254219Scy frp->fri_sifpidx = frp4->fri_sifpidx; 1385254219Scy frp->fri_difpidx = frp4->fri_difpidx; 1386254219Scy return 0; 1387254219Scy} 1388254219Scy 1389254219Scy 1390254219Scystatic void 1391254219Scyipf_v5fripftov4(frp, frp4) 1392254219Scy fripf_t *frp; 1393254219Scy fripf4_t *frp4; 1394254219Scy{ 1395254219Scy 1396254219Scy ipf_v5iptov4(&frp->fri_ip, &frp4->fri_ip); 1397254219Scy ipf_v5iptov4(&frp->fri_mip, &frp4->fri_mip); 1398254219Scy frp4->fri_icmpm = frp->fri_icmpm; 1399254219Scy frp4->fri_icmp = frp->fri_icmp; 1400254219Scy frp4->fri_tuc.ftu_tcpfm = frp->fri_tuc.ftu_tcpfm; 1401254219Scy frp4->fri_tuc.ftu_tcpf = frp->fri_tuc.ftu_tcpf; 1402254219Scy ipfv5tuctov4(&frp->fri_tuc, &frp4->fri_tuc); 1403254219Scy frp4->fri_satype = frp->fri_satype; 1404254219Scy frp4->fri_datype = frp->fri_datype; 1405254219Scy frp4->fri_sifpidx = frp->fri_sifpidx; 1406254219Scy frp4->fri_difpidx = frp->fri_difpidx; 1407254219Scy} 1408254219Scy 1409254219Scy 1410254219Scy/* ------------------------------------------------------------------------ */ 1411254219Scy/* ipf_in_compat is the first of two service routines. It is responsible for*/ 1412254219Scy/* converting data structures from user space into what's required by the */ 1413254219Scy/* kernel module. */ 1414254219Scy/* ------------------------------------------------------------------------ */ 1415254219Scyint 1416254219Scyipf_in_compat(softc, obj, ptr, size) 1417254219Scy ipf_main_softc_t *softc; 1418254219Scy ipfobj_t *obj; 1419254219Scy void *ptr; 1420254219Scy int size; 1421254219Scy{ 1422254219Scy int error; 1423254219Scy int sz; 1424254219Scy 1425254219Scy IPFERROR(140000); 1426254219Scy error = EINVAL; 1427254219Scy 1428254219Scy switch (obj->ipfo_type) 1429254219Scy { 1430254219Scy default : 1431254219Scy break; 1432254219Scy 1433254219Scy case IPFOBJ_FRENTRY : 1434254219Scy if (obj->ipfo_rev >= 4013400) { 1435254219Scy frentry_4_1_34_t *old; 1436254219Scy 1437254219Scy KMALLOC(old, frentry_4_1_34_t *); 1438254219Scy if (old == NULL) { 1439254219Scy IPFERROR(140001); 1440254219Scy error = ENOMEM; 1441254219Scy break; 1442254219Scy } 1443254219Scy error = COPYIN(obj->ipfo_ptr, old, sizeof(*old)); 1444254219Scy if (error == 0) { 1445254219Scy if (old->fr_type != FR_T_NONE && 1446254219Scy old->fr_type != FR_T_IPF) { 1447254219Scy IPFERROR(140002); 1448254219Scy error = EINVAL; 1449254219Scy KFREE(old); 1450254219Scy break; 1451254219Scy } 1452254219Scy frentry_4_1_34_to_current(softc, old, 1453254219Scy ptr, size); 1454254219Scy } else { 1455254219Scy IPFERROR(140003); 1456254219Scy } 1457254219Scy KFREE(old); 1458254219Scy } else if (obj->ipfo_rev >= 4011600) { 1459254219Scy frentry_4_1_16_t *old; 1460254219Scy 1461254219Scy KMALLOC(old, frentry_4_1_16_t *); 1462254219Scy if (old == NULL) { 1463254219Scy IPFERROR(140004); 1464254219Scy error = ENOMEM; 1465254219Scy break; 1466254219Scy } 1467254219Scy error = COPYIN(obj->ipfo_ptr, old, sizeof(*old)); 1468254219Scy if (error == 0) { 1469254219Scy if (old->fr_type != FR_T_NONE && 1470254219Scy old->fr_type != FR_T_IPF) { 1471254219Scy IPFERROR(140005); 1472254219Scy error = EINVAL; 1473254219Scy KFREE(old); 1474254219Scy break; 1475254219Scy } 1476254219Scy frentry_4_1_16_to_current(softc, old, 1477254219Scy ptr, size); 1478254219Scy } else { 1479254219Scy IPFERROR(140006); 1480254219Scy } 1481254219Scy KFREE(old); 1482254219Scy } else { 1483254219Scy frentry_4_1_0_t *old; 1484254219Scy 1485254219Scy KMALLOC(old, frentry_4_1_0_t *); 1486254219Scy if (old == NULL) { 1487254219Scy IPFERROR(140007); 1488254219Scy error = ENOMEM; 1489254219Scy break; 1490254219Scy } 1491254219Scy error = COPYIN(obj->ipfo_ptr, old, sizeof(*old)); 1492254219Scy if (error == 0) { 1493254219Scy if (old->fr_type != FR_T_NONE && 1494254219Scy old->fr_type != FR_T_IPF) { 1495254219Scy IPFERROR(140008); 1496254219Scy error = EINVAL; 1497254219Scy KFREE(old); 1498254219Scy break; 1499254219Scy } 1500254219Scy frentry_4_1_0_to_current(softc, old, ptr, size); 1501254219Scy } else { 1502254219Scy IPFERROR(140009); 1503254219Scy } 1504254219Scy KFREE(old); 1505254219Scy } 1506254219Scy break; 1507254219Scy 1508254219Scy case IPFOBJ_IPFSTAT : 1509254219Scy if (obj->ipfo_rev >= 4013300) { 1510254219Scy friostat_4_1_33_t *old; 1511254219Scy 1512254219Scy KMALLOC(old, friostat_4_1_33_t *); 1513254219Scy if (old == NULL) { 1514254219Scy IPFERROR(140010); 1515254219Scy error = ENOMEM; 1516254219Scy break; 1517254219Scy } 1518254219Scy error = COPYIN(obj->ipfo_ptr, old, sizeof(*old)); 1519254219Scy if (error == 0) { 1520254219Scy friostat_4_1_33_to_current(old, ptr); 1521254219Scy } else { 1522254219Scy IPFERROR(140011); 1523254219Scy } 1524254219Scy } else { 1525254219Scy friostat_4_1_0_t *old; 1526254219Scy 1527254219Scy KMALLOC(old, friostat_4_1_0_t *); 1528254219Scy if (old == NULL) { 1529254219Scy IPFERROR(140012); 1530254219Scy error = ENOMEM; 1531254219Scy break; 1532254219Scy } 1533254219Scy error = COPYIN(obj->ipfo_ptr, old, sizeof(*old)); 1534254219Scy if (error == 0) { 1535254219Scy friostat_4_1_0_to_current(old, ptr); 1536254219Scy } else { 1537254219Scy IPFERROR(140013); 1538254219Scy } 1539254219Scy } 1540254219Scy break; 1541254219Scy 1542254219Scy case IPFOBJ_IPFINFO : /* unused */ 1543254219Scy break; 1544254219Scy 1545254219Scy case IPFOBJ_IPNAT : 1546254219Scy if (obj->ipfo_rev >= 4011400) { 1547254219Scy ipnat_4_1_14_t *old; 1548254219Scy 1549254219Scy KMALLOC(old, ipnat_4_1_14_t *); 1550254219Scy if (old == NULL) { 1551254219Scy IPFERROR(140014); 1552254219Scy error = ENOMEM; 1553254219Scy break; 1554254219Scy } 1555254219Scy error = COPYIN(obj->ipfo_ptr, old, sizeof(*old)); 1556254219Scy if (error == 0) { 1557254219Scy ipnat_4_1_14_to_current(old, ptr, size); 1558254219Scy } else { 1559254219Scy IPFERROR(140015); 1560254219Scy } 1561254219Scy KFREE(old); 1562254219Scy } else { 1563254219Scy ipnat_4_1_0_t *old; 1564254219Scy 1565254219Scy KMALLOC(old, ipnat_4_1_0_t *); 1566254219Scy if (old == NULL) { 1567254219Scy IPFERROR(140016); 1568254219Scy error = ENOMEM; 1569254219Scy break; 1570254219Scy } 1571254219Scy error = COPYIN(obj->ipfo_ptr, old, sizeof(*old)); 1572254219Scy if (error == 0) { 1573254219Scy ipnat_4_1_0_to_current(old, ptr, size); 1574254219Scy } else { 1575254219Scy IPFERROR(140017); 1576254219Scy } 1577254219Scy KFREE(old); 1578254219Scy } 1579254219Scy break; 1580254219Scy 1581254219Scy case IPFOBJ_NATSTAT : 1582254219Scy /* 1583254219Scy * Statistics are not copied in. 1584254219Scy */ 1585254219Scy break; 1586254219Scy 1587254219Scy case IPFOBJ_NATSAVE : 1588254219Scy if (obj->ipfo_rev >= 4011600) { 1589254219Scy nat_save_4_1_16_t *old16; 1590254219Scy 1591254219Scy KMALLOC(old16, nat_save_4_1_16_t *); 1592254219Scy if (old16 == NULL) { 1593254219Scy IPFERROR(140018); 1594254219Scy error = ENOMEM; 1595254219Scy break; 1596254219Scy } 1597254219Scy error = COPYIN(obj->ipfo_ptr, old16, sizeof(*old16)); 1598254219Scy if (error == 0) { 1599254219Scy nat_save_4_1_16_to_current(softc, old16, ptr); 1600254219Scy } else { 1601254219Scy IPFERROR(140019); 1602254219Scy } 1603254219Scy KFREE(old16); 1604254219Scy } else if (obj->ipfo_rev >= 4011400) { 1605254219Scy nat_save_4_1_14_t *old14; 1606254219Scy 1607254219Scy KMALLOC(old14, nat_save_4_1_14_t *); 1608254219Scy if (old14 == NULL) { 1609254219Scy IPFERROR(140020); 1610254219Scy error = ENOMEM; 1611254219Scy break; 1612254219Scy } 1613254219Scy error = COPYIN(obj->ipfo_ptr, old14, sizeof(*old14)); 1614254219Scy if (error == 0) { 1615254219Scy nat_save_4_1_14_to_current(softc, old14, ptr); 1616254219Scy } else { 1617254219Scy IPFERROR(140021); 1618254219Scy } 1619254219Scy KFREE(old14); 1620254219Scy } else if (obj->ipfo_rev >= 4010300) { 1621254219Scy nat_save_4_1_3_t *old3; 1622254219Scy 1623254219Scy KMALLOC(old3, nat_save_4_1_3_t *); 1624254219Scy if (old3 == NULL) { 1625254219Scy IPFERROR(140022); 1626254219Scy error = ENOMEM; 1627254219Scy break; 1628254219Scy } 1629254219Scy error = COPYIN(obj->ipfo_ptr, old3, sizeof(*old3)); 1630254219Scy if (error == 0) { 1631254219Scy nat_save_4_1_3_to_current(softc, old3, ptr); 1632254219Scy } else { 1633254219Scy IPFERROR(140023); 1634254219Scy } 1635254219Scy KFREE(old3); 1636254219Scy } 1637254219Scy break; 1638254219Scy 1639254219Scy case IPFOBJ_STATESAVE : 1640254219Scy if (obj->ipfo_rev >= 4013400) { 1641254219Scy ipstate_save_4_1_34_t *old; 1642254219Scy 1643254219Scy KMALLOC(old, ipstate_save_4_1_34_t *); 1644254219Scy if (old == NULL) { 1645254219Scy IPFERROR(140024); 1646254219Scy error = ENOMEM; 1647254219Scy break; 1648254219Scy } 1649254219Scy error = COPYIN(obj->ipfo_ptr, old, sizeof(*old)); 1650254219Scy if (error != 0) { 1651254219Scy IPFERROR(140025); 1652254219Scy } 1653254219Scy KFREE(old); 1654254219Scy } else if (obj->ipfo_rev >= 4011600) { 1655254219Scy ipstate_save_4_1_16_t *old; 1656254219Scy 1657254219Scy KMALLOC(old, ipstate_save_4_1_16_t *); 1658254219Scy if (old == NULL) { 1659254219Scy IPFERROR(140026); 1660254219Scy error = ENOMEM; 1661254219Scy break; 1662254219Scy } 1663254219Scy error = COPYIN(obj->ipfo_ptr, old, sizeof(*old)); 1664254219Scy if (error != 0) { 1665254219Scy IPFERROR(140027); 1666254219Scy } 1667254219Scy KFREE(old); 1668254219Scy } else { 1669254219Scy ipstate_save_4_1_0_t *old; 1670254219Scy 1671254219Scy KMALLOC(old, ipstate_save_4_1_0_t *); 1672254219Scy if (old == NULL) { 1673254219Scy IPFERROR(140028); 1674254219Scy error = ENOMEM; 1675254219Scy break; 1676254219Scy } 1677254219Scy error = COPYIN(obj->ipfo_ptr, old, sizeof(*old)); 1678254219Scy if (error != 0) { 1679254219Scy IPFERROR(140029); 1680254219Scy } 1681254219Scy KFREE(old); 1682254219Scy } 1683254219Scy break; 1684254219Scy 1685254219Scy case IPFOBJ_IPSTATE : 1686254219Scy /* 1687254219Scy * This structure is not copied in by itself. 1688254219Scy */ 1689254219Scy break; 1690254219Scy 1691254219Scy case IPFOBJ_STATESTAT : 1692254219Scy /* 1693254219Scy * Statistics are not copied in. 1694254219Scy */ 1695254219Scy break; 1696254219Scy 1697254219Scy case IPFOBJ_FRAUTH : 1698254219Scy if (obj->ipfo_rev >= 4013200) { 1699254219Scy frauth_4_1_32_t *old32; 1700254219Scy 1701254219Scy KMALLOC(old32, frauth_4_1_32_t *); 1702254219Scy if (old32 == NULL) { 1703254219Scy IPFERROR(140030); 1704254219Scy error = ENOMEM; 1705254219Scy break; 1706254219Scy } 1707254219Scy error = COPYIN(obj->ipfo_ptr, old32, sizeof(*old32)); 1708254219Scy if (error == 0) { 1709254219Scy frauth_4_1_32_to_current(old32, ptr); 1710254219Scy } else { 1711254219Scy IPFERROR(140031); 1712254219Scy } 1713254219Scy KFREE(old32); 1714254219Scy } else if (obj->ipfo_rev >= 4012900) { 1715254219Scy frauth_4_1_29_t *old29; 1716254219Scy 1717254219Scy KMALLOC(old29, frauth_4_1_29_t *); 1718254219Scy if (old29 == NULL) { 1719254219Scy IPFERROR(140032); 1720254219Scy error = ENOMEM; 1721254219Scy break; 1722254219Scy } 1723254219Scy error = COPYIN(obj->ipfo_ptr, old29, sizeof(*old29)); 1724254219Scy if (error == 0) { 1725254219Scy frauth_4_1_29_to_current(old29, ptr); 1726254219Scy } else { 1727254219Scy IPFERROR(140033); 1728254219Scy } 1729254219Scy KFREE(old29); 1730254219Scy } else if (obj->ipfo_rev >= 4012400) { 1731254219Scy frauth_4_1_24_t *old24; 1732254219Scy 1733254219Scy KMALLOC(old24, frauth_4_1_24_t *); 1734254219Scy if (old24 == NULL) { 1735254219Scy IPFERROR(140034); 1736254219Scy error = ENOMEM; 1737254219Scy break; 1738254219Scy } 1739254219Scy error = COPYIN(obj->ipfo_ptr, old24, sizeof(*old24)); 1740254219Scy if (error == 0) { 1741254219Scy frauth_4_1_24_to_current(old24, ptr); 1742254219Scy } else { 1743254219Scy IPFERROR(140035); 1744254219Scy } 1745254219Scy KFREE(old24); 1746254219Scy } else if (obj->ipfo_rev >= 4012300) { 1747254219Scy frauth_4_1_23_t *old23; 1748254219Scy 1749254219Scy KMALLOC(old23, frauth_4_1_23_t *); 1750254219Scy if (old23 == NULL) { 1751254219Scy IPFERROR(140036); 1752254219Scy error = ENOMEM; 1753254219Scy break; 1754254219Scy } 1755254219Scy error = COPYIN(obj->ipfo_ptr, old23, sizeof(*old23)); 1756254219Scy if (error == 0) 1757254219Scy frauth_4_1_23_to_current(old23, ptr); 1758254219Scy KFREE(old23); 1759254219Scy } else if (obj->ipfo_rev >= 4011100) { 1760254219Scy frauth_4_1_11_t *old11; 1761254219Scy 1762254219Scy KMALLOC(old11, frauth_4_1_11_t *); 1763254219Scy if (old11 == NULL) { 1764254219Scy IPFERROR(140037); 1765254219Scy error = ENOMEM; 1766254219Scy break; 1767254219Scy } 1768254219Scy error = COPYIN(obj->ipfo_ptr, old11, sizeof(*old11)); 1769254219Scy if (error == 0) { 1770254219Scy frauth_4_1_11_to_current(old11, ptr); 1771254219Scy } else { 1772254219Scy IPFERROR(140038); 1773254219Scy } 1774254219Scy KFREE(old11); 1775254219Scy } 1776254219Scy break; 1777254219Scy 1778254219Scy case IPFOBJ_NAT : 1779254219Scy if (obj->ipfo_rev >= 4011400) { 1780254219Scy sz = sizeof(nat_4_1_14_t); 1781254219Scy } else if (obj->ipfo_rev >= 4010300) { 1782254219Scy sz = sizeof(nat_4_1_3_t); 1783254219Scy } else { 1784254219Scy break; 1785254219Scy } 1786254219Scy bzero(ptr, sizeof(nat_t)); 1787254219Scy error = COPYIN(obj->ipfo_ptr, ptr, sz); 1788254219Scy if (error != 0) { 1789254219Scy IPFERROR(140039); 1790254219Scy } 1791254219Scy break; 1792254219Scy 1793254219Scy case IPFOBJ_FRIPF : 1794254219Scy if (obj->ipfo_rev < 5000000) { 1795254219Scy fripf4_t *old; 1796254219Scy 1797254219Scy KMALLOC(old, fripf4_t *); 1798254219Scy if (old == NULL) { 1799254219Scy IPFERROR(140040); 1800254219Scy error = ENOMEM; 1801254219Scy break; 1802254219Scy } 1803254219Scy error = COPYIN(obj->ipfo_ptr, old, sizeof(*old)); 1804254219Scy if (error == 0) { 1805254219Scy ipf_v4fripftov5(old, ptr); 1806254219Scy } else { 1807254219Scy IPFERROR(140041); 1808254219Scy } 1809254219Scy KFREE(old); 1810254219Scy } 1811254219Scy break; 1812254219Scy } 1813254219Scy 1814254219Scy return error; 1815254219Scy} 1816254219Scy/* ------------------------------------------------------------------------ */ 1817254219Scy 1818254219Scy 1819254219Scy/* 1820254219Scy * flags is v4 flags, returns v5 flags. 1821254219Scy */ 1822254219Scystatic int 1823254219Scyfr_frflags4to5(flags) 1824254219Scy u_32_t flags; 1825254219Scy{ 1826254219Scy u_32_t nflags = 0; 1827254219Scy 1828254219Scy switch (flags & 0xf) { 1829254219Scy case 0x0 : 1830254219Scy nflags |= FR_CALL; 1831254219Scy break; 1832254219Scy case 0x1 : 1833254219Scy nflags |= FR_BLOCK; 1834254219Scy break; 1835254219Scy case 0x2 : 1836254219Scy nflags |= FR_PASS; 1837254219Scy break; 1838254219Scy case 0x3 : 1839254219Scy nflags |= FR_AUTH; 1840254219Scy break; 1841254219Scy case 0x4 : 1842254219Scy nflags |= FR_PREAUTH; 1843254219Scy break; 1844254219Scy case 0x5 : 1845254219Scy nflags |= FR_ACCOUNT; 1846254219Scy break; 1847254219Scy case 0x6 : 1848254219Scy nflags |= FR_SKIP; 1849254219Scy break; 1850254219Scy default : 1851254219Scy break; 1852254219Scy } 1853254219Scy 1854254219Scy if (flags & 0x00010) 1855254219Scy nflags |= FR_LOG; 1856254219Scy if (flags & 0x00020) 1857254219Scy nflags |= FR_CALLNOW; 1858254219Scy if (flags & 0x00080) 1859254219Scy nflags |= FR_NOTSRCIP; 1860254219Scy if (flags & 0x00040) 1861254219Scy nflags |= FR_NOTDSTIP; 1862254219Scy if (flags & 0x00100) 1863254219Scy nflags |= FR_QUICK; 1864254219Scy if (flags & 0x00200) 1865254219Scy nflags |= FR_KEEPFRAG; 1866254219Scy if (flags & 0x00400) 1867254219Scy nflags |= FR_KEEPSTATE; 1868254219Scy if (flags & 0x00800) 1869254219Scy nflags |= FR_FASTROUTE; 1870254219Scy if (flags & 0x01000) 1871254219Scy nflags |= FR_RETRST; 1872254219Scy if (flags & 0x02000) 1873254219Scy nflags |= FR_RETICMP; 1874254219Scy if (flags & 0x03000) 1875254219Scy nflags |= FR_FAKEICMP; 1876254219Scy if (flags & 0x04000) 1877254219Scy nflags |= FR_OUTQUE; 1878254219Scy if (flags & 0x08000) 1879254219Scy nflags |= FR_INQUE; 1880254219Scy if (flags & 0x10000) 1881254219Scy nflags |= FR_LOGBODY; 1882254219Scy if (flags & 0x20000) 1883254219Scy nflags |= FR_LOGFIRST; 1884254219Scy if (flags & 0x40000) 1885254219Scy nflags |= FR_LOGORBLOCK; 1886254219Scy if (flags & 0x100000) 1887254219Scy nflags |= FR_FRSTRICT; 1888254219Scy if (flags & 0x200000) 1889254219Scy nflags |= FR_STSTRICT; 1890254219Scy if (flags & 0x400000) 1891254219Scy nflags |= FR_NEWISN; 1892254219Scy if (flags & 0x800000) 1893254219Scy nflags |= FR_NOICMPERR; 1894254219Scy if (flags & 0x1000000) 1895254219Scy nflags |= FR_STATESYNC; 1896254219Scy if (flags & 0x8000000) 1897254219Scy nflags |= FR_NOMATCH; 1898254219Scy if (flags & 0x40000000) 1899254219Scy nflags |= FR_COPIED; 1900254219Scy if (flags & 0x80000000) 1901254219Scy nflags |= FR_INACTIVE; 1902254219Scy 1903254219Scy return nflags; 1904254219Scy} 1905254219Scy 1906254219Scystatic void 1907254219Scyfrentry_4_1_34_to_current(softc, old, current, size) 1908254219Scy ipf_main_softc_t *softc; 1909254219Scy frentry_4_1_34_t *old; 1910254219Scy void *current; 1911254219Scy int size; 1912254219Scy{ 1913254219Scy frentry_t *fr = (frentry_t *)current; 1914254219Scy 1915254219Scy fr->fr_comment = -1; 1916254219Scy fr->fr_ref = old->fr_ref; 1917254219Scy fr->fr_statecnt = old->fr_statecnt; 1918254219Scy fr->fr_hits = old->fr_hits; 1919254219Scy fr->fr_bytes = old->fr_bytes; 1920254219Scy fr->fr_lastpkt.tv_sec = old->fr_lastpkt.tv_sec; 1921254219Scy fr->fr_lastpkt.tv_usec = old->fr_lastpkt.tv_usec; 1922254219Scy bcopy(&old->fr_dun, &fr->fr_dun, sizeof(old->fr_dun)); 1923254219Scy fr->fr_func = old->fr_func; 1924254219Scy fr->fr_dsize = old->fr_dsize; 1925254219Scy fr->fr_pps = old->fr_pps; 1926254219Scy fr->fr_statemax = old->fr_statemax; 1927254219Scy fr->fr_flineno = old->fr_flineno; 1928254219Scy fr->fr_type = old->fr_type; 1929254219Scy fr->fr_flags = fr_frflags4to5(old->fr_flags); 1930254219Scy fr->fr_logtag = old->fr_logtag; 1931254219Scy fr->fr_collect = old->fr_collect; 1932254219Scy fr->fr_arg = old->fr_arg; 1933254219Scy fr->fr_loglevel = old->fr_loglevel; 1934254219Scy fr->fr_age[0] = old->fr_age[0]; 1935254219Scy fr->fr_age[1] = old->fr_age[1]; 1936254219Scy fr->fr_tifs[0].fd_ip6 = old->fr_tifs[0].ofd_ip6; 1937254219Scy fr->fr_tifs[0].fd_type = FRD_NORMAL; 1938254219Scy fr->fr_tifs[1].fd_ip6 = old->fr_tifs[1].ofd_ip6; 1939254219Scy fr->fr_tifs[1].fd_type = FRD_NORMAL; 1940254219Scy fr->fr_dif.fd_ip6 = old->fr_dif.ofd_ip6; 1941254219Scy fr->fr_dif.fd_type = FRD_NORMAL; 1942254219Scy if (old->fr_v == 4) 1943254219Scy fr->fr_family = AF_INET; 1944254219Scy if (old->fr_v == 6) 1945254219Scy fr->fr_family = AF_INET6; 1946254219Scy fr->fr_icode = old->fr_icode; 1947254219Scy fr->fr_cksum = old->fr_cksum; 1948254219Scy fr->fr_namelen = 0; 1949254219Scy fr->fr_ifnames[0] = -1; 1950254219Scy fr->fr_ifnames[1] = -1; 1951254219Scy fr->fr_ifnames[2] = -1; 1952254219Scy fr->fr_ifnames[3] = -1; 1953254219Scy fr->fr_dif.fd_name = -1; 1954254219Scy fr->fr_tifs[0].fd_name = -1; 1955254219Scy fr->fr_tifs[1].fd_name = -1; 1956254219Scy fr->fr_group = -1; 1957254219Scy fr->fr_grhead = -1; 1958254219Scy fr->fr_icmphead = -1; 1959254219Scy if (size == 0) { 1960254219Scy fr->fr_size = sizeof(*fr) + LIFNAMSIZ * 7 + FR_GROUPLEN * 2; 1961254219Scy fr->fr_size += sizeof(fripf_t) + 16; 1962254219Scy fr->fr_size += 9; /* room for \0's */ 1963254219Scy } else { 1964254219Scy char *names = fr->fr_names; 1965254219Scy int nlen = fr->fr_namelen; 1966254219Scy 1967254219Scy fr->fr_size = size; 1968254219Scy if (old->fr_ifnames[0][0] != '\0') { 1969254219Scy fr->fr_ifnames[0] = nlen; 1970254219Scy nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[0], 1971254219Scy LIFNAMSIZ); 1972254219Scy } 1973254219Scy if (old->fr_ifnames[1][0] != '\0') { 1974254219Scy fr->fr_ifnames[1] = nlen; 1975254219Scy nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[1], 1976254219Scy LIFNAMSIZ); 1977254219Scy } 1978254219Scy if (old->fr_ifnames[2][0] != '\0') { 1979254219Scy fr->fr_ifnames[2] = nlen; 1980254219Scy nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[2], 1981254219Scy LIFNAMSIZ); 1982254219Scy } 1983254219Scy if (old->fr_ifnames[3][0] != '\0') { 1984254219Scy fr->fr_ifnames[3] = nlen; 1985254219Scy nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[3], 1986254219Scy LIFNAMSIZ); 1987254219Scy } 1988254219Scy if (old->fr_tifs[0].fd_ifname[0] != '\0') { 1989254219Scy fr->fr_tifs[0].fd_name = nlen; 1990254219Scy nlen = ipf_addfrstr(names, nlen, 1991254219Scy old->fr_tifs[0].fd_ifname, 1992254219Scy LIFNAMSIZ); 1993254219Scy } 1994254219Scy if (old->fr_tifs[1].fd_ifname[0] != '\0') { 1995254219Scy fr->fr_tifs[1].fd_name = nlen; 1996254219Scy nlen = ipf_addfrstr(names, nlen, 1997254219Scy old->fr_tifs[1].fd_ifname, 1998254219Scy LIFNAMSIZ); 1999254219Scy } 2000254219Scy if (old->fr_dif.fd_ifname[0] != '\0') { 2001254219Scy fr->fr_dif.fd_name = nlen; 2002254219Scy nlen = ipf_addfrstr(names, nlen, 2003254219Scy old->fr_dif.fd_ifname, LIFNAMSIZ); 2004254219Scy } 2005254219Scy if (old->fr_group[0] != '\0') { 2006254219Scy fr->fr_group = nlen; 2007254219Scy nlen = ipf_addfrstr(names, nlen, 2008254219Scy old->fr_group, LIFNAMSIZ); 2009254219Scy } 2010254219Scy if (old->fr_grhead[0] != '\0') { 2011254219Scy fr->fr_grhead = nlen; 2012254219Scy nlen = ipf_addfrstr(names, nlen, 2013254219Scy old->fr_grhead, LIFNAMSIZ); 2014254219Scy } 2015254219Scy fr->fr_namelen = nlen; 2016254219Scy 2017254219Scy if (old->fr_type == FR_T_IPF) { 2018254219Scy int offset = fr->fr_namelen; 2019254219Scy ipfobj_t obj; 2020254219Scy int error; 2021254219Scy 2022254219Scy obj.ipfo_type = IPFOBJ_FRIPF; 2023254219Scy obj.ipfo_rev = 4010100; 2024254219Scy obj.ipfo_ptr = old->fr_data; 2025254219Scy 2026254219Scy if ((offset & 7) != 0) 2027254219Scy offset += 8 - (offset & 7); 2028254219Scy error = ipf_in_compat(softc, &obj, 2029254219Scy fr->fr_names + offset, 0); 2030254219Scy if (error == 0) { 2031254219Scy fr->fr_data = fr->fr_names + offset; 2032254219Scy fr->fr_dsize = sizeof(fripf_t); 2033254219Scy } 2034254219Scy } 2035254219Scy } 2036254219Scy} 2037254219Scy 2038254219Scystatic void 2039254219Scyfrentry_4_1_16_to_current(softc, old, current, size) 2040254219Scy ipf_main_softc_t *softc; 2041254219Scy frentry_4_1_16_t *old; 2042254219Scy void *current; 2043254219Scy int size; 2044254219Scy{ 2045254219Scy frentry_t *fr = (frentry_t *)current; 2046254219Scy 2047254219Scy fr->fr_comment = -1; 2048254219Scy fr->fr_ref = old->fr_ref; 2049254219Scy fr->fr_statecnt = old->fr_statecnt; 2050254219Scy fr->fr_hits = old->fr_hits; 2051254219Scy fr->fr_bytes = old->fr_bytes; 2052254219Scy fr->fr_lastpkt.tv_sec = old->fr_lastpkt.tv_sec; 2053254219Scy fr->fr_lastpkt.tv_usec = old->fr_lastpkt.tv_usec; 2054254219Scy bcopy(&old->fr_dun, &fr->fr_dun, sizeof(old->fr_dun)); 2055254219Scy fr->fr_func = old->fr_func; 2056254219Scy fr->fr_dsize = old->fr_dsize; 2057254219Scy fr->fr_pps = old->fr_pps; 2058254219Scy fr->fr_statemax = old->fr_statemax; 2059254219Scy fr->fr_flineno = old->fr_flineno; 2060254219Scy fr->fr_type = old->fr_type; 2061254219Scy fr->fr_flags = fr_frflags4to5(old->fr_flags); 2062254219Scy fr->fr_logtag = old->fr_logtag; 2063254219Scy fr->fr_collect = old->fr_collect; 2064254219Scy fr->fr_arg = old->fr_arg; 2065254219Scy fr->fr_loglevel = old->fr_loglevel; 2066254219Scy fr->fr_age[0] = old->fr_age[0]; 2067254219Scy fr->fr_age[1] = old->fr_age[1]; 2068254219Scy fr->fr_tifs[0].fd_ip6 = old->fr_tifs[0].ofd_ip6; 2069254219Scy fr->fr_tifs[0].fd_type = FRD_NORMAL; 2070254219Scy fr->fr_tifs[1].fd_ip6 = old->fr_tifs[1].ofd_ip6; 2071254219Scy fr->fr_tifs[1].fd_type = FRD_NORMAL; 2072254219Scy fr->fr_dif.fd_ip6 = old->fr_dif.ofd_ip6; 2073254219Scy fr->fr_dif.fd_type = FRD_NORMAL; 2074254219Scy if (old->fr_v == 4) 2075254219Scy fr->fr_family = AF_INET; 2076254219Scy if (old->fr_v == 6) 2077254219Scy fr->fr_family = AF_INET6; 2078254219Scy fr->fr_icode = old->fr_icode; 2079254219Scy fr->fr_cksum = old->fr_cksum; 2080254219Scy fr->fr_namelen = 0; 2081254219Scy fr->fr_ifnames[0] = -1; 2082254219Scy fr->fr_ifnames[1] = -1; 2083254219Scy fr->fr_ifnames[2] = -1; 2084254219Scy fr->fr_ifnames[3] = -1; 2085254219Scy fr->fr_dif.fd_name = -1; 2086254219Scy fr->fr_tifs[0].fd_name = -1; 2087254219Scy fr->fr_tifs[1].fd_name = -1; 2088254219Scy fr->fr_group = -1; 2089254219Scy fr->fr_grhead = -1; 2090254219Scy fr->fr_icmphead = -1; 2091254219Scy if (size == 0) { 2092254219Scy fr->fr_size = sizeof(*fr) + LIFNAMSIZ * 7 + FR_GROUPLEN * 2; 2093254219Scy fr->fr_size += 9; /* room for \0's */ 2094254219Scy } else { 2095254219Scy char *names = fr->fr_names; 2096254219Scy int nlen = fr->fr_namelen; 2097254219Scy 2098254219Scy fr->fr_size = size; 2099254219Scy if (old->fr_ifnames[0][0] != '\0') { 2100254219Scy fr->fr_ifnames[0] = nlen; 2101254219Scy nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[0], 2102254219Scy LIFNAMSIZ); 2103254219Scy } 2104254219Scy if (old->fr_ifnames[1][0] != '\0') { 2105254219Scy fr->fr_ifnames[1] = nlen; 2106254219Scy nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[1], 2107254219Scy LIFNAMSIZ); 2108254219Scy } 2109254219Scy if (old->fr_ifnames[2][0] != '\0') { 2110254219Scy fr->fr_ifnames[2] = nlen; 2111254219Scy nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[2], 2112254219Scy LIFNAMSIZ); 2113254219Scy } 2114254219Scy if (old->fr_ifnames[3][0] != '\0') { 2115254219Scy fr->fr_ifnames[3] = nlen; 2116254219Scy nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[3], 2117254219Scy LIFNAMSIZ); 2118254219Scy } 2119254219Scy if (old->fr_tifs[0].fd_ifname[0] != '\0') { 2120254219Scy fr->fr_tifs[0].fd_name = nlen; 2121254219Scy nlen = ipf_addfrstr(names, nlen, 2122254219Scy old->fr_tifs[0].fd_ifname, 2123254219Scy LIFNAMSIZ); 2124254219Scy } 2125254219Scy if (old->fr_tifs[1].fd_ifname[0] != '\0') { 2126254219Scy fr->fr_tifs[1].fd_name = nlen; 2127254219Scy nlen = ipf_addfrstr(names, nlen, 2128254219Scy old->fr_tifs[1].fd_ifname, 2129254219Scy LIFNAMSIZ); 2130254219Scy } 2131254219Scy if (old->fr_dif.fd_ifname[0] != '\0') { 2132254219Scy fr->fr_dif.fd_name = nlen; 2133254219Scy nlen = ipf_addfrstr(names, nlen, 2134254219Scy old->fr_dif.fd_ifname, LIFNAMSIZ); 2135254219Scy } 2136254219Scy if (old->fr_group[0] != '\0') { 2137254219Scy fr->fr_group = nlen; 2138254219Scy nlen = ipf_addfrstr(names, nlen, 2139254219Scy old->fr_group, LIFNAMSIZ); 2140254219Scy } 2141254219Scy if (old->fr_grhead[0] != '\0') { 2142254219Scy fr->fr_grhead = nlen; 2143254219Scy nlen = ipf_addfrstr(names, nlen, 2144254219Scy old->fr_grhead, LIFNAMSIZ); 2145254219Scy } 2146254219Scy fr->fr_namelen = nlen; 2147254219Scy 2148254219Scy if (old->fr_type == FR_T_IPF) { 2149254219Scy int offset = fr->fr_namelen; 2150254219Scy ipfobj_t obj; 2151254219Scy int error; 2152254219Scy 2153254219Scy obj.ipfo_type = IPFOBJ_FRIPF; 2154254219Scy obj.ipfo_rev = 4010100; 2155254219Scy obj.ipfo_ptr = old->fr_data; 2156254219Scy 2157254219Scy if ((offset & 7) != 0) 2158254219Scy offset += 8 - (offset & 7); 2159254219Scy error = ipf_in_compat(softc, &obj, 2160254219Scy fr->fr_names + offset, 0); 2161254219Scy if (error == 0) { 2162254219Scy fr->fr_data = fr->fr_names + offset; 2163254219Scy fr->fr_dsize = sizeof(fripf_t); 2164254219Scy } 2165254219Scy } 2166254219Scy } 2167254219Scy} 2168254219Scy 2169254219Scy 2170254219Scystatic void 2171254219Scyfrentry_4_1_0_to_current(softc, old, current, size) 2172254219Scy ipf_main_softc_t *softc; 2173254219Scy frentry_4_1_0_t *old; 2174254219Scy void *current; 2175254219Scy int size; 2176254219Scy{ 2177254219Scy frentry_t *fr = (frentry_t *)current; 2178254219Scy 2179254219Scy fr->fr_size = sizeof(*fr); 2180254219Scy fr->fr_comment = -1; 2181254219Scy fr->fr_ref = old->fr_ref; 2182254219Scy fr->fr_statecnt = old->fr_statecnt; 2183254219Scy fr->fr_hits = old->fr_hits; 2184254219Scy fr->fr_bytes = old->fr_bytes; 2185254219Scy fr->fr_lastpkt.tv_sec = old->fr_lastpkt.tv_sec; 2186254219Scy fr->fr_lastpkt.tv_usec = old->fr_lastpkt.tv_usec; 2187254219Scy bcopy(&old->fr_dun, &fr->fr_dun, sizeof(old->fr_dun)); 2188254219Scy fr->fr_func = old->fr_func; 2189254219Scy fr->fr_dsize = old->fr_dsize; 2190254219Scy fr->fr_pps = old->fr_pps; 2191254219Scy fr->fr_statemax = old->fr_statemax; 2192254219Scy fr->fr_flineno = old->fr_flineno; 2193254219Scy fr->fr_type = old->fr_type; 2194254219Scy fr->fr_flags = fr_frflags4to5(old->fr_flags); 2195254219Scy fr->fr_logtag = old->fr_logtag; 2196254219Scy fr->fr_collect = old->fr_collect; 2197254219Scy fr->fr_arg = old->fr_arg; 2198254219Scy fr->fr_loglevel = old->fr_loglevel; 2199254219Scy fr->fr_age[0] = old->fr_age[0]; 2200254219Scy fr->fr_age[1] = old->fr_age[1]; 2201254219Scy fr->fr_tifs[0].fd_ip6 = old->fr_tifs[0].ofd_ip6; 2202254219Scy fr->fr_tifs[0].fd_type = FRD_NORMAL; 2203254219Scy fr->fr_tifs[1].fd_ip6 = old->fr_tifs[1].ofd_ip6; 2204254219Scy fr->fr_tifs[1].fd_type = FRD_NORMAL; 2205254219Scy fr->fr_dif.fd_ip6 = old->fr_dif.ofd_ip6; 2206254219Scy fr->fr_dif.fd_type = FRD_NORMAL; 2207254219Scy if (old->fr_v == 4) 2208254219Scy fr->fr_family = AF_INET; 2209254219Scy if (old->fr_v == 6) 2210254219Scy fr->fr_family = AF_INET6; 2211254219Scy fr->fr_icode = old->fr_icode; 2212254219Scy fr->fr_cksum = old->fr_cksum; 2213254219Scy fr->fr_namelen = 0; 2214254219Scy fr->fr_ifnames[0] = -1; 2215254219Scy fr->fr_ifnames[1] = -1; 2216254219Scy fr->fr_ifnames[2] = -1; 2217254219Scy fr->fr_ifnames[3] = -1; 2218254219Scy fr->fr_dif.fd_name = -1; 2219254219Scy fr->fr_tifs[0].fd_name = -1; 2220254219Scy fr->fr_tifs[1].fd_name = -1; 2221254219Scy fr->fr_group = -1; 2222254219Scy fr->fr_grhead = -1; 2223254219Scy fr->fr_icmphead = -1; 2224254219Scy if (size == 0) { 2225254219Scy fr->fr_size = sizeof(*fr) + LIFNAMSIZ * 7 + FR_GROUPLEN * 2; 2226254219Scy fr->fr_size += 9; /* room for \0's */ 2227254219Scy } else { 2228254219Scy char *names = fr->fr_names; 2229254219Scy int nlen = fr->fr_namelen; 2230254219Scy 2231254219Scy fr->fr_size = size; 2232254219Scy if (old->fr_ifnames[0][0] != '\0') { 2233254219Scy fr->fr_ifnames[0] = nlen; 2234254219Scy nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[0], 2235254219Scy LIFNAMSIZ); 2236254219Scy } 2237254219Scy if (old->fr_ifnames[1][0] != '\0') { 2238254219Scy fr->fr_ifnames[1] = nlen; 2239254219Scy nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[1], 2240254219Scy LIFNAMSIZ); 2241254219Scy } 2242254219Scy if (old->fr_ifnames[2][0] != '\0') { 2243254219Scy fr->fr_ifnames[2] = nlen; 2244254219Scy nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[2], 2245254219Scy LIFNAMSIZ); 2246254219Scy } 2247254219Scy if (old->fr_ifnames[3][0] != '\0') { 2248254219Scy fr->fr_ifnames[3] = nlen; 2249254219Scy nlen = ipf_addfrstr(names, nlen, old->fr_ifnames[3], 2250254219Scy LIFNAMSIZ); 2251254219Scy } 2252254219Scy if (old->fr_tifs[0].fd_ifname[0] != '\0') { 2253254219Scy fr->fr_tifs[0].fd_name = nlen; 2254254219Scy nlen = ipf_addfrstr(names, nlen, 2255254219Scy old->fr_tifs[0].fd_ifname, 2256254219Scy LIFNAMSIZ); 2257254219Scy } 2258254219Scy if (old->fr_tifs[1].fd_ifname[0] != '\0') { 2259254219Scy fr->fr_tifs[1].fd_name = nlen; 2260254219Scy nlen = ipf_addfrstr(names, nlen, 2261254219Scy old->fr_tifs[1].fd_ifname, 2262254219Scy LIFNAMSIZ); 2263254219Scy } 2264254219Scy if (old->fr_dif.fd_ifname[0] != '\0') { 2265254219Scy fr->fr_dif.fd_name = nlen; 2266254219Scy nlen = ipf_addfrstr(names, nlen, 2267254219Scy old->fr_dif.fd_ifname, LIFNAMSIZ); 2268254219Scy } 2269254219Scy if (old->fr_group[0] != '\0') { 2270254219Scy fr->fr_group = nlen; 2271254219Scy nlen = ipf_addfrstr(names, nlen, 2272254219Scy old->fr_group, LIFNAMSIZ); 2273254219Scy } 2274254219Scy if (old->fr_grhead[0] != '\0') { 2275254219Scy fr->fr_grhead = nlen; 2276254219Scy nlen = ipf_addfrstr(names, nlen, 2277254219Scy old->fr_grhead, LIFNAMSIZ); 2278254219Scy } 2279254219Scy fr->fr_namelen = nlen; 2280254219Scy 2281254219Scy if (old->fr_type == FR_T_IPF) { 2282254219Scy int offset = fr->fr_namelen; 2283254219Scy ipfobj_t obj; 2284254219Scy int error; 2285254219Scy 2286254219Scy obj.ipfo_type = IPFOBJ_FRIPF; 2287254219Scy obj.ipfo_rev = 4010100; 2288254219Scy obj.ipfo_ptr = old->fr_data; 2289254219Scy 2290254219Scy if ((offset & 7) != 0) 2291254219Scy offset += 8 - (offset & 7); 2292254219Scy offset += 8 - (offset & 7); 2293254219Scy error = ipf_in_compat(softc, &obj, 2294254219Scy fr->fr_names + offset, 0); 2295254219Scy if (error == 0) { 2296254219Scy fr->fr_data = fr->fr_names + offset; 2297254219Scy fr->fr_dsize = sizeof(fripf_t); 2298254219Scy } 2299254219Scy } 2300254219Scy } 2301254219Scy} 2302254219Scy 2303254219Scy 2304254219Scystatic void 2305254219Scyfriostat_4_1_33_to_current(old, current) 2306254219Scy friostat_4_1_33_t *old; 2307254219Scy void *current; 2308254219Scy{ 2309254219Scy friostat_t *fiop = (friostat_t *)current; 2310254219Scy 2311254219Scy bcopy(&old->of_st[0], &fiop->f_st[0].fr_pass, sizeof(old->of_st[0])); 2312254219Scy bcopy(&old->of_st[1], &fiop->f_st[1].fr_pass, sizeof(old->of_st[1])); 2313254219Scy 2314254219Scy fiop->f_ipf[0][0] = old->f_ipf[0][0]; 2315254219Scy fiop->f_ipf[0][1] = old->f_ipf[0][1]; 2316254219Scy fiop->f_ipf[1][0] = old->f_ipf[1][0]; 2317254219Scy fiop->f_ipf[1][1] = old->f_ipf[1][1]; 2318254219Scy fiop->f_acct[0][0] = old->f_acct[0][0]; 2319254219Scy fiop->f_acct[0][1] = old->f_acct[0][1]; 2320254219Scy fiop->f_acct[1][0] = old->f_acct[1][0]; 2321254219Scy fiop->f_acct[1][1] = old->f_acct[1][1]; 2322254219Scy fiop->f_auth = fiop->f_auth; 2323254219Scy bcopy(&old->f_groups, &fiop->f_groups, sizeof(old->f_groups)); 2324254219Scy bcopy(&old->f_froute, &fiop->f_froute, sizeof(old->f_froute)); 2325254219Scy fiop->f_ticks = old->f_ticks; 2326254219Scy bcopy(&old->f_locks, &fiop->f_locks, sizeof(old->f_locks)); 2327254219Scy fiop->f_defpass = old->f_defpass; 2328254219Scy fiop->f_active = old->f_active; 2329254219Scy fiop->f_running = old->f_running; 2330254219Scy fiop->f_logging = old->f_logging; 2331254219Scy fiop->f_features = old->f_features; 2332254219Scy bcopy(old->f_version, fiop->f_version, sizeof(old->f_version)); 2333254219Scy} 2334254219Scy 2335254219Scy 2336254219Scystatic void 2337254219Scyfriostat_4_1_0_to_current(old, current) 2338254219Scy friostat_4_1_0_t *old; 2339254219Scy void *current; 2340254219Scy{ 2341254219Scy friostat_t *fiop = (friostat_t *)current; 2342254219Scy 2343254219Scy bcopy(&old->of_st[0], &fiop->f_st[0].fr_pass, sizeof(old->of_st[0])); 2344254219Scy bcopy(&old->of_st[1], &fiop->f_st[1].fr_pass, sizeof(old->of_st[1])); 2345254219Scy 2346254219Scy fiop->f_ipf[0][0] = old->f_ipf[0][0]; 2347254219Scy fiop->f_ipf[0][1] = old->f_ipf[0][1]; 2348254219Scy fiop->f_ipf[1][0] = old->f_ipf[1][0]; 2349254219Scy fiop->f_ipf[1][1] = old->f_ipf[1][1]; 2350254219Scy fiop->f_acct[0][0] = old->f_acct[0][0]; 2351254219Scy fiop->f_acct[0][1] = old->f_acct[0][1]; 2352254219Scy fiop->f_acct[1][0] = old->f_acct[1][0]; 2353254219Scy fiop->f_acct[1][1] = old->f_acct[1][1]; 2354254219Scy fiop->f_auth = fiop->f_auth; 2355254219Scy bcopy(&old->f_groups, &fiop->f_groups, sizeof(old->f_groups)); 2356254219Scy bcopy(&old->f_froute, &fiop->f_froute, sizeof(old->f_froute)); 2357254219Scy fiop->f_ticks = old->f_ticks; 2358254219Scy bcopy(&old->f_locks, &fiop->f_locks, sizeof(old->f_locks)); 2359254219Scy fiop->f_defpass = old->f_defpass; 2360254219Scy fiop->f_active = old->f_active; 2361254219Scy fiop->f_running = old->f_running; 2362254219Scy fiop->f_logging = old->f_logging; 2363254219Scy fiop->f_features = old->f_features; 2364254219Scy bcopy(old->f_version, fiop->f_version, sizeof(old->f_version)); 2365254219Scy} 2366254219Scy 2367254219Scy 2368254219Scystatic void 2369254219Scyipnat_4_1_14_to_current(old, current, size) 2370254219Scy ipnat_4_1_14_t *old; 2371254219Scy void *current; 2372254219Scy int size; 2373254219Scy{ 2374254219Scy ipnat_t *np = (ipnat_t *)current; 2375254219Scy 2376254219Scy np->in_space = old->in_space; 2377254219Scy np->in_hv[0] = old->in_hv; 2378254219Scy np->in_hv[1] = old->in_hv; 2379254219Scy np->in_flineno = old->in_flineno; 2380254219Scy if (old->in_redir == NAT_REDIRECT) 2381254219Scy np->in_dpnext = old->in_pnext; 2382254219Scy else 2383254219Scy np->in_spnext = old->in_pnext; 2384254219Scy np->in_v[0] = old->in_v; 2385254219Scy np->in_v[1] = old->in_v; 2386254219Scy np->in_flags = old->in_flags; 2387254219Scy np->in_mssclamp = old->in_mssclamp; 2388254219Scy np->in_age[0] = old->in_age[0]; 2389254219Scy np->in_age[1] = old->in_age[1]; 2390254219Scy np->in_redir = old->in_redir; 2391254219Scy np->in_pr[0] = old->in_p; 2392254219Scy np->in_pr[1] = old->in_p; 2393254219Scy if (np->in_redir == NAT_REDIRECT) { 2394254219Scy np->in_ndst.na_nextaddr = old->in_next6; 2395254219Scy np->in_ndst.na_addr[0] = old->in_in[0]; 2396254219Scy np->in_ndst.na_addr[1] = old->in_in[1]; 2397254219Scy np->in_ndst.na_atype = FRI_NORMAL; 2398254219Scy np->in_odst.na_addr[0] = old->in_out[0]; 2399254219Scy np->in_odst.na_addr[1] = old->in_out[1]; 2400254219Scy np->in_odst.na_atype = FRI_NORMAL; 2401254219Scy np->in_osrc.na_addr[0] = old->in_src[0]; 2402254219Scy np->in_osrc.na_addr[1] = old->in_src[1]; 2403254219Scy np->in_osrc.na_atype = FRI_NORMAL; 2404254219Scy } else { 2405254219Scy np->in_nsrc.na_nextaddr = old->in_next6; 2406254219Scy np->in_nsrc.na_addr[0] = old->in_out[0]; 2407254219Scy np->in_nsrc.na_addr[1] = old->in_out[1]; 2408254219Scy np->in_nsrc.na_atype = FRI_NORMAL; 2409254219Scy np->in_osrc.na_addr[0] = old->in_in[0]; 2410254219Scy np->in_osrc.na_addr[1] = old->in_in[1]; 2411254219Scy np->in_osrc.na_atype = FRI_NORMAL; 2412254219Scy np->in_odst.na_addr[0] = old->in_src[0]; 2413254219Scy np->in_odst.na_addr[1] = old->in_src[1]; 2414254219Scy np->in_odst.na_atype = FRI_NORMAL; 2415254219Scy } 2416254219Scy ipfv4tuctov5(&old->in_tuc, &np->in_tuc); 2417254219Scy if (np->in_redir == NAT_REDIRECT) { 2418254219Scy np->in_dpmin = old->in_port[0]; 2419254219Scy np->in_dpmax = old->in_port[1]; 2420254219Scy } else { 2421254219Scy np->in_spmin = old->in_port[0]; 2422254219Scy np->in_spmax = old->in_port[1]; 2423254219Scy } 2424254219Scy np->in_ppip = old->in_ppip; 2425254219Scy np->in_ippip = old->in_ippip; 2426254219Scy np->in_tag = old->in_tag; 2427254219Scy 2428254219Scy np->in_namelen = 0; 2429254219Scy np->in_plabel = -1; 2430254219Scy np->in_ifnames[0] = -1; 2431254219Scy np->in_ifnames[1] = -1; 2432254219Scy 2433254219Scy if (size == 0) { 2434254219Scy np->in_size = sizeof(*np); 2435254219Scy np->in_size += LIFNAMSIZ * 2 + APR_LABELLEN; 2436254219Scy np->in_size += 3; 2437254219Scy } else { 2438254219Scy int nlen = np->in_namelen; 2439254219Scy char *names = np->in_names; 2440254219Scy 2441254219Scy if (old->in_ifnames[0][0] != '\0') { 2442254219Scy np->in_ifnames[0] = nlen; 2443254219Scy nlen = ipf_addfrstr(names, nlen, old->in_ifnames[0], 2444254219Scy LIFNAMSIZ); 2445254219Scy } 2446254219Scy if (old->in_ifnames[1][0] != '\0') { 2447254219Scy np->in_ifnames[0] = nlen; 2448254219Scy nlen = ipf_addfrstr(names, nlen, old->in_ifnames[1], 2449254219Scy LIFNAMSIZ); 2450254219Scy } 2451254219Scy if (old->in_plabel[0] != '\0') { 2452254219Scy np->in_plabel = nlen; 2453254219Scy nlen = ipf_addfrstr(names, nlen, old->in_plabel, 2454254219Scy LIFNAMSIZ); 2455254219Scy } 2456254219Scy np->in_namelen = nlen; 2457254219Scy np->in_size = size; 2458254219Scy } 2459254219Scy} 2460254219Scy 2461254219Scy 2462254219Scystatic void 2463254219Scyipnat_4_1_0_to_current(old, current, size) 2464254219Scy ipnat_4_1_0_t *old; 2465254219Scy void *current; 2466254219Scy int size; 2467254219Scy{ 2468254219Scy ipnat_t *np = (ipnat_t *)current; 2469254219Scy 2470254219Scy np->in_space = old->in_space; 2471254219Scy np->in_hv[0] = old->in_hv; 2472254219Scy np->in_hv[1] = old->in_hv; 2473254219Scy np->in_flineno = old->in_flineno; 2474254219Scy if (old->in_redir == NAT_REDIRECT) 2475254219Scy np->in_dpnext = old->in_pnext; 2476254219Scy else 2477254219Scy np->in_spnext = old->in_pnext; 2478254219Scy np->in_v[0] = old->in_v; 2479254219Scy np->in_v[1] = old->in_v; 2480254219Scy np->in_flags = old->in_flags; 2481254219Scy np->in_mssclamp = old->in_mssclamp; 2482254219Scy np->in_age[0] = old->in_age[0]; 2483254219Scy np->in_age[1] = old->in_age[1]; 2484254219Scy np->in_redir = old->in_redir; 2485254219Scy np->in_pr[0] = old->in_p; 2486254219Scy np->in_pr[1] = old->in_p; 2487254219Scy if (np->in_redir == NAT_REDIRECT) { 2488254219Scy np->in_ndst.na_nextaddr = old->in_next6; 2489254219Scy bcopy(&old->in_in, &np->in_ndst.na_addr, sizeof(old->in_in)); 2490254219Scy bcopy(&old->in_out, &np->in_odst.na_addr, sizeof(old->in_out)); 2491254219Scy bcopy(&old->in_src, &np->in_osrc.na_addr, sizeof(old->in_src)); 2492254219Scy } else { 2493254219Scy np->in_nsrc.na_nextaddr = old->in_next6; 2494254219Scy bcopy(&old->in_in, &np->in_osrc.na_addr, sizeof(old->in_in)); 2495254219Scy bcopy(&old->in_out, &np->in_nsrc.na_addr, sizeof(old->in_out)); 2496254219Scy bcopy(&old->in_src, &np->in_odst.na_addr, sizeof(old->in_src)); 2497254219Scy } 2498254219Scy ipfv4tuctov5(&old->in_tuc, &np->in_tuc); 2499254219Scy if (np->in_redir == NAT_REDIRECT) { 2500254219Scy np->in_dpmin = old->in_port[0]; 2501254219Scy np->in_dpmax = old->in_port[1]; 2502254219Scy } else { 2503254219Scy np->in_spmin = old->in_port[0]; 2504254219Scy np->in_spmax = old->in_port[1]; 2505254219Scy } 2506254219Scy np->in_ppip = old->in_ppip; 2507254219Scy np->in_ippip = old->in_ippip; 2508254219Scy bcopy(&old->in_tag, &np->in_tag, sizeof(np->in_tag)); 2509254219Scy 2510254219Scy np->in_namelen = 0; 2511254219Scy np->in_plabel = -1; 2512254219Scy np->in_ifnames[0] = -1; 2513254219Scy np->in_ifnames[1] = -1; 2514254219Scy 2515254219Scy if (size == 0) { 2516254219Scy np->in_size = sizeof(*np); 2517254219Scy np->in_size += LIFNAMSIZ * 2 + APR_LABELLEN; 2518254219Scy np->in_size += 3; 2519254219Scy } else { 2520254219Scy int nlen = np->in_namelen; 2521254219Scy char *names = np->in_names; 2522254219Scy 2523254219Scy if (old->in_ifnames[0][0] != '\0') { 2524254219Scy np->in_ifnames[0] = nlen; 2525254219Scy nlen = ipf_addfrstr(names, nlen, old->in_ifnames[0], 2526254219Scy LIFNAMSIZ); 2527254219Scy } 2528254219Scy if (old->in_ifnames[1][0] != '\0') { 2529254219Scy np->in_ifnames[0] = nlen; 2530254219Scy nlen = ipf_addfrstr(names, nlen, old->in_ifnames[1], 2531254219Scy LIFNAMSIZ); 2532254219Scy } 2533254219Scy if (old->in_plabel[0] != '\0') { 2534254219Scy np->in_plabel = nlen; 2535254219Scy nlen = ipf_addfrstr(names, nlen, old->in_plabel, 2536254219Scy LIFNAMSIZ); 2537254219Scy } 2538254219Scy np->in_namelen = nlen; 2539254219Scy np->in_size = size; 2540254219Scy } 2541254219Scy} 2542254219Scy 2543254219Scy 2544254219Scystatic void 2545254219Scyfrauth_4_1_32_to_current(old, current) 2546254219Scy frauth_4_1_32_t *old; 2547254219Scy void *current; 2548254219Scy{ 2549254219Scy frauth_t *fra = (frauth_t *)current; 2550254219Scy 2551254219Scy fra->fra_age = old->fra_age; 2552254219Scy fra->fra_len = old->fra_len; 2553254219Scy fra->fra_index = old->fra_index; 2554254219Scy fra->fra_pass = old->fra_pass; 2555254219Scy fr_info_4_1_32_to_current(&old->fra_info, &fra->fra_info); 2556254219Scy fra->fra_buf = old->fra_buf; 2557254219Scy fra->fra_flx = old->fra_flx; 2558254219Scy#ifdef MENTAT 2559254219Scy fra->fra_q = old->fra_q; 2560254219Scy fra->fra_m = old->fra_m; 2561254219Scy#endif 2562254219Scy} 2563254219Scy 2564254219Scy 2565254219Scystatic void 2566254219Scyfrauth_4_1_29_to_current(old, current) 2567254219Scy frauth_4_1_29_t *old; 2568254219Scy void *current; 2569254219Scy{ 2570254219Scy frauth_t *fra = (frauth_t *)current; 2571254219Scy 2572254219Scy fra->fra_age = old->fra_age; 2573254219Scy fra->fra_len = old->fra_len; 2574254219Scy fra->fra_index = old->fra_index; 2575254219Scy fra->fra_pass = old->fra_pass; 2576254219Scy fr_info_4_1_24_to_current(&old->fra_info, &fra->fra_info); 2577254219Scy fra->fra_buf = old->fra_buf; 2578254219Scy fra->fra_flx = old->fra_flx; 2579254219Scy#ifdef MENTAT 2580254219Scy fra->fra_q = old->fra_q; 2581254219Scy fra->fra_m = old->fra_m; 2582254219Scy#endif 2583254219Scy} 2584254219Scy 2585254219Scy 2586254219Scystatic void 2587254219Scyfrauth_4_1_24_to_current(old, current) 2588254219Scy frauth_4_1_24_t *old; 2589254219Scy void *current; 2590254219Scy{ 2591254219Scy frauth_t *fra = (frauth_t *)current; 2592254219Scy 2593254219Scy fra->fra_age = old->fra_age; 2594254219Scy fra->fra_len = old->fra_len; 2595254219Scy fra->fra_index = old->fra_index; 2596254219Scy fra->fra_pass = old->fra_pass; 2597254219Scy fr_info_4_1_24_to_current(&old->fra_info, &fra->fra_info); 2598254219Scy fra->fra_buf = old->fra_buf; 2599254219Scy#ifdef MENTAT 2600254219Scy fra->fra_q = old->fra_q; 2601254219Scy fra->fra_m = old->fra_m; 2602254219Scy#endif 2603254219Scy} 2604254219Scy 2605254219Scy 2606254219Scystatic void 2607254219Scyfrauth_4_1_23_to_current(old, current) 2608254219Scy frauth_4_1_23_t *old; 2609254219Scy void *current; 2610254219Scy{ 2611254219Scy frauth_t *fra = (frauth_t *)current; 2612254219Scy 2613254219Scy fra->fra_age = old->fra_age; 2614254219Scy fra->fra_len = old->fra_len; 2615254219Scy fra->fra_index = old->fra_index; 2616254219Scy fra->fra_pass = old->fra_pass; 2617254219Scy fr_info_4_1_23_to_current(&old->fra_info, &fra->fra_info); 2618254219Scy fra->fra_buf = old->fra_buf; 2619254219Scy#ifdef MENTAT 2620254219Scy fra->fra_q = old->fra_q; 2621254219Scy fra->fra_m = old->fra_m; 2622254219Scy#endif 2623254219Scy} 2624254219Scy 2625254219Scy 2626254219Scystatic void 2627254219Scyfrauth_4_1_11_to_current(old, current) 2628254219Scy frauth_4_1_11_t *old; 2629254219Scy void *current; 2630254219Scy{ 2631254219Scy frauth_t *fra = (frauth_t *)current; 2632254219Scy 2633254219Scy fra->fra_age = old->fra_age; 2634254219Scy fra->fra_len = old->fra_len; 2635254219Scy fra->fra_index = old->fra_index; 2636254219Scy fra->fra_pass = old->fra_pass; 2637254219Scy fr_info_4_1_11_to_current(&old->fra_info, &fra->fra_info); 2638254219Scy fra->fra_buf = old->fra_buf; 2639254219Scy#ifdef MENTAT 2640254219Scy fra->fra_q = old->fra_q; 2641254219Scy fra->fra_m = old->fra_m; 2642254219Scy#endif 2643254219Scy} 2644254219Scy 2645254219Scy 2646254219Scystatic void 2647254219Scyfr_info_4_1_32_to_current(old, current) 2648254219Scy fr_info_4_1_32_t *old; 2649254219Scy void *current; 2650254219Scy{ 2651254219Scy fr_info_t *fin = (fr_info_t *)current; 2652254219Scy 2653254219Scy fin->fin_ifp = old->fin_ifp; 2654254219Scy ipf_v4iptov5(&old->fin_fi, &fin->fin_fi); 2655254219Scy bcopy(&old->fin_dat, &fin->fin_dat, sizeof(old->fin_dat)); 2656254219Scy fin->fin_out = old->fin_out; 2657254219Scy fin->fin_rev = old->fin_rev; 2658254219Scy fin->fin_hlen = old->fin_hlen; 2659254219Scy fin->fin_tcpf = old->ofin_tcpf; 2660254219Scy fin->fin_icode = old->fin_icode; 2661254219Scy fin->fin_rule = old->fin_rule; 2662254219Scy bcopy(old->fin_group, fin->fin_group, sizeof(old->fin_group)); 2663254219Scy fin->fin_fr = old->fin_fr; 2664254219Scy fin->fin_dp = old->fin_dp; 2665254219Scy fin->fin_dlen = old->fin_dlen; 2666254219Scy fin->fin_plen = old->fin_plen; 2667254219Scy fin->fin_ipoff = old->fin_ipoff; 2668254219Scy fin->fin_id = old->fin_id; 2669254219Scy fin->fin_off = old->fin_off; 2670254219Scy fin->fin_depth = old->fin_depth; 2671254219Scy fin->fin_error = old->fin_error; 2672254219Scy fin->fin_cksum = old->fin_cksum; 2673254219Scy fin->fin_nattag = old->fin_nattag; 2674254219Scy fin->fin_ip = old->ofin_ip; 2675254219Scy fin->fin_mp = old->fin_mp; 2676254219Scy fin->fin_m = old->fin_m; 2677254219Scy#ifdef MENTAT 2678254219Scy fin->fin_qfm = old->fin_qfm; 2679254219Scy fin->fin_qpi = old->fin_qpi; 2680254219Scy#endif 2681254219Scy#ifdef __sgi 2682254219Scy fin->fin_hbuf = old->fin_hbuf; 2683254219Scy#endif 2684254219Scy} 2685254219Scy 2686254219Scy 2687254219Scystatic void 2688254219Scyfr_info_4_1_24_to_current(old, current) 2689254219Scy fr_info_4_1_24_t *old; 2690254219Scy void *current; 2691254219Scy{ 2692254219Scy fr_info_t *fin = (fr_info_t *)current; 2693254219Scy 2694254219Scy fin->fin_ifp = old->fin_ifp; 2695254219Scy ipf_v4iptov5(&old->fin_fi, &fin->fin_fi); 2696254219Scy bcopy(&old->fin_dat, &fin->fin_dat, sizeof(old->fin_dat)); 2697254219Scy fin->fin_out = old->fin_out; 2698254219Scy fin->fin_rev = old->fin_rev; 2699254219Scy fin->fin_hlen = old->fin_hlen; 2700254219Scy fin->fin_tcpf = old->ofin_tcpf; 2701254219Scy fin->fin_icode = old->fin_icode; 2702254219Scy fin->fin_rule = old->fin_rule; 2703254219Scy bcopy(old->fin_group, fin->fin_group, sizeof(old->fin_group)); 2704254219Scy fin->fin_fr = old->fin_fr; 2705254219Scy fin->fin_dp = old->fin_dp; 2706254219Scy fin->fin_dlen = old->fin_dlen; 2707254219Scy fin->fin_plen = old->fin_plen; 2708254219Scy fin->fin_ipoff = old->fin_ipoff; 2709254219Scy fin->fin_id = old->fin_id; 2710254219Scy fin->fin_off = old->fin_off; 2711254219Scy fin->fin_depth = old->fin_depth; 2712254219Scy fin->fin_error = old->fin_error; 2713254219Scy fin->fin_cksum = old->fin_cksum; 2714254219Scy fin->fin_nattag = old->fin_nattag; 2715254219Scy fin->fin_ip = old->ofin_ip; 2716254219Scy fin->fin_mp = old->fin_mp; 2717254219Scy fin->fin_m = old->fin_m; 2718254219Scy#ifdef MENTAT 2719254219Scy fin->fin_qfm = old->fin_qfm; 2720254219Scy fin->fin_qpi = old->fin_qpi; 2721254219Scy#endif 2722254219Scy#ifdef __sgi 2723254219Scy fin->fin_hbuf = old->fin_hbuf; 2724254219Scy#endif 2725254219Scy} 2726254219Scy 2727254219Scy 2728254219Scystatic void 2729254219Scyfr_info_4_1_23_to_current(old, current) 2730254219Scy fr_info_4_1_23_t *old; 2731254219Scy void *current; 2732254219Scy{ 2733254219Scy fr_info_t *fin = (fr_info_t *)current; 2734254219Scy 2735254219Scy fin->fin_ifp = old->fin_ifp; 2736254219Scy ipf_v4iptov5(&old->fin_fi, &fin->fin_fi); 2737254219Scy bcopy(&old->fin_dat, &fin->fin_dat, sizeof(old->fin_dat)); 2738254219Scy fin->fin_out = old->fin_out; 2739254219Scy fin->fin_rev = old->fin_rev; 2740254219Scy fin->fin_hlen = old->fin_hlen; 2741254219Scy fin->fin_tcpf = old->ofin_tcpf; 2742254219Scy fin->fin_icode = old->fin_icode; 2743254219Scy fin->fin_rule = old->fin_rule; 2744254219Scy bcopy(old->fin_group, fin->fin_group, sizeof(old->fin_group)); 2745254219Scy fin->fin_fr = old->fin_fr; 2746254219Scy fin->fin_dp = old->fin_dp; 2747254219Scy fin->fin_dlen = old->fin_dlen; 2748254219Scy fin->fin_plen = old->fin_plen; 2749254219Scy fin->fin_ipoff = old->fin_ipoff; 2750254219Scy fin->fin_id = old->fin_id; 2751254219Scy fin->fin_off = old->fin_off; 2752254219Scy fin->fin_depth = old->fin_depth; 2753254219Scy fin->fin_error = old->fin_error; 2754254219Scy fin->fin_nattag = old->fin_nattag; 2755254219Scy fin->fin_ip = old->ofin_ip; 2756254219Scy fin->fin_mp = old->fin_mp; 2757254219Scy fin->fin_m = old->fin_m; 2758254219Scy#ifdef MENTAT 2759254219Scy fin->fin_qfm = old->fin_qfm; 2760254219Scy fin->fin_qpi = old->fin_qpi; 2761254219Scy#endif 2762254219Scy#ifdef __sgi 2763254219Scy fin->fin_hbuf = fin->fin_hbuf; 2764254219Scy#endif 2765254219Scy} 2766254219Scy 2767254219Scy 2768254219Scystatic void 2769254219Scyfr_info_4_1_11_to_current(old, current) 2770254219Scy fr_info_4_1_11_t *old; 2771254219Scy void *current; 2772254219Scy{ 2773254219Scy fr_info_t *fin = (fr_info_t *)current; 2774254219Scy 2775254219Scy fin->fin_ifp = old->fin_ifp; 2776254219Scy ipf_v4iptov5(&old->fin_fi, &fin->fin_fi); 2777254219Scy bcopy(&old->fin_dat, &fin->fin_dat, sizeof(old->fin_dat)); 2778254219Scy fin->fin_out = old->fin_out; 2779254219Scy fin->fin_rev = old->fin_rev; 2780254219Scy fin->fin_hlen = old->fin_hlen; 2781254219Scy fin->fin_tcpf = old->ofin_tcpf; 2782254219Scy fin->fin_icode = old->fin_icode; 2783254219Scy fin->fin_rule = old->fin_rule; 2784254219Scy bcopy(old->fin_group, fin->fin_group, sizeof(old->fin_group)); 2785254219Scy fin->fin_fr = old->fin_fr; 2786254219Scy fin->fin_dp = old->fin_dp; 2787254219Scy fin->fin_dlen = old->fin_dlen; 2788254219Scy fin->fin_plen = old->fin_plen; 2789254219Scy fin->fin_ipoff = old->fin_ipoff; 2790254219Scy fin->fin_id = old->fin_id; 2791254219Scy fin->fin_off = old->fin_off; 2792254219Scy fin->fin_depth = old->fin_depth; 2793254219Scy fin->fin_error = old->fin_error; 2794254219Scy fin->fin_nattag = old->fin_nattag; 2795254219Scy fin->fin_ip = old->ofin_ip; 2796254219Scy fin->fin_mp = old->fin_mp; 2797254219Scy fin->fin_m = old->fin_m; 2798254219Scy#ifdef MENTAT 2799254219Scy fin->fin_qfm = old->fin_qfm; 2800254219Scy fin->fin_qpi = old->fin_qpi; 2801254219Scy#endif 2802254219Scy#ifdef __sgi 2803254219Scy fin->fin_hbuf = fin->fin_hbuf; 2804254219Scy#endif 2805254219Scy} 2806254219Scy 2807254219Scy 2808254219Scystatic void 2809254219Scynat_4_1_3_to_current(nat_4_1_3_t *old, nat_t *current) 2810254219Scy{ 2811254219Scy bzero((void *)current, sizeof(*current)); 2812254219Scy bcopy((void *)old, (void *)current, sizeof(*old)); 2813254219Scy} 2814254219Scy 2815254219Scy 2816254219Scystatic void 2817254219Scynat_4_1_14_to_current(nat_4_1_14_t *old, nat_t *current) 2818254219Scy{ 2819254219Scy bzero((void *)current, sizeof(*current)); 2820254219Scy bcopy((void *)old, (void *)current, sizeof(*old)); 2821254219Scy} 2822254219Scy 2823254219Scy 2824254219Scystatic void 2825254219Scynat_save_4_1_16_to_current(softc, old, current) 2826254219Scy ipf_main_softc_t *softc; 2827254219Scy nat_save_4_1_16_t *old; 2828254219Scy void *current; 2829254219Scy{ 2830254219Scy nat_save_t *nats = (nat_save_t *)current; 2831254219Scy 2832254219Scy nats->ipn_next = old->ipn_next; 2833254219Scy nat_4_1_14_to_current(&old->ipn_nat, &nats->ipn_nat); 2834254219Scy bcopy(&old->ipn_ipnat, &nats->ipn_ipnat, sizeof(old->ipn_ipnat)); 2835254219Scy frentry_4_1_16_to_current(softc, &old->ipn_fr, &nats->ipn_fr, 0); 2836254219Scy nats->ipn_dsize = old->ipn_dsize; 2837254219Scy bcopy(old->ipn_data, nats->ipn_data, sizeof(nats->ipn_data)); 2838254219Scy} 2839254219Scy 2840254219Scy 2841254219Scystatic void 2842254219Scynat_save_4_1_14_to_current(softc, old, current) 2843254219Scy ipf_main_softc_t *softc; 2844254219Scy nat_save_4_1_14_t *old; 2845254219Scy void *current; 2846254219Scy{ 2847254219Scy nat_save_t *nats = (nat_save_t *)current; 2848254219Scy 2849254219Scy nats->ipn_next = old->ipn_next; 2850254219Scy nat_4_1_14_to_current(&old->ipn_nat, &nats->ipn_nat); 2851254219Scy bcopy(&old->ipn_ipnat, &nats->ipn_ipnat, sizeof(old->ipn_ipnat)); 2852254219Scy frentry_4_1_0_to_current(softc, &old->ipn_fr, &nats->ipn_fr, 0); 2853254219Scy nats->ipn_dsize = old->ipn_dsize; 2854254219Scy bcopy(old->ipn_data, nats->ipn_data, sizeof(nats->ipn_data)); 2855254219Scy} 2856254219Scy 2857254219Scy 2858254219Scystatic void 2859254219Scynat_save_4_1_3_to_current(softc, old, current) 2860254219Scy ipf_main_softc_t *softc; 2861254219Scy nat_save_4_1_3_t *old; 2862254219Scy void *current; 2863254219Scy{ 2864254219Scy nat_save_t *nats = (nat_save_t *)current; 2865254219Scy 2866254219Scy nats->ipn_next = old->ipn_next; 2867254219Scy nat_4_1_3_to_current(&old->ipn_nat, &nats->ipn_nat); 2868254219Scy ipnat_4_1_0_to_current(&old->ipn_ipnat, &nats->ipn_ipnat, 0); 2869254219Scy frentry_4_1_0_to_current(softc, &old->ipn_fr, &nats->ipn_fr, 0); 2870254219Scy nats->ipn_dsize = old->ipn_dsize; 2871254219Scy bcopy(old->ipn_data, nats->ipn_data, sizeof(nats->ipn_data)); 2872254219Scy} 2873254219Scy 2874254219Scy 2875254219Scystatic void 2876254219Scynatstat_current_to_4_1_32(current, old) 2877254219Scy void *current; 2878254219Scy natstat_4_1_32_t *old; 2879254219Scy{ 2880254219Scy natstat_t *ns = (natstat_t *)current; 2881254219Scy 2882254219Scy old->ns_mapped[0] = ns->ns_side[0].ns_translated; 2883254219Scy old->ns_mapped[1] = ns->ns_side[1].ns_translated; 2884254219Scy old->ns_rules = ns->ns_side[0].ns_inuse + ns->ns_side[1].ns_inuse; 2885254219Scy old->ns_added = ns->ns_side[0].ns_added + ns->ns_side[1].ns_added; 2886254219Scy old->ns_expire = ns->ns_expire; 2887254219Scy old->ns_inuse = ns->ns_side[0].ns_inuse + ns->ns_side[1].ns_inuse; 2888254219Scy old->ns_logged = ns->ns_log_ok; 2889254219Scy old->ns_logfail = ns->ns_log_fail; 2890254219Scy old->ns_memfail = ns->ns_side[0].ns_memfail + ns->ns_side[1].ns_memfail; 2891254219Scy old->ns_badnat = ns->ns_side[0].ns_badnat + ns->ns_side[1].ns_badnat; 2892254219Scy old->ns_addtrpnt = ns->ns_addtrpnt; 2893254219Scy old->ns_table[0] = ns->ns_side[0].ns_table; 2894254219Scy old->ns_table[1] = ns->ns_side[1].ns_table; 2895254219Scy old->ns_maptable = NULL; 2896254219Scy old->ns_list = ns->ns_list; 2897254219Scy old->ns_apslist = NULL; 2898254219Scy old->ns_wilds = ns->ns_wilds; 2899254219Scy old->ns_nattab_sz = ns->ns_nattab_sz; 2900254219Scy old->ns_nattab_max = ns->ns_nattab_max; 2901254219Scy old->ns_rultab_sz = ns->ns_rultab_sz; 2902254219Scy old->ns_rdrtab_sz = ns->ns_rdrtab_sz; 2903254219Scy old->ns_trpntab_sz = ns->ns_trpntab_sz; 2904254219Scy old->ns_hostmap_sz = 0; 2905254219Scy old->ns_instances = ns->ns_instances; 2906254219Scy old->ns_maplist = ns->ns_maplist; 2907254219Scy old->ns_bucketlen[0] = (u_long *)ns->ns_side[0].ns_bucketlen; 2908254219Scy old->ns_bucketlen[1] = (u_long *)ns->ns_side[1].ns_bucketlen; 2909254219Scy old->ns_ticks = ns->ns_ticks; 2910254219Scy old->ns_orphans = ns->ns_orphans; 2911254219Scy old->ns_uncreate[0][0] = ns->ns_side[0].ns_uncreate[0]; 2912254219Scy old->ns_uncreate[0][1] = ns->ns_side[0].ns_uncreate[1]; 2913254219Scy old->ns_uncreate[1][0] = ns->ns_side[1].ns_uncreate[0]; 2914254219Scy old->ns_uncreate[1][1] = ns->ns_side[1].ns_uncreate[1]; 2915254219Scy} 2916254219Scy 2917254219Scy 2918254219Scystatic void 2919254219Scynatstat_current_to_4_1_27(current, old) 2920254219Scy void *current; 2921254219Scy natstat_4_1_27_t *old; 2922254219Scy{ 2923254219Scy natstat_t *ns = (natstat_t *)current; 2924254219Scy 2925254219Scy old->ns_mapped[0] = ns->ns_side[0].ns_translated; 2926254219Scy old->ns_mapped[1] = ns->ns_side[1].ns_translated; 2927254219Scy old->ns_rules = ns->ns_side[0].ns_inuse + ns->ns_side[1].ns_inuse; 2928254219Scy old->ns_added = ns->ns_side[0].ns_added + ns->ns_side[1].ns_added; 2929254219Scy old->ns_expire = ns->ns_expire; 2930254219Scy old->ns_inuse = ns->ns_side[0].ns_inuse + ns->ns_side[1].ns_inuse; 2931254219Scy old->ns_logged = ns->ns_log_ok; 2932254219Scy old->ns_logfail = ns->ns_log_fail; 2933254219Scy old->ns_memfail = ns->ns_side[0].ns_memfail + ns->ns_side[1].ns_memfail; 2934254219Scy old->ns_badnat = ns->ns_side[0].ns_badnat + ns->ns_side[1].ns_badnat; 2935254219Scy old->ns_addtrpnt = ns->ns_addtrpnt; 2936254219Scy old->ns_table[0] = ns->ns_side[0].ns_table; 2937254219Scy old->ns_table[1] = ns->ns_side[1].ns_table; 2938254219Scy old->ns_maptable = NULL; 2939254219Scy old->ns_list = ns->ns_list; 2940254219Scy old->ns_apslist = NULL; 2941254219Scy old->ns_wilds = ns->ns_wilds; 2942254219Scy old->ns_nattab_sz = ns->ns_nattab_sz; 2943254219Scy old->ns_nattab_max = ns->ns_nattab_max; 2944254219Scy old->ns_rultab_sz = ns->ns_rultab_sz; 2945254219Scy old->ns_rdrtab_sz = ns->ns_rdrtab_sz; 2946254219Scy old->ns_trpntab_sz = ns->ns_trpntab_sz; 2947254219Scy old->ns_hostmap_sz = 0; 2948254219Scy old->ns_instances = ns->ns_instances; 2949254219Scy old->ns_maplist = ns->ns_maplist; 2950254219Scy old->ns_bucketlen[0] = (u_long *)ns->ns_side[0].ns_bucketlen; 2951254219Scy old->ns_bucketlen[1] = (u_long *)ns->ns_side[1].ns_bucketlen; 2952254219Scy old->ns_ticks = ns->ns_ticks; 2953254219Scy old->ns_orphans = ns->ns_orphans; 2954254219Scy} 2955254219Scy 2956254219Scy 2957254219Scystatic void 2958254219Scynatstat_current_to_4_1_16(current, old) 2959254219Scy void *current; 2960254219Scy natstat_4_1_16_t *old; 2961254219Scy{ 2962254219Scy natstat_t *ns = (natstat_t *)current; 2963254219Scy 2964254219Scy old->ns_mapped[0] = ns->ns_side[0].ns_translated; 2965254219Scy old->ns_mapped[1] = ns->ns_side[1].ns_translated; 2966254219Scy old->ns_rules = ns->ns_side[0].ns_inuse + ns->ns_side[1].ns_inuse; 2967254219Scy old->ns_added = ns->ns_side[0].ns_added + ns->ns_side[1].ns_added; 2968254219Scy old->ns_expire = ns->ns_expire; 2969254219Scy old->ns_inuse = ns->ns_side[0].ns_inuse + ns->ns_side[1].ns_inuse; 2970254219Scy old->ns_logged = ns->ns_log_ok; 2971254219Scy old->ns_logfail = ns->ns_log_fail; 2972254219Scy old->ns_memfail = ns->ns_side[0].ns_memfail + ns->ns_side[1].ns_memfail; 2973254219Scy old->ns_badnat = ns->ns_side[0].ns_badnat + ns->ns_side[1].ns_badnat; 2974254219Scy old->ns_addtrpnt = ns->ns_addtrpnt; 2975254219Scy old->ns_table[0] = ns->ns_side[0].ns_table; 2976254219Scy old->ns_table[1] = ns->ns_side[1].ns_table; 2977254219Scy old->ns_maptable = NULL; 2978254219Scy old->ns_list = ns->ns_list; 2979254219Scy old->ns_apslist = NULL; 2980254219Scy old->ns_wilds = ns->ns_wilds; 2981254219Scy old->ns_nattab_sz = ns->ns_nattab_sz; 2982254219Scy old->ns_nattab_max = ns->ns_nattab_max; 2983254219Scy old->ns_rultab_sz = ns->ns_rultab_sz; 2984254219Scy old->ns_rdrtab_sz = ns->ns_rdrtab_sz; 2985254219Scy old->ns_trpntab_sz = ns->ns_trpntab_sz; 2986254219Scy old->ns_hostmap_sz = 0; 2987254219Scy old->ns_instances = ns->ns_instances; 2988254219Scy old->ns_maplist = ns->ns_maplist; 2989254219Scy old->ns_bucketlen[0] = (u_long *)ns->ns_side[0].ns_bucketlen; 2990254219Scy old->ns_bucketlen[1] = (u_long *)ns->ns_side[1].ns_bucketlen; 2991254219Scy old->ns_ticks = ns->ns_ticks; 2992254219Scy} 2993254219Scy 2994254219Scy 2995254219Scystatic void 2996254219Scynatstat_current_to_4_1_0(current, old) 2997254219Scy void *current; 2998254219Scy natstat_4_1_0_t *old; 2999254219Scy{ 3000254219Scy natstat_t *ns = (natstat_t *)current; 3001254219Scy 3002254219Scy old->ns_mapped[0] = ns->ns_side[0].ns_translated; 3003254219Scy old->ns_mapped[1] = ns->ns_side[1].ns_translated; 3004254219Scy old->ns_rules = ns->ns_side[0].ns_inuse + ns->ns_side[1].ns_inuse; 3005254219Scy old->ns_added = ns->ns_side[0].ns_added + ns->ns_side[1].ns_added; 3006254219Scy old->ns_expire = ns->ns_expire; 3007254219Scy old->ns_inuse = ns->ns_side[0].ns_inuse + ns->ns_side[1].ns_inuse; 3008254219Scy old->ns_logged = ns->ns_log_ok; 3009254219Scy old->ns_logfail = ns->ns_log_fail; 3010254219Scy old->ns_memfail = ns->ns_side[0].ns_memfail + ns->ns_side[1].ns_memfail; 3011254219Scy old->ns_badnat = ns->ns_side[0].ns_badnat + ns->ns_side[1].ns_badnat; 3012254219Scy old->ns_addtrpnt = ns->ns_addtrpnt; 3013254219Scy old->ns_table[0] = ns->ns_side[0].ns_table; 3014254219Scy old->ns_table[1] = ns->ns_side[1].ns_table; 3015254219Scy old->ns_maptable = NULL; 3016254219Scy old->ns_list = ns->ns_list; 3017254219Scy old->ns_apslist = NULL; 3018254219Scy old->ns_wilds = ns->ns_wilds; 3019254219Scy old->ns_nattab_sz = ns->ns_nattab_sz; 3020254219Scy old->ns_nattab_max = ns->ns_nattab_max; 3021254219Scy old->ns_rultab_sz = ns->ns_rultab_sz; 3022254219Scy old->ns_rdrtab_sz = ns->ns_rdrtab_sz; 3023254219Scy old->ns_trpntab_sz = ns->ns_trpntab_sz; 3024254219Scy old->ns_hostmap_sz = 0; 3025254219Scy old->ns_instances = ns->ns_instances; 3026254219Scy old->ns_maplist = ns->ns_maplist; 3027254219Scy old->ns_bucketlen[0] = (u_long *)ns->ns_side[0].ns_bucketlen; 3028254219Scy old->ns_bucketlen[1] = (u_long *)ns->ns_side[1].ns_bucketlen; 3029254219Scy} 3030254219Scy 3031254219Scy 3032254219Scystatic void 3033254219Scyipstate_save_current_to_4_1_16(current, old) 3034254219Scy void *current; 3035254219Scy ipstate_save_4_1_16_t *old; 3036254219Scy{ 3037254219Scy ipstate_save_t *ips = (ipstate_save_t *)current; 3038254219Scy 3039254219Scy old->ips_next = ips->ips_next; 3040254219Scy ipstate_current_to_4_1_0(&ips->ips_is, &old->ips_is); 3041254219Scy frentry_current_to_4_1_16(&ips->ips_fr, &old->ips_fr); 3042254219Scy} 3043254219Scy 3044254219Scy 3045254219Scystatic void 3046254219Scyipstate_save_current_to_4_1_0(current, old) 3047254219Scy void *current; 3048254219Scy ipstate_save_4_1_0_t *old; 3049254219Scy{ 3050254219Scy ipstate_save_t *ips = (ipstate_save_t *)current; 3051254219Scy 3052254219Scy old->ips_next = ips->ips_next; 3053254219Scy ipstate_current_to_4_1_0(&ips->ips_is, &old->ips_is); 3054254219Scy frentry_current_to_4_1_0(&ips->ips_fr, &old->ips_fr); 3055254219Scy} 3056254219Scy 3057254219Scy 3058254219Scyint 3059254219Scyipf_out_compat(softc, obj, ptr) 3060254219Scy ipf_main_softc_t *softc; 3061254219Scy ipfobj_t *obj; 3062254219Scy void *ptr; 3063254219Scy{ 3064254219Scy frentry_t *fr; 3065254219Scy int error; 3066254219Scy 3067254219Scy IPFERROR(140042); 3068254219Scy error = EINVAL; 3069254219Scy 3070254219Scy switch (obj->ipfo_type) 3071254219Scy { 3072254219Scy default : 3073254219Scy break; 3074254219Scy 3075254219Scy case IPFOBJ_FRENTRY : 3076254219Scy if (obj->ipfo_rev >= 4013400) { 3077254219Scy frentry_4_1_34_t *old; 3078254219Scy 3079254219Scy KMALLOC(old, frentry_4_1_34_t *); 3080254219Scy if (old == NULL) { 3081254219Scy IPFERROR(140043); 3082254219Scy error = ENOMEM; 3083254219Scy break; 3084254219Scy } 3085254219Scy frentry_current_to_4_1_34(ptr, old); 3086254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3087254219Scy if (error == 0 && old->fr_dsize > 0) { 3088254219Scy char *dst = obj->ipfo_ptr; 3089254219Scy 3090254219Scy fr = ptr; 3091254219Scy dst += sizeof(*old); 3092254219Scy error = COPYOUT(fr->fr_data, dst, 3093254219Scy old->fr_dsize); 3094254219Scy if (error != 0) { 3095254219Scy IPFERROR(140044); 3096254219Scy } 3097254219Scy } 3098254219Scy KFREE(old); 3099254219Scy obj->ipfo_size = sizeof(*old); 3100254219Scy } else if (obj->ipfo_rev >= 4011600) { 3101254219Scy frentry_4_1_16_t *old; 3102254219Scy 3103254219Scy KMALLOC(old, frentry_4_1_16_t *); 3104254219Scy if (old == NULL) { 3105254219Scy IPFERROR(140045); 3106254219Scy error = ENOMEM; 3107254219Scy break; 3108254219Scy } 3109254219Scy frentry_current_to_4_1_16(ptr, old); 3110254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3111254219Scy if (error != 0) { 3112254219Scy IPFERROR(140046); 3113254219Scy } 3114254219Scy KFREE(old); 3115254219Scy obj->ipfo_size = sizeof(*old); 3116254219Scy } else { 3117254219Scy frentry_4_1_0_t *old; 3118254219Scy 3119254219Scy KMALLOC(old, frentry_4_1_0_t *); 3120254219Scy if (old == NULL) { 3121254219Scy IPFERROR(140047); 3122254219Scy error = ENOMEM; 3123254219Scy break; 3124254219Scy } 3125254219Scy frentry_current_to_4_1_0(ptr, old); 3126254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3127254219Scy if (error != 0) { 3128254219Scy IPFERROR(140048); 3129254219Scy } 3130254219Scy KFREE(old); 3131254219Scy obj->ipfo_size = sizeof(*old); 3132254219Scy } 3133254219Scy break; 3134254219Scy 3135254219Scy case IPFOBJ_IPFSTAT : 3136254219Scy if (obj->ipfo_rev >= 4013300) { 3137254219Scy friostat_4_1_33_t *old; 3138254219Scy 3139254219Scy KMALLOC(old, friostat_4_1_33_t *); 3140254219Scy if (old == NULL) { 3141254219Scy IPFERROR(140049); 3142254219Scy error = ENOMEM; 3143254219Scy break; 3144254219Scy } 3145254219Scy friostat_current_to_4_1_33(ptr, old, obj->ipfo_rev); 3146254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3147254219Scy if (error != 0) { 3148254219Scy IPFERROR(140050); 3149254219Scy } 3150254219Scy KFREE(old); 3151254219Scy } else { 3152254219Scy friostat_4_1_0_t *old; 3153254219Scy 3154254219Scy KMALLOC(old, friostat_4_1_0_t *); 3155254219Scy if (old == NULL) { 3156254219Scy IPFERROR(140051); 3157254219Scy error = ENOMEM; 3158254219Scy break; 3159254219Scy } 3160254219Scy friostat_current_to_4_1_0(ptr, old, obj->ipfo_rev); 3161254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3162254219Scy if (error != 0) { 3163254219Scy IPFERROR(140052); 3164254219Scy } 3165254219Scy KFREE(old); 3166254219Scy } 3167254219Scy break; 3168254219Scy 3169254219Scy case IPFOBJ_IPFINFO : /* unused */ 3170254219Scy break; 3171254219Scy 3172254219Scy case IPFOBJ_IPNAT : 3173254219Scy if (obj->ipfo_rev >= 4011400) { 3174254219Scy ipnat_4_1_14_t *old; 3175254219Scy 3176254219Scy KMALLOC(old, ipnat_4_1_14_t *); 3177254219Scy if (old == NULL) { 3178254219Scy IPFERROR(140053); 3179254219Scy error = ENOMEM; 3180254219Scy break; 3181254219Scy } 3182254219Scy ipnat_current_to_4_1_14(ptr, old); 3183254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3184254219Scy if (error != 0) { 3185254219Scy IPFERROR(140054); 3186254219Scy } 3187254219Scy KFREE(old); 3188254219Scy } else { 3189254219Scy ipnat_4_1_0_t *old; 3190254219Scy 3191254219Scy KMALLOC(old, ipnat_4_1_0_t *); 3192254219Scy if (old == NULL) { 3193254219Scy IPFERROR(140055); 3194254219Scy error = ENOMEM; 3195254219Scy break; 3196254219Scy } 3197254219Scy ipnat_current_to_4_1_0(ptr, old); 3198254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3199254219Scy if (error != 0) { 3200254219Scy IPFERROR(140056); 3201254219Scy } 3202254219Scy KFREE(old); 3203254219Scy } 3204254219Scy break; 3205254219Scy 3206254219Scy case IPFOBJ_NATSTAT : 3207254219Scy if (obj->ipfo_rev >= 4013200) { 3208254219Scy natstat_4_1_32_t *old; 3209254219Scy 3210254219Scy KMALLOC(old, natstat_4_1_32_t *); 3211254219Scy if (old == NULL) { 3212254219Scy IPFERROR(140057); 3213254219Scy error = ENOMEM; 3214254219Scy break; 3215254219Scy } 3216254219Scy natstat_current_to_4_1_32(ptr, old); 3217254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3218254219Scy if (error != 0) { 3219254219Scy IPFERROR(140058); 3220254219Scy } 3221254219Scy KFREE(old); 3222254219Scy } else if (obj->ipfo_rev >= 4012700) { 3223254219Scy natstat_4_1_27_t *old; 3224254219Scy 3225254219Scy KMALLOC(old, natstat_4_1_27_t *); 3226254219Scy if (old == NULL) { 3227254219Scy IPFERROR(140059); 3228254219Scy error = ENOMEM; 3229254219Scy break; 3230254219Scy } 3231254219Scy natstat_current_to_4_1_27(ptr, old); 3232254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3233254219Scy if (error != 0) { 3234254219Scy IPFERROR(140060); 3235254219Scy } 3236254219Scy KFREE(old); 3237254219Scy } else if (obj->ipfo_rev >= 4011600) { 3238254219Scy natstat_4_1_16_t *old; 3239254219Scy 3240254219Scy KMALLOC(old, natstat_4_1_16_t *); 3241254219Scy if (old == NULL) { 3242254219Scy IPFERROR(140061); 3243254219Scy error = ENOMEM; 3244254219Scy break; 3245254219Scy } 3246254219Scy natstat_current_to_4_1_16(ptr, old); 3247254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3248254219Scy if (error != 0) { 3249254219Scy IPFERROR(140062); 3250254219Scy } 3251254219Scy KFREE(old); 3252254219Scy } else { 3253254219Scy natstat_4_1_0_t *old; 3254254219Scy 3255254219Scy KMALLOC(old, natstat_4_1_0_t *); 3256254219Scy if (old == NULL) { 3257254219Scy IPFERROR(140063); 3258254219Scy error = ENOMEM; 3259254219Scy break; 3260254219Scy } 3261254219Scy natstat_current_to_4_1_0(ptr, old); 3262254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3263254219Scy if (error != 0) { 3264254219Scy IPFERROR(140064); 3265254219Scy } 3266254219Scy KFREE(old); 3267254219Scy } 3268254219Scy break; 3269254219Scy 3270254219Scy case IPFOBJ_STATESAVE : 3271254219Scy if (obj->ipfo_rev >= 4011600) { 3272254219Scy ipstate_save_4_1_16_t *old; 3273254219Scy 3274254219Scy KMALLOC(old, ipstate_save_4_1_16_t *); 3275254219Scy if (old == NULL) { 3276254219Scy IPFERROR(140065); 3277254219Scy error = ENOMEM; 3278254219Scy break; 3279254219Scy } 3280254219Scy ipstate_save_current_to_4_1_16(ptr, old); 3281254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3282254219Scy if (error != 0) { 3283254219Scy IPFERROR(140066); 3284254219Scy } 3285254219Scy KFREE(old); 3286254219Scy } else { 3287254219Scy ipstate_save_4_1_0_t *old; 3288254219Scy 3289254219Scy KMALLOC(old, ipstate_save_4_1_0_t *); 3290254219Scy if (old == NULL) { 3291254219Scy IPFERROR(140067); 3292254219Scy error = ENOMEM; 3293254219Scy break; 3294254219Scy } 3295254219Scy ipstate_save_current_to_4_1_0(ptr, old); 3296254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3297254219Scy if (error != 0) { 3298254219Scy IPFERROR(140068); 3299254219Scy } 3300254219Scy KFREE(old); 3301254219Scy } 3302254219Scy break; 3303254219Scy 3304254219Scy case IPFOBJ_NATSAVE : 3305254219Scy if (obj->ipfo_rev >= 4011600) { 3306254219Scy nat_save_4_1_16_t *old16; 3307254219Scy 3308254219Scy KMALLOC(old16, nat_save_4_1_16_t *); 3309254219Scy if (old16 == NULL) { 3310254219Scy IPFERROR(140069); 3311254219Scy error = ENOMEM; 3312254219Scy break; 3313254219Scy } 3314254219Scy nat_save_current_to_4_1_16(ptr, old16); 3315254219Scy error = COPYOUT(&old16, obj->ipfo_ptr, sizeof(*old16)); 3316254219Scy if (error != 0) { 3317254219Scy IPFERROR(140070); 3318254219Scy } 3319254219Scy KFREE(old16); 3320254219Scy } else if (obj->ipfo_rev >= 4011400) { 3321254219Scy nat_save_4_1_14_t *old14; 3322254219Scy 3323254219Scy KMALLOC(old14, nat_save_4_1_14_t *); 3324254219Scy if (old14 == NULL) { 3325254219Scy IPFERROR(140071); 3326254219Scy error = ENOMEM; 3327254219Scy break; 3328254219Scy } 3329254219Scy nat_save_current_to_4_1_14(ptr, old14); 3330254219Scy error = COPYOUT(&old14, obj->ipfo_ptr, sizeof(*old14)); 3331254219Scy if (error != 0) { 3332254219Scy IPFERROR(140072); 3333254219Scy } 3334254219Scy KFREE(old14); 3335254219Scy } else if (obj->ipfo_rev >= 4010300) { 3336254219Scy nat_save_4_1_3_t *old3; 3337254219Scy 3338254219Scy KMALLOC(old3, nat_save_4_1_3_t *); 3339254219Scy if (old3 == NULL) { 3340254219Scy IPFERROR(140073); 3341254219Scy error = ENOMEM; 3342254219Scy break; 3343254219Scy } 3344254219Scy nat_save_current_to_4_1_3(ptr, old3); 3345254219Scy error = COPYOUT(&old3, obj->ipfo_ptr, sizeof(*old3)); 3346254219Scy if (error != 0) { 3347254219Scy IPFERROR(140074); 3348254219Scy } 3349254219Scy KFREE(old3); 3350254219Scy } 3351254219Scy break; 3352254219Scy 3353254219Scy case IPFOBJ_IPSTATE : 3354254219Scy if (obj->ipfo_rev >= 4011600) { 3355254219Scy ipstate_4_1_16_t *old; 3356254219Scy 3357254219Scy KMALLOC(old, ipstate_4_1_16_t *); 3358254219Scy if (old == NULL) { 3359254219Scy IPFERROR(140075); 3360254219Scy error = ENOMEM; 3361254219Scy break; 3362254219Scy } 3363254219Scy ipstate_current_to_4_1_16(ptr, old); 3364254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3365254219Scy if (error != 0) { 3366254219Scy IPFERROR(140076); 3367254219Scy } 3368254219Scy KFREE(old); 3369254219Scy } else { 3370254219Scy ipstate_4_1_0_t *old; 3371254219Scy 3372254219Scy KMALLOC(old, ipstate_4_1_0_t *); 3373254219Scy if (old == NULL) { 3374254219Scy IPFERROR(140077); 3375254219Scy error = ENOMEM; 3376254219Scy break; 3377254219Scy } 3378254219Scy ipstate_current_to_4_1_0(ptr, old); 3379254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3380254219Scy if (error != 0) { 3381254219Scy IPFERROR(140078); 3382254219Scy } 3383254219Scy KFREE(old); 3384254219Scy } 3385254219Scy break; 3386254219Scy 3387254219Scy case IPFOBJ_STATESTAT : 3388254219Scy if (obj->ipfo_rev >= 4012100) { 3389254219Scy ips_stat_4_1_21_t *old; 3390254219Scy 3391254219Scy KMALLOC(old, ips_stat_4_1_21_t *); 3392254219Scy if (old == NULL) { 3393254219Scy IPFERROR(140079); 3394254219Scy error = ENOMEM; 3395254219Scy break; 3396254219Scy } 3397254219Scy ips_stat_current_to_4_1_21(ptr, old); 3398254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3399254219Scy if (error != 0) { 3400254219Scy IPFERROR(140080); 3401254219Scy } 3402254219Scy KFREE(old); 3403254219Scy } else { 3404254219Scy ips_stat_4_1_0_t *old; 3405254219Scy 3406254219Scy KMALLOC(old, ips_stat_4_1_0_t *); 3407254219Scy if (old == NULL) { 3408254219Scy IPFERROR(140081); 3409254219Scy error = ENOMEM; 3410254219Scy break; 3411254219Scy } 3412254219Scy ips_stat_current_to_4_1_0(ptr, old); 3413254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3414254219Scy if (error != 0) { 3415254219Scy IPFERROR(140082); 3416254219Scy } 3417254219Scy KFREE(old); 3418254219Scy } 3419254219Scy break; 3420254219Scy 3421254219Scy case IPFOBJ_FRAUTH : 3422254219Scy if (obj->ipfo_rev >= 4012900) { 3423254219Scy frauth_4_1_29_t *old29; 3424254219Scy 3425254219Scy KMALLOC(old29, frauth_4_1_29_t *); 3426254219Scy if (old29 == NULL) { 3427254219Scy IPFERROR(140083); 3428254219Scy error = ENOMEM; 3429254219Scy break; 3430254219Scy } 3431254219Scy frauth_current_to_4_1_29(ptr, old29); 3432254219Scy error = COPYOUT(old29, obj->ipfo_ptr, sizeof(*old29)); 3433254219Scy if (error != 0) { 3434254219Scy IPFERROR(140084); 3435254219Scy } 3436254219Scy KFREE(old29); 3437254219Scy } else if (obj->ipfo_rev >= 4012400) { 3438254219Scy frauth_4_1_24_t *old24; 3439254219Scy 3440254219Scy KMALLOC(old24, frauth_4_1_24_t *); 3441254219Scy if (old24 == NULL) { 3442254219Scy IPFERROR(140085); 3443254219Scy error = ENOMEM; 3444254219Scy break; 3445254219Scy } 3446254219Scy frauth_current_to_4_1_24(ptr, old24); 3447254219Scy error = COPYOUT(old24, obj->ipfo_ptr, sizeof(*old24)); 3448254219Scy if (error != 0) { 3449254219Scy IPFERROR(140086); 3450254219Scy } 3451254219Scy KFREE(old24); 3452254219Scy } else if (obj->ipfo_rev >= 4012300) { 3453254219Scy frauth_4_1_23_t *old23; 3454254219Scy 3455254219Scy KMALLOC(old23, frauth_4_1_23_t *); 3456254219Scy if (old23 == NULL) { 3457254219Scy IPFERROR(140087); 3458254219Scy error = ENOMEM; 3459254219Scy break; 3460254219Scy } 3461254219Scy frauth_current_to_4_1_23(ptr, old23); 3462254219Scy error = COPYOUT(old23, obj->ipfo_ptr, sizeof(*old23)); 3463254219Scy if (error != 0) { 3464254219Scy IPFERROR(140088); 3465254219Scy } 3466254219Scy KFREE(old23); 3467254219Scy } else if (obj->ipfo_rev >= 4011100) { 3468254219Scy frauth_4_1_11_t *old11; 3469254219Scy 3470254219Scy KMALLOC(old11, frauth_4_1_11_t *); 3471254219Scy if (old11 == NULL) { 3472254219Scy IPFERROR(140089); 3473254219Scy error = ENOMEM; 3474254219Scy break; 3475254219Scy } 3476254219Scy frauth_current_to_4_1_11(ptr, old11); 3477254219Scy error = COPYOUT(old11, obj->ipfo_ptr, sizeof(*old11)); 3478254219Scy if (error != 0) { 3479254219Scy IPFERROR(140090); 3480254219Scy } 3481254219Scy KFREE(old11); 3482254219Scy } 3483254219Scy break; 3484254219Scy 3485254219Scy case IPFOBJ_NAT : 3486254219Scy if (obj->ipfo_rev >= 4012500) { 3487254219Scy nat_4_1_25_t *old; 3488254219Scy 3489254219Scy KMALLOC(old, nat_4_1_25_t *); 3490254219Scy if (old == NULL) { 3491254219Scy IPFERROR(140091); 3492254219Scy error = ENOMEM; 3493254219Scy break; 3494254219Scy } 3495254219Scy nat_current_to_4_1_25(ptr, old); 3496254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3497254219Scy if (error != 0) { 3498254219Scy IPFERROR(140092); 3499254219Scy } 3500254219Scy KFREE(old); 3501254219Scy } else if (obj->ipfo_rev >= 4011400) { 3502254219Scy nat_4_1_14_t *old; 3503254219Scy 3504254219Scy KMALLOC(old, nat_4_1_14_t *); 3505254219Scy if (old == NULL) { 3506254219Scy IPFERROR(140093); 3507254219Scy error = ENOMEM; 3508254219Scy break; 3509254219Scy } 3510254219Scy nat_current_to_4_1_14(ptr, old); 3511254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3512254219Scy if (error != 0) { 3513254219Scy IPFERROR(140094); 3514254219Scy } 3515254219Scy KFREE(old); 3516254219Scy } else if (obj->ipfo_rev >= 4010300) { 3517254219Scy nat_4_1_3_t *old; 3518254219Scy 3519254219Scy KMALLOC(old, nat_4_1_3_t *); 3520254219Scy if (old == NULL) { 3521254219Scy IPFERROR(140095); 3522254219Scy error = ENOMEM; 3523254219Scy break; 3524254219Scy } 3525254219Scy nat_current_to_4_1_3(ptr, old); 3526254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3527254219Scy if (error != 0) { 3528254219Scy IPFERROR(140096); 3529254219Scy } 3530254219Scy KFREE(old); 3531254219Scy } 3532254219Scy break; 3533254219Scy 3534254219Scy case IPFOBJ_FRIPF : 3535254219Scy if (obj->ipfo_rev < 5000000) { 3536254219Scy fripf4_t *old; 3537254219Scy 3538254219Scy KMALLOC(old, fripf4_t *); 3539254219Scy if (old == NULL) { 3540254219Scy IPFERROR(140097); 3541254219Scy error = ENOMEM; 3542254219Scy break; 3543254219Scy } 3544254219Scy ipf_v5fripftov4(ptr, old); 3545254219Scy error = COPYOUT(old, obj->ipfo_ptr, sizeof(*old)); 3546254219Scy if (error != 0) { 3547254219Scy IPFERROR(140098); 3548254219Scy } 3549254219Scy KFREE(old); 3550254219Scy } 3551254219Scy break; 3552254219Scy } 3553254219Scy return error; 3554254219Scy} 3555254219Scy 3556254219Scy 3557254219Scystatic void 3558254219Scyfriostat_current_to_4_1_33(current, old, rev) 3559254219Scy void *current; 3560254219Scy friostat_4_1_33_t *old; 3561254219Scy int rev; 3562254219Scy{ 3563254219Scy friostat_t *fiop = (friostat_t *)current; 3564254219Scy 3565254219Scy bcopy(&fiop->f_st[0].fr_pass, &old->of_st[0], sizeof(old->of_st[0])); 3566254219Scy bcopy(&fiop->f_st[1].fr_pass, &old->of_st[1], sizeof(old->of_st[1])); 3567254219Scy 3568254219Scy old->f_ipf[0][0] = fiop->f_ipf[0][0]; 3569254219Scy old->f_ipf[0][1] = fiop->f_ipf[0][1]; 3570254219Scy old->f_ipf[1][0] = fiop->f_ipf[1][0]; 3571254219Scy old->f_ipf[1][1] = fiop->f_ipf[1][1]; 3572254219Scy old->f_acct[0][0] = fiop->f_acct[0][0]; 3573254219Scy old->f_acct[0][1] = fiop->f_acct[0][1]; 3574254219Scy old->f_acct[1][0] = fiop->f_acct[1][0]; 3575254219Scy old->f_acct[1][1] = fiop->f_acct[1][1]; 3576254219Scy old->f_ipf6[0][0] = NULL; 3577254219Scy old->f_ipf6[0][1] = NULL; 3578254219Scy old->f_ipf6[1][0] = NULL; 3579254219Scy old->f_ipf6[1][1] = NULL; 3580254219Scy old->f_acct6[0][0] = NULL; 3581254219Scy old->f_acct6[0][1] = NULL; 3582254219Scy old->f_acct6[1][0] = NULL; 3583254219Scy old->f_acct6[1][1] = NULL; 3584254219Scy old->f_auth = fiop->f_auth; 3585254219Scy bcopy(&fiop->f_groups, &old->f_groups, sizeof(old->f_groups)); 3586254219Scy bcopy(&fiop->f_froute, &old->f_froute, sizeof(old->f_froute)); 3587254219Scy old->f_ticks = fiop->f_ticks; 3588254219Scy bcopy(&fiop->f_locks, &old->f_locks, sizeof(old->f_locks)); 3589254219Scy old->f_kmutex_sz = 0; 3590254219Scy old->f_krwlock_sz = 0; 3591254219Scy old->f_defpass = fiop->f_defpass; 3592254219Scy old->f_active = fiop->f_active; 3593254219Scy old->f_running = fiop->f_running; 3594254219Scy old->f_logging = fiop->f_logging; 3595254219Scy old->f_features = fiop->f_features; 3596254219Scy sprintf(old->f_version, "IP Filter: v%d.%d.%d", 3597254219Scy (rev / 1000000) % 100, 3598254219Scy (rev / 10000) % 100, 3599254219Scy (rev / 100) % 100); 3600254219Scy} 3601254219Scy 3602254219Scy 3603254219Scystatic void 3604254219Scyfriostat_current_to_4_1_0(current, old, rev) 3605254219Scy void *current; 3606254219Scy friostat_4_1_0_t *old; 3607254219Scy int rev; 3608254219Scy{ 3609254219Scy friostat_t *fiop = (friostat_t *)current; 3610254219Scy 3611254219Scy bcopy(&fiop->f_st[0].fr_pass, &old->of_st[0], sizeof(old->of_st[0])); 3612254219Scy bcopy(&fiop->f_st[1].fr_pass, &old->of_st[1], sizeof(old->of_st[1])); 3613254219Scy 3614254219Scy old->f_ipf[0][0] = fiop->f_ipf[0][0]; 3615254219Scy old->f_ipf[0][1] = fiop->f_ipf[0][1]; 3616254219Scy old->f_ipf[1][0] = fiop->f_ipf[1][0]; 3617254219Scy old->f_ipf[1][1] = fiop->f_ipf[1][1]; 3618254219Scy old->f_acct[0][0] = fiop->f_acct[0][0]; 3619254219Scy old->f_acct[0][1] = fiop->f_acct[0][1]; 3620254219Scy old->f_acct[1][0] = fiop->f_acct[1][0]; 3621254219Scy old->f_acct[1][1] = fiop->f_acct[1][1]; 3622254219Scy old->f_ipf6[0][0] = NULL; 3623254219Scy old->f_ipf6[0][1] = NULL; 3624254219Scy old->f_ipf6[1][0] = NULL; 3625254219Scy old->f_ipf6[1][1] = NULL; 3626254219Scy old->f_acct6[0][0] = NULL; 3627254219Scy old->f_acct6[0][1] = NULL; 3628254219Scy old->f_acct6[1][0] = NULL; 3629254219Scy old->f_acct6[1][1] = NULL; 3630254219Scy old->f_auth = fiop->f_auth; 3631254219Scy bcopy(&fiop->f_groups, &old->f_groups, sizeof(old->f_groups)); 3632254219Scy bcopy(&fiop->f_froute, &old->f_froute, sizeof(old->f_froute)); 3633254219Scy old->f_ticks = fiop->f_ticks; 3634254219Scy old->f_ipf[0][0] = fiop->f_ipf[0][0]; 3635254219Scy old->f_ipf[0][1] = fiop->f_ipf[0][1]; 3636254219Scy old->f_ipf[1][0] = fiop->f_ipf[1][0]; 3637254219Scy old->f_ipf[1][1] = fiop->f_ipf[1][1]; 3638254219Scy old->f_acct[0][0] = fiop->f_acct[0][0]; 3639254219Scy old->f_acct[0][1] = fiop->f_acct[0][1]; 3640254219Scy old->f_acct[1][0] = fiop->f_acct[1][0]; 3641254219Scy old->f_acct[1][1] = fiop->f_acct[1][1]; 3642254219Scy old->f_ipf6[0][0] = NULL; 3643254219Scy old->f_ipf6[0][1] = NULL; 3644254219Scy old->f_ipf6[1][0] = NULL; 3645254219Scy old->f_ipf6[1][1] = NULL; 3646254219Scy old->f_acct6[0][0] = NULL; 3647254219Scy old->f_acct6[0][1] = NULL; 3648254219Scy old->f_acct6[1][0] = NULL; 3649254219Scy old->f_acct6[1][1] = NULL; 3650254219Scy old->f_auth = fiop->f_auth; 3651254219Scy bcopy(&fiop->f_groups, &old->f_groups, sizeof(old->f_groups)); 3652254219Scy bcopy(&fiop->f_froute, &old->f_froute, sizeof(old->f_froute)); 3653254219Scy old->f_ticks = fiop->f_ticks; 3654254219Scy bcopy(&fiop->f_locks, &old->f_locks, sizeof(old->f_locks)); 3655254219Scy old->f_kmutex_sz = 0; 3656254219Scy old->f_krwlock_sz = 0; 3657254219Scy old->f_defpass = fiop->f_defpass; 3658254219Scy old->f_active = fiop->f_active; 3659254219Scy old->f_running = fiop->f_running; 3660254219Scy old->f_logging = fiop->f_logging; 3661254219Scy old->f_features = fiop->f_features; 3662254219Scy sprintf(old->f_version, "IP Filter: v%d.%d.%d", 3663254219Scy (rev / 1000000) % 100, 3664254219Scy (rev / 10000) % 100, 3665254219Scy (rev / 100) % 100); 3666254219Scy} 3667254219Scy 3668254219Scy 3669254219Scy/* 3670254219Scy * nflags is v5 flags, returns v4 flags. 3671254219Scy */ 3672254219Scystatic int 3673254219Scyfr_frflags5to4(nflags) 3674254219Scy u_32_t nflags; 3675254219Scy{ 3676254219Scy u_32_t oflags = 0; 3677254219Scy 3678254219Scy switch (nflags & FR_CMDMASK) { 3679254219Scy case FR_CALL : 3680254219Scy oflags = 0x0; 3681254219Scy break; 3682254219Scy case FR_BLOCK : 3683254219Scy oflags = 0x1; 3684254219Scy break; 3685254219Scy case FR_PASS : 3686254219Scy oflags = 0x2; 3687254219Scy break; 3688254219Scy case FR_AUTH : 3689254219Scy oflags = 0x3; 3690254219Scy break; 3691254219Scy case FR_PREAUTH : 3692254219Scy oflags = 0x4; 3693254219Scy break; 3694254219Scy case FR_ACCOUNT : 3695254219Scy oflags = 0x5; 3696254219Scy break; 3697254219Scy case FR_SKIP : 3698254219Scy oflags = 0x6; 3699254219Scy break; 3700254219Scy default : 3701254219Scy break; 3702254219Scy } 3703254219Scy 3704254219Scy if (nflags & FR_LOG) 3705254219Scy oflags |= 0x00010; 3706254219Scy if (nflags & FR_CALLNOW) 3707254219Scy oflags |= 0x00020; 3708254219Scy if (nflags & FR_NOTSRCIP) 3709254219Scy oflags |= 0x00080; 3710254219Scy if (nflags & FR_NOTDSTIP) 3711254219Scy oflags |= 0x00040; 3712254219Scy if (nflags & FR_QUICK) 3713254219Scy oflags |= 0x00100; 3714254219Scy if (nflags & FR_KEEPFRAG) 3715254219Scy oflags |= 0x00200; 3716254219Scy if (nflags & FR_KEEPSTATE) 3717254219Scy oflags |= 0x00400; 3718254219Scy if (nflags & FR_FASTROUTE) 3719254219Scy oflags |= 0x00800; 3720254219Scy if (nflags & FR_RETRST) 3721254219Scy oflags |= 0x01000; 3722254219Scy if (nflags & FR_RETICMP) 3723254219Scy oflags |= 0x02000; 3724254219Scy if (nflags & FR_FAKEICMP) 3725254219Scy oflags |= 0x03000; 3726254219Scy if (nflags & FR_OUTQUE) 3727254219Scy oflags |= 0x04000; 3728254219Scy if (nflags & FR_INQUE) 3729254219Scy oflags |= 0x08000; 3730254219Scy if (nflags & FR_LOGBODY) 3731254219Scy oflags |= 0x10000; 3732254219Scy if (nflags & FR_LOGFIRST) 3733254219Scy oflags |= 0x20000; 3734254219Scy if (nflags & FR_LOGORBLOCK) 3735254219Scy oflags |= 0x40000; 3736254219Scy if (nflags & FR_FRSTRICT) 3737254219Scy oflags |= 0x100000; 3738254219Scy if (nflags & FR_STSTRICT) 3739254219Scy oflags |= 0x200000; 3740254219Scy if (nflags & FR_NEWISN) 3741254219Scy oflags |= 0x400000; 3742254219Scy if (nflags & FR_NOICMPERR) 3743254219Scy oflags |= 0x800000; 3744254219Scy if (nflags & FR_STATESYNC) 3745254219Scy oflags |= 0x1000000; 3746254219Scy if (nflags & FR_NOMATCH) 3747254219Scy oflags |= 0x8000000; 3748254219Scy if (nflags & FR_COPIED) 3749254219Scy oflags |= 0x40000000; 3750254219Scy if (nflags & FR_INACTIVE) 3751254219Scy oflags |= 0x80000000; 3752254219Scy 3753254219Scy return oflags; 3754254219Scy} 3755254219Scy 3756254219Scy 3757254219Scystatic void 3758254219Scyfrentry_current_to_4_1_34(current, old) 3759254219Scy void *current; 3760254219Scy frentry_4_1_34_t *old; 3761254219Scy{ 3762254219Scy frentry_t *fr = (frentry_t *)current; 3763254219Scy 3764254219Scy old->fr_lock = fr->fr_lock; 3765254219Scy old->fr_next = fr->fr_next; 3766254219Scy old->fr_grp = (void *)fr->fr_grp; 3767254219Scy old->fr_isc = fr->fr_isc; 3768254219Scy old->fr_ifas[0] = fr->fr_ifas[0]; 3769254219Scy old->fr_ifas[1] = fr->fr_ifas[1]; 3770254219Scy old->fr_ifas[2] = fr->fr_ifas[2]; 3771254219Scy old->fr_ifas[3] = fr->fr_ifas[3]; 3772254219Scy old->fr_ptr = fr->fr_ptr; 3773254219Scy old->fr_comment = NULL; 3774254219Scy old->fr_ref = fr->fr_ref; 3775254219Scy old->fr_statecnt = fr->fr_statecnt; 3776254219Scy old->fr_hits = fr->fr_hits; 3777254219Scy old->fr_bytes = fr->fr_bytes; 3778254219Scy old->fr_lastpkt.tv_sec = fr->fr_lastpkt.tv_sec; 3779254219Scy old->fr_lastpkt.tv_usec = fr->fr_lastpkt.tv_usec; 3780254219Scy old->fr_curpps = fr->fr_curpps; 3781254219Scy old->fr_dun.fru_data = fr->fr_dun.fru_data; 3782254219Scy old->fr_func = fr->fr_func; 3783254219Scy old->fr_dsize = fr->fr_dsize; 3784254219Scy old->fr_pps = fr->fr_pps; 3785254219Scy old->fr_statemax = fr->fr_statemax; 3786254219Scy old->fr_flineno = fr->fr_flineno; 3787254219Scy old->fr_type = fr->fr_type; 3788254219Scy old->fr_flags = fr_frflags5to4(fr->fr_flags); 3789254219Scy old->fr_logtag = fr->fr_logtag; 3790254219Scy old->fr_collect = fr->fr_collect; 3791254219Scy old->fr_arg = fr->fr_arg; 3792254219Scy old->fr_loglevel = fr->fr_loglevel; 3793254219Scy old->fr_age[0] = fr->fr_age[0]; 3794254219Scy old->fr_age[1] = fr->fr_age[1]; 3795254219Scy if (fr->fr_family == AF_INET) 3796254219Scy old->fr_v = 4; 3797254219Scy if (fr->fr_family == AF_INET6) 3798254219Scy old->fr_v = 6; 3799254219Scy old->fr_icode = fr->fr_icode; 3800254219Scy old->fr_cksum = fr->fr_cksum; 3801254219Scy old->fr_tifs[0].ofd_ip6 = fr->fr_tifs[0].fd_ip6; 3802254219Scy old->fr_tifs[1].ofd_ip6 = fr->fr_tifs[0].fd_ip6; 3803254219Scy old->fr_dif.ofd_ip6 = fr->fr_dif.fd_ip6; 3804254219Scy if (fr->fr_ifnames[0] >= 0) { 3805254219Scy strncpy(old->fr_ifnames[0], fr->fr_names + fr->fr_ifnames[0], 3806254219Scy LIFNAMSIZ); 3807254219Scy old->fr_ifnames[0][LIFNAMSIZ - 1] = '\0'; 3808254219Scy } 3809254219Scy if (fr->fr_ifnames[1] >= 0) { 3810254219Scy strncpy(old->fr_ifnames[1], fr->fr_names + fr->fr_ifnames[1], 3811254219Scy LIFNAMSIZ); 3812254219Scy old->fr_ifnames[1][LIFNAMSIZ - 1] = '\0'; 3813254219Scy } 3814254219Scy if (fr->fr_ifnames[2] >= 0) { 3815254219Scy strncpy(old->fr_ifnames[2], fr->fr_names + fr->fr_ifnames[2], 3816254219Scy LIFNAMSIZ); 3817254219Scy old->fr_ifnames[2][LIFNAMSIZ - 1] = '\0'; 3818254219Scy } 3819254219Scy if (fr->fr_ifnames[3] >= 0) { 3820254219Scy strncpy(old->fr_ifnames[3], fr->fr_names + fr->fr_ifnames[3], 3821254219Scy LIFNAMSIZ); 3822254219Scy old->fr_ifnames[3][LIFNAMSIZ - 1] = '\0'; 3823254219Scy } 3824254219Scy if (fr->fr_tifs[0].fd_name >= 0) { 3825254219Scy strncpy(old->fr_tifs[0].fd_ifname, 3826254219Scy fr->fr_names + fr->fr_tifs[0].fd_name, LIFNAMSIZ); 3827254219Scy old->fr_tifs[0].fd_ifname[LIFNAMSIZ - 1] = '\0'; 3828254219Scy } 3829254219Scy if (fr->fr_tifs[1].fd_name >= 0) { 3830254219Scy strncpy(old->fr_tifs[1].fd_ifname, 3831254219Scy fr->fr_names + fr->fr_tifs[1].fd_name, LIFNAMSIZ); 3832254219Scy old->fr_tifs[1].fd_ifname[LIFNAMSIZ - 1] = '\0'; 3833254219Scy } 3834254219Scy if (fr->fr_dif.fd_name >= 0) { 3835254219Scy strncpy(old->fr_dif.fd_ifname, 3836254219Scy fr->fr_names + fr->fr_dif.fd_name, LIFNAMSIZ); 3837254219Scy old->fr_dif.fd_ifname[LIFNAMSIZ - 1] = '\0'; 3838254219Scy } 3839254219Scy if (fr->fr_group >= 0) { 3840254219Scy strncpy(old->fr_group, fr->fr_names + fr->fr_group, 3841254219Scy FR_GROUPLEN); 3842254219Scy old->fr_group[FR_GROUPLEN - 1] = '\0'; 3843254219Scy } 3844254219Scy if (fr->fr_grhead >= 0) { 3845254219Scy strncpy(old->fr_grhead, fr->fr_names + fr->fr_grhead, 3846254219Scy FR_GROUPLEN); 3847254219Scy old->fr_grhead[FR_GROUPLEN - 1] = '\0'; 3848254219Scy } 3849254219Scy} 3850254219Scy 3851254219Scy 3852254219Scystatic void 3853254219Scyfrentry_current_to_4_1_16(current, old) 3854254219Scy void *current; 3855254219Scy frentry_4_1_16_t *old; 3856254219Scy{ 3857254219Scy frentry_t *fr = (frentry_t *)current; 3858254219Scy 3859254219Scy old->fr_lock = fr->fr_lock; 3860254219Scy old->fr_next = fr->fr_next; 3861254219Scy old->fr_grp = (void *)fr->fr_grp; 3862254219Scy old->fr_isc = fr->fr_isc; 3863254219Scy old->fr_ifas[0] = fr->fr_ifas[0]; 3864254219Scy old->fr_ifas[1] = fr->fr_ifas[1]; 3865254219Scy old->fr_ifas[2] = fr->fr_ifas[2]; 3866254219Scy old->fr_ifas[3] = fr->fr_ifas[3]; 3867254219Scy old->fr_ptr = fr->fr_ptr; 3868254219Scy old->fr_comment = NULL; 3869254219Scy old->fr_ref = fr->fr_ref; 3870254219Scy old->fr_statecnt = fr->fr_statecnt; 3871254219Scy old->fr_hits = fr->fr_hits; 3872254219Scy old->fr_bytes = fr->fr_bytes; 3873254219Scy old->fr_lastpkt.tv_sec = fr->fr_lastpkt.tv_sec; 3874254219Scy old->fr_lastpkt.tv_usec = fr->fr_lastpkt.tv_usec; 3875254219Scy old->fr_curpps = fr->fr_curpps; 3876254219Scy old->fr_dun.fru_data = fr->fr_dun.fru_data; 3877254219Scy old->fr_func = fr->fr_func; 3878254219Scy old->fr_dsize = fr->fr_dsize; 3879254219Scy old->fr_pps = fr->fr_pps; 3880254219Scy old->fr_statemax = fr->fr_statemax; 3881254219Scy old->fr_flineno = fr->fr_flineno; 3882254219Scy old->fr_type = fr->fr_type; 3883254219Scy old->fr_flags = fr_frflags5to4(fr->fr_flags); 3884254219Scy old->fr_logtag = fr->fr_logtag; 3885254219Scy old->fr_collect = fr->fr_collect; 3886254219Scy old->fr_arg = fr->fr_arg; 3887254219Scy old->fr_loglevel = fr->fr_loglevel; 3888254219Scy old->fr_age[0] = fr->fr_age[0]; 3889254219Scy old->fr_age[1] = fr->fr_age[1]; 3890254219Scy if (old->fr_v == 4) 3891254219Scy fr->fr_family = AF_INET; 3892254219Scy if (old->fr_v == 6) 3893254219Scy fr->fr_family = AF_INET6; 3894254219Scy old->fr_icode = fr->fr_icode; 3895254219Scy old->fr_cksum = fr->fr_cksum; 3896254219Scy old->fr_tifs[0].ofd_ip6 = fr->fr_tifs[0].fd_ip6; 3897254219Scy old->fr_tifs[1].ofd_ip6 = fr->fr_tifs[0].fd_ip6; 3898254219Scy old->fr_dif.ofd_ip6 = fr->fr_dif.fd_ip6; 3899254219Scy if (fr->fr_ifnames[0] >= 0) { 3900254219Scy strncpy(old->fr_ifnames[0], fr->fr_names + fr->fr_ifnames[0], 3901254219Scy LIFNAMSIZ); 3902254219Scy old->fr_ifnames[0][LIFNAMSIZ - 1] = '\0'; 3903254219Scy } 3904254219Scy if (fr->fr_ifnames[1] >= 0) { 3905254219Scy strncpy(old->fr_ifnames[1], fr->fr_names + fr->fr_ifnames[1], 3906254219Scy LIFNAMSIZ); 3907254219Scy old->fr_ifnames[1][LIFNAMSIZ - 1] = '\0'; 3908254219Scy } 3909254219Scy if (fr->fr_ifnames[2] >= 0) { 3910254219Scy strncpy(old->fr_ifnames[2], fr->fr_names + fr->fr_ifnames[2], 3911254219Scy LIFNAMSIZ); 3912254219Scy old->fr_ifnames[2][LIFNAMSIZ - 1] = '\0'; 3913254219Scy } 3914254219Scy if (fr->fr_ifnames[3] >= 0) { 3915254219Scy strncpy(old->fr_ifnames[3], fr->fr_names + fr->fr_ifnames[3], 3916254219Scy LIFNAMSIZ); 3917254219Scy old->fr_ifnames[3][LIFNAMSIZ - 1] = '\0'; 3918254219Scy } 3919254219Scy if (fr->fr_tifs[0].fd_name >= 0) { 3920254219Scy strncpy(old->fr_tifs[0].fd_ifname, 3921254219Scy fr->fr_names + fr->fr_tifs[0].fd_name, LIFNAMSIZ); 3922254219Scy old->fr_tifs[0].fd_ifname[LIFNAMSIZ - 1] = '\0'; 3923254219Scy } 3924254219Scy if (fr->fr_tifs[1].fd_name >= 0) { 3925254219Scy strncpy(old->fr_tifs[1].fd_ifname, 3926254219Scy fr->fr_names + fr->fr_tifs[1].fd_name, LIFNAMSIZ); 3927254219Scy old->fr_tifs[1].fd_ifname[LIFNAMSIZ - 1] = '\0'; 3928254219Scy } 3929254219Scy if (fr->fr_dif.fd_name >= 0) { 3930254219Scy strncpy(old->fr_dif.fd_ifname, 3931254219Scy fr->fr_names + fr->fr_dif.fd_name, LIFNAMSIZ); 3932254219Scy old->fr_dif.fd_ifname[LIFNAMSIZ - 1] = '\0'; 3933254219Scy } 3934254219Scy if (fr->fr_group >= 0) { 3935254219Scy strncpy(old->fr_group, fr->fr_names + fr->fr_group, 3936254219Scy FR_GROUPLEN); 3937254219Scy old->fr_group[FR_GROUPLEN - 1] = '\0'; 3938254219Scy } 3939254219Scy if (fr->fr_grhead >= 0) { 3940254219Scy strncpy(old->fr_grhead, fr->fr_names + fr->fr_grhead, 3941254219Scy FR_GROUPLEN); 3942254219Scy old->fr_grhead[FR_GROUPLEN - 1] = '\0'; 3943254219Scy } 3944254219Scy} 3945254219Scy 3946254219Scy 3947254219Scystatic void 3948254219Scyfrentry_current_to_4_1_0(current, old) 3949254219Scy void *current; 3950254219Scy frentry_4_1_0_t *old; 3951254219Scy{ 3952254219Scy frentry_t *fr = (frentry_t *)current; 3953254219Scy 3954254219Scy old->fr_lock = fr->fr_lock; 3955254219Scy old->fr_next = fr->fr_next; 3956254219Scy old->fr_grp = (void *)fr->fr_grp; 3957254219Scy old->fr_isc = fr->fr_isc; 3958254219Scy old->fr_ifas[0] = fr->fr_ifas[0]; 3959254219Scy old->fr_ifas[1] = fr->fr_ifas[1]; 3960254219Scy old->fr_ifas[2] = fr->fr_ifas[2]; 3961254219Scy old->fr_ifas[3] = fr->fr_ifas[3]; 3962254219Scy old->fr_ptr = fr->fr_ptr; 3963254219Scy old->fr_comment = NULL; 3964254219Scy old->fr_ref = fr->fr_ref; 3965254219Scy old->fr_statecnt = fr->fr_statecnt; 3966254219Scy old->fr_hits = fr->fr_hits; 3967254219Scy old->fr_bytes = fr->fr_bytes; 3968254219Scy old->fr_lastpkt.tv_sec = fr->fr_lastpkt.tv_sec; 3969254219Scy old->fr_lastpkt.tv_usec = fr->fr_lastpkt.tv_usec; 3970254219Scy old->fr_curpps = fr->fr_curpps; 3971254219Scy old->fr_dun.fru_data = fr->fr_dun.fru_data; 3972254219Scy old->fr_func = fr->fr_func; 3973254219Scy old->fr_dsize = fr->fr_dsize; 3974254219Scy old->fr_pps = fr->fr_pps; 3975254219Scy old->fr_statemax = fr->fr_statemax; 3976254219Scy old->fr_flineno = fr->fr_flineno; 3977254219Scy old->fr_type = fr->fr_type; 3978254219Scy old->fr_flags = fr_frflags5to4(fr->fr_flags); 3979254219Scy old->fr_logtag = fr->fr_logtag; 3980254219Scy old->fr_collect = fr->fr_collect; 3981254219Scy old->fr_arg = fr->fr_arg; 3982254219Scy old->fr_loglevel = fr->fr_loglevel; 3983254219Scy old->fr_age[0] = fr->fr_age[0]; 3984254219Scy old->fr_age[1] = fr->fr_age[1]; 3985254219Scy if (old->fr_v == 4) 3986254219Scy fr->fr_family = AF_INET; 3987254219Scy if (old->fr_v == 6) 3988254219Scy fr->fr_family = AF_INET6; 3989254219Scy old->fr_icode = fr->fr_icode; 3990254219Scy old->fr_cksum = fr->fr_cksum; 3991254219Scy old->fr_tifs[0].ofd_ip6 = fr->fr_tifs[0].fd_ip6; 3992254219Scy old->fr_tifs[1].ofd_ip6 = fr->fr_tifs[0].fd_ip6; 3993254219Scy old->fr_dif.ofd_ip6 = fr->fr_dif.fd_ip6; 3994254219Scy if (fr->fr_ifnames[0] >= 0) { 3995254219Scy strncpy(old->fr_ifnames[0], fr->fr_names + fr->fr_ifnames[0], 3996254219Scy LIFNAMSIZ); 3997254219Scy old->fr_ifnames[0][LIFNAMSIZ - 1] = '\0'; 3998254219Scy } 3999254219Scy if (fr->fr_ifnames[1] >= 0) { 4000254219Scy strncpy(old->fr_ifnames[1], fr->fr_names + fr->fr_ifnames[1], 4001254219Scy LIFNAMSIZ); 4002254219Scy old->fr_ifnames[1][LIFNAMSIZ - 1] = '\0'; 4003254219Scy } 4004254219Scy if (fr->fr_ifnames[2] >= 0) { 4005254219Scy strncpy(old->fr_ifnames[2], fr->fr_names + fr->fr_ifnames[2], 4006254219Scy LIFNAMSIZ); 4007254219Scy old->fr_ifnames[2][LIFNAMSIZ - 1] = '\0'; 4008254219Scy } 4009254219Scy if (fr->fr_ifnames[3] >= 0) { 4010254219Scy strncpy(old->fr_ifnames[3], fr->fr_names + fr->fr_ifnames[3], 4011254219Scy LIFNAMSIZ); 4012254219Scy old->fr_ifnames[3][LIFNAMSIZ - 1] = '\0'; 4013254219Scy } 4014254219Scy if (fr->fr_tifs[0].fd_name >= 0) { 4015254219Scy strncpy(old->fr_tifs[0].fd_ifname, 4016254219Scy fr->fr_names + fr->fr_tifs[0].fd_name, LIFNAMSIZ); 4017254219Scy old->fr_tifs[0].fd_ifname[LIFNAMSIZ - 1] = '\0'; 4018254219Scy } 4019254219Scy if (fr->fr_tifs[1].fd_name >= 0) { 4020254219Scy strncpy(old->fr_tifs[1].fd_ifname, 4021254219Scy fr->fr_names + fr->fr_tifs[1].fd_name, LIFNAMSIZ); 4022254219Scy old->fr_tifs[1].fd_ifname[LIFNAMSIZ - 1] = '\0'; 4023254219Scy } 4024254219Scy if (fr->fr_dif.fd_name >= 0) { 4025254219Scy strncpy(old->fr_dif.fd_ifname, 4026254219Scy fr->fr_names + fr->fr_dif.fd_name, LIFNAMSIZ); 4027254219Scy old->fr_dif.fd_ifname[LIFNAMSIZ - 1] = '\0'; 4028254219Scy } 4029254219Scy if (fr->fr_group >= 0) { 4030254219Scy strncpy(old->fr_group, fr->fr_names + fr->fr_group, 4031254219Scy FR_GROUPLEN); 4032254219Scy old->fr_group[FR_GROUPLEN - 1] = '\0'; 4033254219Scy } 4034254219Scy if (fr->fr_grhead >= 0) { 4035254219Scy strncpy(old->fr_grhead, fr->fr_names + fr->fr_grhead, 4036254219Scy FR_GROUPLEN); 4037254219Scy old->fr_grhead[FR_GROUPLEN - 1] = '\0'; 4038254219Scy } 4039254219Scy} 4040254219Scy 4041254219Scy 4042254219Scystatic void 4043254219Scyfr_info_current_to_4_1_24(current, old) 4044254219Scy void *current; 4045254219Scy fr_info_4_1_24_t *old; 4046254219Scy{ 4047254219Scy fr_info_t *fin = (fr_info_t *)current; 4048254219Scy 4049254219Scy old->fin_ifp = fin->fin_ifp; 4050254219Scy ipf_v5iptov4(&fin->fin_fi, &old->fin_fi); 4051254219Scy bcopy(&fin->fin_dat, &old->fin_dat, sizeof(fin->fin_dat)); 4052254219Scy old->fin_out = fin->fin_out; 4053254219Scy old->fin_rev = fin->fin_rev; 4054254219Scy old->fin_hlen = fin->fin_hlen; 4055254219Scy old->ofin_tcpf = fin->fin_tcpf; 4056254219Scy old->fin_icode = fin->fin_icode; 4057254219Scy old->fin_rule = fin->fin_rule; 4058254219Scy bcopy(fin->fin_group, old->fin_group, sizeof(fin->fin_group)); 4059254219Scy old->fin_fr = fin->fin_fr; 4060254219Scy old->fin_dp = fin->fin_dp; 4061254219Scy old->fin_dlen = fin->fin_dlen; 4062254219Scy old->fin_plen = fin->fin_plen; 4063254219Scy old->fin_ipoff = fin->fin_ipoff; 4064254219Scy old->fin_id = fin->fin_id; 4065254219Scy old->fin_off = fin->fin_off; 4066254219Scy old->fin_depth = fin->fin_depth; 4067254219Scy old->fin_error = fin->fin_error; 4068254219Scy old->fin_cksum = fin->fin_cksum; 4069254219Scy old->fin_state = NULL; 4070254219Scy old->fin_nat = NULL; 4071254219Scy old->fin_nattag = fin->fin_nattag; 4072254219Scy old->fin_exthdr = NULL; 4073254219Scy old->ofin_ip = fin->fin_ip; 4074254219Scy old->fin_mp = fin->fin_mp; 4075254219Scy old->fin_m = fin->fin_m; 4076254219Scy#ifdef MENTAT 4077254219Scy old->fin_qfm = fin->fin_qfm; 4078254219Scy old->fin_qpi = fin->fin_qpi; 4079254219Scy old->fin_ifname[0] = '\0'; 4080254219Scy#endif 4081254219Scy#ifdef __sgi 4082254219Scy old->fin_hbuf = fin->fin_hbuf; 4083254219Scy#endif 4084254219Scy} 4085254219Scy 4086254219Scy 4087254219Scystatic void 4088254219Scyfr_info_current_to_4_1_23(current, old) 4089254219Scy void *current; 4090254219Scy fr_info_4_1_23_t *old; 4091254219Scy{ 4092254219Scy fr_info_t *fin = (fr_info_t *)current; 4093254219Scy 4094254219Scy old->fin_ifp = fin->fin_ifp; 4095254219Scy ipf_v5iptov4(&fin->fin_fi, &old->fin_fi); 4096254219Scy bcopy(&fin->fin_dat, &old->fin_dat, sizeof(fin->fin_dat)); 4097254219Scy old->fin_out = fin->fin_out; 4098254219Scy old->fin_rev = fin->fin_rev; 4099254219Scy old->fin_hlen = fin->fin_hlen; 4100254219Scy old->ofin_tcpf = fin->fin_tcpf; 4101254219Scy old->fin_icode = fin->fin_icode; 4102254219Scy old->fin_rule = fin->fin_rule; 4103254219Scy bcopy(fin->fin_group, old->fin_group, sizeof(fin->fin_group)); 4104254219Scy old->fin_fr = fin->fin_fr; 4105254219Scy old->fin_dp = fin->fin_dp; 4106254219Scy old->fin_dlen = fin->fin_dlen; 4107254219Scy old->fin_plen = fin->fin_plen; 4108254219Scy old->fin_ipoff = fin->fin_ipoff; 4109254219Scy old->fin_id = fin->fin_id; 4110254219Scy old->fin_off = fin->fin_off; 4111254219Scy old->fin_depth = fin->fin_depth; 4112254219Scy old->fin_error = fin->fin_error; 4113254219Scy old->fin_state = NULL; 4114254219Scy old->fin_nat = NULL; 4115254219Scy old->fin_nattag = fin->fin_nattag; 4116254219Scy old->ofin_ip = fin->fin_ip; 4117254219Scy old->fin_mp = fin->fin_mp; 4118254219Scy old->fin_m = fin->fin_m; 4119254219Scy#ifdef MENTAT 4120254219Scy old->fin_qfm = fin->fin_qfm; 4121254219Scy old->fin_qpi = fin->fin_qpi; 4122254219Scy old->fin_ifname[0] = '\0'; 4123254219Scy#endif 4124254219Scy#ifdef __sgi 4125254219Scy old->fin_hbuf = fin->fin_hbuf; 4126254219Scy#endif 4127254219Scy} 4128254219Scy 4129254219Scy 4130254219Scystatic void 4131254219Scyfr_info_current_to_4_1_11(current, old) 4132254219Scy void *current; 4133254219Scy fr_info_4_1_11_t *old; 4134254219Scy{ 4135254219Scy fr_info_t *fin = (fr_info_t *)current; 4136254219Scy 4137254219Scy old->fin_ifp = fin->fin_ifp; 4138254219Scy ipf_v5iptov4(&fin->fin_fi, &old->fin_fi); 4139254219Scy bcopy(&fin->fin_dat, &old->fin_dat, sizeof(fin->fin_dat)); 4140254219Scy old->fin_out = fin->fin_out; 4141254219Scy old->fin_rev = fin->fin_rev; 4142254219Scy old->fin_hlen = fin->fin_hlen; 4143254219Scy old->ofin_tcpf = fin->fin_tcpf; 4144254219Scy old->fin_icode = fin->fin_icode; 4145254219Scy old->fin_rule = fin->fin_rule; 4146254219Scy bcopy(fin->fin_group, old->fin_group, sizeof(fin->fin_group)); 4147254219Scy old->fin_fr = fin->fin_fr; 4148254219Scy old->fin_dp = fin->fin_dp; 4149254219Scy old->fin_dlen = fin->fin_dlen; 4150254219Scy old->fin_plen = fin->fin_plen; 4151254219Scy old->fin_ipoff = fin->fin_ipoff; 4152254219Scy old->fin_id = fin->fin_id; 4153254219Scy old->fin_off = fin->fin_off; 4154254219Scy old->fin_depth = fin->fin_depth; 4155254219Scy old->fin_error = fin->fin_error; 4156254219Scy old->fin_state = NULL; 4157254219Scy old->fin_nat = NULL; 4158254219Scy old->fin_nattag = fin->fin_nattag; 4159254219Scy old->ofin_ip = fin->fin_ip; 4160254219Scy old->fin_mp = fin->fin_mp; 4161254219Scy old->fin_m = fin->fin_m; 4162254219Scy#ifdef MENTAT 4163254219Scy old->fin_qfm = fin->fin_qfm; 4164254219Scy old->fin_qpi = fin->fin_qpi; 4165254219Scy old->fin_ifname[0] = '\0'; 4166254219Scy#endif 4167254219Scy#ifdef __sgi 4168254219Scy old->fin_hbuf = fin->fin_hbuf; 4169254219Scy#endif 4170254219Scy} 4171254219Scy 4172254219Scy 4173254219Scystatic void 4174254219Scyfrauth_current_to_4_1_29(current, old) 4175254219Scy void *current; 4176254219Scy frauth_4_1_29_t *old; 4177254219Scy{ 4178254219Scy frauth_t *fra = (frauth_t *)current; 4179254219Scy 4180254219Scy old->fra_age = fra->fra_age; 4181254219Scy old->fra_len = fra->fra_len; 4182254219Scy old->fra_index = fra->fra_index; 4183254219Scy old->fra_pass = fra->fra_pass; 4184254219Scy fr_info_current_to_4_1_24(&fra->fra_info, &old->fra_info); 4185254219Scy old->fra_buf = fra->fra_buf; 4186254219Scy old->fra_flx = fra->fra_flx; 4187254219Scy#ifdef MENTAT 4188254219Scy old->fra_q = fra->fra_q; 4189254219Scy old->fra_m = fra->fra_m; 4190254219Scy#endif 4191254219Scy} 4192254219Scy 4193254219Scy 4194254219Scystatic void 4195254219Scyfrauth_current_to_4_1_24(current, old) 4196254219Scy void *current; 4197254219Scy frauth_4_1_24_t *old; 4198254219Scy{ 4199254219Scy frauth_t *fra = (frauth_t *)current; 4200254219Scy 4201254219Scy old->fra_age = fra->fra_age; 4202254219Scy old->fra_len = fra->fra_len; 4203254219Scy old->fra_index = fra->fra_index; 4204254219Scy old->fra_pass = fra->fra_pass; 4205254219Scy fr_info_current_to_4_1_24(&fra->fra_info, &old->fra_info); 4206254219Scy old->fra_buf = fra->fra_buf; 4207254219Scy#ifdef MENTAT 4208254219Scy old->fra_q = fra->fra_q; 4209254219Scy old->fra_m = fra->fra_m; 4210254219Scy#endif 4211254219Scy} 4212254219Scy 4213254219Scy 4214254219Scystatic void 4215254219Scyfrauth_current_to_4_1_23(current, old) 4216254219Scy void *current; 4217254219Scy frauth_4_1_23_t *old; 4218254219Scy{ 4219254219Scy frauth_t *fra = (frauth_t *)current; 4220254219Scy 4221254219Scy old->fra_age = fra->fra_age; 4222254219Scy old->fra_len = fra->fra_len; 4223254219Scy old->fra_index = fra->fra_index; 4224254219Scy old->fra_pass = fra->fra_pass; 4225254219Scy fr_info_current_to_4_1_23(&fra->fra_info, &old->fra_info); 4226254219Scy old->fra_buf = fra->fra_buf; 4227254219Scy#ifdef MENTAT 4228254219Scy old->fra_q = fra->fra_q; 4229254219Scy old->fra_m = fra->fra_m; 4230254219Scy#endif 4231254219Scy} 4232254219Scy 4233254219Scy 4234254219Scystatic void 4235254219Scyfrauth_current_to_4_1_11(current, old) 4236254219Scy void *current; 4237254219Scy frauth_4_1_11_t *old; 4238254219Scy{ 4239254219Scy frauth_t *fra = (frauth_t *)current; 4240254219Scy 4241254219Scy old->fra_age = fra->fra_age; 4242254219Scy old->fra_len = fra->fra_len; 4243254219Scy old->fra_index = fra->fra_index; 4244254219Scy old->fra_pass = fra->fra_pass; 4245254219Scy fr_info_current_to_4_1_11(&fra->fra_info, &old->fra_info); 4246254219Scy old->fra_buf = fra->fra_buf; 4247254219Scy#ifdef MENTAT 4248254219Scy old->fra_q = fra->fra_q; 4249254219Scy old->fra_m = fra->fra_m; 4250254219Scy#endif 4251254219Scy} 4252254219Scy 4253254219Scy 4254254219Scystatic void 4255254219Scyipnat_current_to_4_1_14(current, old) 4256254219Scy void *current; 4257254219Scy ipnat_4_1_14_t *old; 4258254219Scy{ 4259254219Scy ipnat_t *np = (ipnat_t *)current; 4260254219Scy 4261254219Scy old->in_next = np->in_next; 4262254219Scy old->in_rnext = np->in_rnext; 4263254219Scy old->in_prnext = np->in_prnext; 4264254219Scy old->in_mnext = np->in_mnext; 4265254219Scy old->in_pmnext = np->in_pmnext; 4266254219Scy old->in_tqehead[0] = np->in_tqehead[0]; 4267254219Scy old->in_tqehead[1] = np->in_tqehead[1]; 4268254219Scy old->in_ifps[0] = np->in_ifps[0]; 4269254219Scy old->in_ifps[1] = np->in_ifps[1]; 4270254219Scy old->in_apr = np->in_apr; 4271254219Scy old->in_comment = np->in_comment; 4272254219Scy old->in_space = np->in_space; 4273254219Scy old->in_hits = np->in_hits; 4274254219Scy old->in_use = np->in_use; 4275254219Scy old->in_hv = np->in_hv[0]; 4276254219Scy old->in_flineno = np->in_flineno; 4277254219Scy if (old->in_redir == NAT_REDIRECT) 4278254219Scy old->in_pnext = np->in_dpnext; 4279254219Scy else 4280254219Scy old->in_pnext = np->in_spnext; 4281254219Scy old->in_v = np->in_v[0]; 4282254219Scy old->in_flags = np->in_flags; 4283254219Scy old->in_mssclamp = np->in_mssclamp; 4284254219Scy old->in_age[0] = np->in_age[0]; 4285254219Scy old->in_age[1] = np->in_age[1]; 4286254219Scy old->in_redir = np->in_redir; 4287254219Scy old->in_p = np->in_pr[0]; 4288254219Scy if (np->in_redir == NAT_REDIRECT) { 4289254219Scy old->in_next6 = np->in_ndst.na_nextaddr; 4290254219Scy old->in_in[0] = np->in_ndst.na_addr[0]; 4291254219Scy old->in_in[1] = np->in_ndst.na_addr[1]; 4292254219Scy old->in_out[0] = np->in_odst.na_addr[0]; 4293254219Scy old->in_out[1] = np->in_odst.na_addr[1]; 4294254219Scy old->in_src[0] = np->in_osrc.na_addr[0]; 4295254219Scy old->in_src[1] = np->in_osrc.na_addr[1]; 4296254219Scy } else { 4297254219Scy old->in_next6 = np->in_nsrc.na_nextaddr; 4298254219Scy old->in_out[0] = np->in_nsrc.na_addr[0]; 4299254219Scy old->in_out[1] = np->in_nsrc.na_addr[1]; 4300254219Scy old->in_in[0] = np->in_osrc.na_addr[0]; 4301254219Scy old->in_in[1] = np->in_osrc.na_addr[1]; 4302254219Scy old->in_src[0] = np->in_odst.na_addr[0]; 4303254219Scy old->in_src[1] = np->in_odst.na_addr[1]; 4304254219Scy } 4305254219Scy ipfv5tuctov4(&np->in_tuc, &old->in_tuc); 4306254219Scy if (np->in_redir == NAT_REDIRECT) { 4307254219Scy old->in_port[0] = np->in_dpmin; 4308254219Scy old->in_port[1] = np->in_dpmax; 4309254219Scy } else { 4310254219Scy old->in_port[0] = np->in_spmin; 4311254219Scy old->in_port[1] = np->in_spmax; 4312254219Scy } 4313254219Scy old->in_ppip = np->in_ppip; 4314254219Scy old->in_ippip = np->in_ippip; 4315254219Scy bcopy(&np->in_tag, &old->in_tag, sizeof(np->in_tag)); 4316254219Scy 4317254219Scy if (np->in_ifnames[0] >= 0) { 4318254219Scy strncpy(old->in_ifnames[0], np->in_names + np->in_ifnames[0], 4319254219Scy LIFNAMSIZ); 4320254219Scy old->in_ifnames[0][LIFNAMSIZ - 1] = '\0'; 4321254219Scy } 4322254219Scy if (np->in_ifnames[1] >= 0) { 4323254219Scy strncpy(old->in_ifnames[1], np->in_names + np->in_ifnames[1], 4324254219Scy LIFNAMSIZ); 4325254219Scy old->in_ifnames[1][LIFNAMSIZ - 1] = '\0'; 4326254219Scy } 4327254219Scy if (np->in_plabel >= 0) { 4328254219Scy strncpy(old->in_plabel, np->in_names + np->in_plabel, 4329254219Scy APR_LABELLEN); 4330254219Scy old->in_plabel[APR_LABELLEN - 1] = '\0'; 4331254219Scy } 4332254219Scy} 4333254219Scy 4334254219Scy 4335254219Scystatic void 4336254219Scyipnat_current_to_4_1_0(current, old) 4337254219Scy void *current; 4338254219Scy ipnat_4_1_0_t *old; 4339254219Scy{ 4340254219Scy ipnat_t *np = (ipnat_t *)current; 4341254219Scy 4342254219Scy old->in_next = np->in_next; 4343254219Scy old->in_rnext = np->in_rnext; 4344254219Scy old->in_prnext = np->in_prnext; 4345254219Scy old->in_mnext = np->in_mnext; 4346254219Scy old->in_pmnext = np->in_pmnext; 4347254219Scy old->in_tqehead[0] = np->in_tqehead[0]; 4348254219Scy old->in_tqehead[1] = np->in_tqehead[1]; 4349254219Scy old->in_ifps[0] = np->in_ifps[0]; 4350254219Scy old->in_ifps[1] = np->in_ifps[1]; 4351254219Scy old->in_apr = np->in_apr; 4352254219Scy old->in_comment = np->in_comment; 4353254219Scy old->in_space = np->in_space; 4354254219Scy old->in_hits = np->in_hits; 4355254219Scy old->in_use = np->in_use; 4356254219Scy old->in_hv = np->in_hv[0]; 4357254219Scy old->in_flineno = np->in_flineno; 4358254219Scy if (old->in_redir == NAT_REDIRECT) 4359254219Scy old->in_pnext = np->in_dpnext; 4360254219Scy else 4361254219Scy old->in_pnext = np->in_spnext; 4362254219Scy old->in_v = np->in_v[0]; 4363254219Scy old->in_flags = np->in_flags; 4364254219Scy old->in_mssclamp = np->in_mssclamp; 4365254219Scy old->in_age[0] = np->in_age[0]; 4366254219Scy old->in_age[1] = np->in_age[1]; 4367254219Scy old->in_redir = np->in_redir; 4368254219Scy old->in_p = np->in_pr[0]; 4369254219Scy if (np->in_redir == NAT_REDIRECT) { 4370254219Scy old->in_next6 = np->in_ndst.na_nextaddr; 4371254219Scy old->in_in[0] = np->in_ndst.na_addr[0]; 4372254219Scy old->in_in[1] = np->in_ndst.na_addr[1]; 4373254219Scy old->in_out[0] = np->in_odst.na_addr[0]; 4374254219Scy old->in_out[1] = np->in_odst.na_addr[1]; 4375254219Scy old->in_src[0] = np->in_osrc.na_addr[0]; 4376254219Scy old->in_src[1] = np->in_osrc.na_addr[1]; 4377254219Scy } else { 4378254219Scy old->in_next6 = np->in_nsrc.na_nextaddr; 4379254219Scy old->in_out[0] = np->in_nsrc.na_addr[0]; 4380254219Scy old->in_out[1] = np->in_nsrc.na_addr[1]; 4381254219Scy old->in_in[0] = np->in_osrc.na_addr[0]; 4382254219Scy old->in_in[1] = np->in_osrc.na_addr[1]; 4383254219Scy old->in_src[0] = np->in_odst.na_addr[0]; 4384254219Scy old->in_src[1] = np->in_odst.na_addr[1]; 4385254219Scy } 4386254219Scy ipfv5tuctov4(&np->in_tuc, &old->in_tuc); 4387254219Scy if (np->in_redir == NAT_REDIRECT) { 4388254219Scy old->in_port[0] = np->in_dpmin; 4389254219Scy old->in_port[1] = np->in_dpmax; 4390254219Scy } else { 4391254219Scy old->in_port[0] = np->in_spmin; 4392254219Scy old->in_port[1] = np->in_spmax; 4393254219Scy } 4394254219Scy old->in_ppip = np->in_ppip; 4395254219Scy old->in_ippip = np->in_ippip; 4396254219Scy bcopy(&np->in_tag, &old->in_tag, sizeof(np->in_tag)); 4397254219Scy 4398254219Scy if (np->in_ifnames[0] >= 0) { 4399254219Scy strncpy(old->in_ifnames[0], np->in_names + np->in_ifnames[0], 4400254219Scy LIFNAMSIZ); 4401254219Scy old->in_ifnames[0][LIFNAMSIZ - 1] = '\0'; 4402254219Scy } 4403254219Scy if (np->in_ifnames[1] >= 0) { 4404254219Scy strncpy(old->in_ifnames[1], np->in_names + np->in_ifnames[1], 4405254219Scy LIFNAMSIZ); 4406254219Scy old->in_ifnames[1][LIFNAMSIZ - 1] = '\0'; 4407254219Scy } 4408254219Scy if (np->in_plabel >= 0) { 4409254219Scy strncpy(old->in_plabel, np->in_names + np->in_plabel, 4410254219Scy APR_LABELLEN); 4411254219Scy old->in_plabel[APR_LABELLEN - 1] = '\0'; 4412254219Scy } 4413254219Scy} 4414254219Scy 4415254219Scy 4416254219Scystatic void 4417254219Scyipstate_current_to_4_1_16(current, old) 4418254219Scy void *current; 4419254219Scy ipstate_4_1_16_t *old; 4420254219Scy{ 4421254219Scy ipstate_t *is = (ipstate_t *)current; 4422254219Scy 4423254219Scy old->is_lock = is->is_lock; 4424254219Scy old->is_next = is->is_next; 4425254219Scy old->is_pnext = is->is_pnext; 4426254219Scy old->is_hnext = is->is_hnext; 4427254219Scy old->is_phnext = is->is_phnext; 4428254219Scy old->is_me = is->is_me; 4429254219Scy old->is_ifp[0] = is->is_ifp[0]; 4430254219Scy old->is_ifp[1] = is->is_ifp[1]; 4431254219Scy old->is_sync = is->is_sync; 4432254219Scy old->is_rule = is->is_rule; 4433254219Scy old->is_tqehead[0] = is->is_tqehead[0]; 4434254219Scy old->is_tqehead[1] = is->is_tqehead[1]; 4435254219Scy old->is_isc = is->is_isc; 4436254219Scy old->is_pkts[0] = is->is_pkts[0]; 4437254219Scy old->is_pkts[1] = is->is_pkts[1]; 4438254219Scy old->is_pkts[2] = is->is_pkts[2]; 4439254219Scy old->is_pkts[3] = is->is_pkts[3]; 4440254219Scy old->is_bytes[0] = is->is_bytes[0]; 4441254219Scy old->is_bytes[1] = is->is_bytes[1]; 4442254219Scy old->is_bytes[2] = is->is_bytes[2]; 4443254219Scy old->is_bytes[3] = is->is_bytes[3]; 4444254219Scy old->is_icmppkts[0] = is->is_icmppkts[0]; 4445254219Scy old->is_icmppkts[1] = is->is_icmppkts[1]; 4446254219Scy old->is_icmppkts[2] = is->is_icmppkts[2]; 4447254219Scy old->is_icmppkts[3] = is->is_icmppkts[3]; 4448254219Scy old->is_sti = is->is_sti; 4449254219Scy old->is_frage[0] = is->is_frage[0]; 4450254219Scy old->is_frage[1] = is->is_frage[1]; 4451254219Scy old->is_ref = is->is_ref; 4452254219Scy old->is_isninc[0] = is->is_isninc[0]; 4453254219Scy old->is_isninc[1] = is->is_isninc[1]; 4454254219Scy old->is_sumd[0] = is->is_sumd[0]; 4455254219Scy old->is_sumd[1] = is->is_sumd[1]; 4456254219Scy old->is_src = is->is_src; 4457254219Scy old->is_dst = is->is_dst; 4458254219Scy old->is_pass = is->is_pass; 4459254219Scy old->is_p = is->is_p; 4460254219Scy old->is_v = is->is_v; 4461254219Scy old->is_hv = is->is_hv; 4462254219Scy old->is_tag = is->is_tag; 4463254219Scy old->is_opt[0] = is->is_opt[0]; 4464254219Scy old->is_opt[1] = is->is_opt[1]; 4465254219Scy old->is_optmsk[0] = is->is_optmsk[0]; 4466254219Scy old->is_optmsk[1] = is->is_optmsk[1]; 4467254219Scy old->is_sec = is->is_sec; 4468254219Scy old->is_secmsk = is->is_secmsk; 4469254219Scy old->is_auth = is->is_auth; 4470254219Scy old->is_authmsk = is->is_authmsk; 4471254219Scy ipf_v5tcpinfoto4(&is->is_tcp, &old->is_tcp); 4472254219Scy old->is_flags = is->is_flags; 4473254219Scy old->is_flx[0][0] = is->is_flx[0][0]; 4474254219Scy old->is_flx[0][1] = is->is_flx[0][1]; 4475254219Scy old->is_flx[1][0] = is->is_flx[1][0]; 4476254219Scy old->is_flx[1][1] = is->is_flx[1][1]; 4477254219Scy old->is_rulen = is->is_rulen; 4478254219Scy old->is_s0[0] = is->is_s0[0]; 4479254219Scy old->is_s0[1] = is->is_s0[1]; 4480254219Scy old->is_smsk[0] = is->is_smsk[0]; 4481254219Scy old->is_smsk[1] = is->is_smsk[1]; 4482254219Scy bcopy(is->is_group, old->is_group, sizeof(is->is_group)); 4483254219Scy bcopy(is->is_sbuf, old->is_sbuf, sizeof(is->is_sbuf)); 4484254219Scy bcopy(is->is_ifname, old->is_ifname, sizeof(is->is_ifname)); 4485254219Scy} 4486254219Scy 4487254219Scy 4488254219Scystatic void 4489254219Scyipstate_current_to_4_1_0(current, old) 4490254219Scy void *current; 4491254219Scy ipstate_4_1_0_t *old; 4492254219Scy{ 4493254219Scy ipstate_t *is = (ipstate_t *)current; 4494254219Scy 4495254219Scy old->is_lock = is->is_lock; 4496254219Scy old->is_next = is->is_next; 4497254219Scy old->is_pnext = is->is_pnext; 4498254219Scy old->is_hnext = is->is_hnext; 4499254219Scy old->is_phnext = is->is_phnext; 4500254219Scy old->is_me = is->is_me; 4501254219Scy old->is_ifp[0] = is->is_ifp[0]; 4502254219Scy old->is_ifp[1] = is->is_ifp[1]; 4503254219Scy old->is_sync = is->is_sync; 4504254219Scy bzero(&old->is_nat, sizeof(old->is_nat)); 4505254219Scy old->is_rule = is->is_rule; 4506254219Scy old->is_tqehead[0] = is->is_tqehead[0]; 4507254219Scy old->is_tqehead[1] = is->is_tqehead[1]; 4508254219Scy old->is_isc = is->is_isc; 4509254219Scy old->is_pkts[0] = is->is_pkts[0]; 4510254219Scy old->is_pkts[1] = is->is_pkts[1]; 4511254219Scy old->is_pkts[2] = is->is_pkts[2]; 4512254219Scy old->is_pkts[3] = is->is_pkts[3]; 4513254219Scy old->is_bytes[0] = is->is_bytes[0]; 4514254219Scy old->is_bytes[1] = is->is_bytes[1]; 4515254219Scy old->is_bytes[2] = is->is_bytes[2]; 4516254219Scy old->is_bytes[3] = is->is_bytes[3]; 4517254219Scy old->is_icmppkts[0] = is->is_icmppkts[0]; 4518254219Scy old->is_icmppkts[1] = is->is_icmppkts[1]; 4519254219Scy old->is_icmppkts[2] = is->is_icmppkts[2]; 4520254219Scy old->is_icmppkts[3] = is->is_icmppkts[3]; 4521254219Scy old->is_sti = is->is_sti; 4522254219Scy old->is_frage[0] = is->is_frage[0]; 4523254219Scy old->is_frage[1] = is->is_frage[1]; 4524254219Scy old->is_ref = is->is_ref; 4525254219Scy old->is_isninc[0] = is->is_isninc[0]; 4526254219Scy old->is_isninc[1] = is->is_isninc[1]; 4527254219Scy old->is_sumd[0] = is->is_sumd[0]; 4528254219Scy old->is_sumd[1] = is->is_sumd[1]; 4529254219Scy old->is_src = is->is_src; 4530254219Scy old->is_dst = is->is_dst; 4531254219Scy old->is_pass = is->is_pass; 4532254219Scy old->is_p = is->is_p; 4533254219Scy old->is_v = is->is_v; 4534254219Scy old->is_hv = is->is_hv; 4535254219Scy old->is_tag = is->is_tag; 4536254219Scy old->is_opt[0] = is->is_opt[0]; 4537254219Scy old->is_opt[1] = is->is_opt[1]; 4538254219Scy old->is_optmsk[0] = is->is_optmsk[0]; 4539254219Scy old->is_optmsk[1] = is->is_optmsk[1]; 4540254219Scy old->is_sec = is->is_sec; 4541254219Scy old->is_secmsk = is->is_secmsk; 4542254219Scy old->is_auth = is->is_auth; 4543254219Scy old->is_authmsk = is->is_authmsk; 4544254219Scy ipf_v5tcpinfoto4(&is->is_tcp, &old->is_tcp); 4545254219Scy old->is_flags = is->is_flags; 4546254219Scy old->is_flx[0][0] = is->is_flx[0][0]; 4547254219Scy old->is_flx[0][1] = is->is_flx[0][1]; 4548254219Scy old->is_flx[1][0] = is->is_flx[1][0]; 4549254219Scy old->is_flx[1][1] = is->is_flx[1][1]; 4550254219Scy old->is_rulen = is->is_rulen; 4551254219Scy old->is_s0[0] = is->is_s0[0]; 4552254219Scy old->is_s0[1] = is->is_s0[1]; 4553254219Scy old->is_smsk[0] = is->is_smsk[0]; 4554254219Scy old->is_smsk[1] = is->is_smsk[1]; 4555254219Scy bcopy(is->is_group, old->is_group, sizeof(is->is_group)); 4556254219Scy bcopy(is->is_sbuf, old->is_sbuf, sizeof(is->is_sbuf)); 4557254219Scy bcopy(is->is_ifname, old->is_ifname, sizeof(is->is_ifname)); 4558254219Scy} 4559254219Scy 4560254219Scy 4561254219Scystatic void 4562254219Scyips_stat_current_to_4_1_21(current, old) 4563254219Scy void *current; 4564254219Scy ips_stat_4_1_21_t *old; 4565254219Scy{ 4566254219Scy ips_stat_t *st = (ips_stat_t *)current; 4567254219Scy 4568254219Scy old->iss_hits = st->iss_hits; 4569254219Scy old->iss_miss = st->iss_check_miss; 4570254219Scy old->iss_max = st->iss_max; 4571254219Scy old->iss_maxref = st->iss_max_ref; 4572254219Scy old->iss_tcp = st->iss_proto[IPPROTO_TCP]; 4573254219Scy old->iss_udp = st->iss_proto[IPPROTO_UDP]; 4574254219Scy old->iss_icmp = st->iss_proto[IPPROTO_ICMP]; 4575254219Scy old->iss_nomem = st->iss_nomem; 4576254219Scy old->iss_expire = st->iss_expire; 4577254219Scy old->iss_fin = st->iss_fin; 4578254219Scy old->iss_active = st->iss_active; 4579254219Scy old->iss_logged = st->iss_log_ok; 4580254219Scy old->iss_logfail = st->iss_log_fail; 4581254219Scy old->iss_inuse = st->iss_inuse; 4582254219Scy old->iss_wild = st->iss_wild; 4583254219Scy old->iss_ticks = st->iss_ticks; 4584254219Scy old->iss_bucketfull = st->iss_bucket_full; 4585254219Scy old->iss_statesize = st->iss_state_size; 4586254219Scy old->iss_statemax = st->iss_state_max; 4587254219Scy old->iss_table = st->iss_table; 4588254219Scy old->iss_list = st->iss_list; 4589254219Scy old->iss_bucketlen = (void *)st->iss_bucketlen; 4590254219Scy old->iss_tcptab = st->iss_tcptab; 4591254219Scy} 4592254219Scy 4593254219Scy 4594254219Scystatic void 4595254219Scyips_stat_current_to_4_1_0(current, old) 4596254219Scy void *current; 4597254219Scy ips_stat_4_1_0_t *old; 4598254219Scy{ 4599254219Scy ips_stat_t *st = (ips_stat_t *)current; 4600254219Scy 4601254219Scy old->iss_hits = st->iss_hits; 4602254219Scy old->iss_miss = st->iss_check_miss; 4603254219Scy old->iss_max = st->iss_max; 4604254219Scy old->iss_maxref = st->iss_max_ref; 4605254219Scy old->iss_tcp = st->iss_proto[IPPROTO_TCP]; 4606254219Scy old->iss_udp = st->iss_proto[IPPROTO_UDP]; 4607254219Scy old->iss_icmp = st->iss_proto[IPPROTO_ICMP]; 4608254219Scy old->iss_nomem = st->iss_nomem; 4609254219Scy old->iss_expire = st->iss_expire; 4610254219Scy old->iss_fin = st->iss_fin; 4611254219Scy old->iss_active = st->iss_active; 4612254219Scy old->iss_logged = st->iss_log_ok; 4613254219Scy old->iss_logfail = st->iss_log_fail; 4614254219Scy old->iss_inuse = st->iss_inuse; 4615254219Scy old->iss_wild = st->iss_wild; 4616254219Scy old->iss_ticks = st->iss_ticks; 4617254219Scy old->iss_bucketfull = st->iss_bucket_full; 4618254219Scy old->iss_statesize = st->iss_state_size; 4619254219Scy old->iss_statemax = st->iss_state_max; 4620254219Scy old->iss_table = st->iss_table; 4621254219Scy old->iss_list = st->iss_list; 4622254219Scy old->iss_bucketlen = (void *)st->iss_bucketlen; 4623254219Scy} 4624254219Scy 4625254219Scy 4626254219Scystatic void 4627254219Scynat_save_current_to_4_1_16(current, old) 4628254219Scy void *current; 4629254219Scy nat_save_4_1_16_t *old; 4630254219Scy{ 4631254219Scy nat_save_t *nats = (nat_save_t *)current; 4632254219Scy 4633254219Scy old->ipn_next = nats->ipn_next; 4634254219Scy bcopy(&nats->ipn_nat, &old->ipn_nat, sizeof(old->ipn_nat)); 4635254219Scy bcopy(&nats->ipn_ipnat, &old->ipn_ipnat, sizeof(old->ipn_ipnat)); 4636254219Scy frentry_current_to_4_1_16(&nats->ipn_fr, &old->ipn_fr); 4637254219Scy old->ipn_dsize = nats->ipn_dsize; 4638254219Scy bcopy(nats->ipn_data, old->ipn_data, sizeof(nats->ipn_data)); 4639254219Scy} 4640254219Scy 4641254219Scy 4642254219Scystatic void 4643254219Scynat_save_current_to_4_1_14(current, old) 4644254219Scy void *current; 4645254219Scy nat_save_4_1_14_t *old; 4646254219Scy{ 4647254219Scy nat_save_t *nats = (nat_save_t *)current; 4648254219Scy 4649254219Scy old->ipn_next = nats->ipn_next; 4650254219Scy bcopy(&nats->ipn_nat, &old->ipn_nat, sizeof(old->ipn_nat)); 4651254219Scy bcopy(&nats->ipn_ipnat, &old->ipn_ipnat, sizeof(old->ipn_ipnat)); 4652254219Scy frentry_current_to_4_1_0(&nats->ipn_fr, &old->ipn_fr); 4653254219Scy old->ipn_dsize = nats->ipn_dsize; 4654254219Scy bcopy(nats->ipn_data, old->ipn_data, sizeof(nats->ipn_data)); 4655254219Scy} 4656254219Scy 4657254219Scy 4658254219Scystatic void 4659254219Scynat_save_current_to_4_1_3(current, old) 4660254219Scy void *current; 4661254219Scy nat_save_4_1_3_t *old; 4662254219Scy{ 4663254219Scy nat_save_t *nats = (nat_save_t *)current; 4664254219Scy 4665254219Scy old->ipn_next = nats->ipn_next; 4666254219Scy bcopy(&nats->ipn_nat, &old->ipn_nat, sizeof(old->ipn_nat)); 4667254219Scy bcopy(&nats->ipn_ipnat, &old->ipn_ipnat, sizeof(old->ipn_ipnat)); 4668254219Scy frentry_current_to_4_1_0(&nats->ipn_fr, &old->ipn_fr); 4669254219Scy old->ipn_dsize = nats->ipn_dsize; 4670254219Scy bcopy(nats->ipn_data, old->ipn_data, sizeof(nats->ipn_data)); 4671254219Scy} 4672254219Scy 4673254219Scy 4674254219Scystatic void 4675254219Scynat_current_to_4_1_25(current, old) 4676254219Scy void *current; 4677254219Scy nat_4_1_25_t *old; 4678254219Scy{ 4679254219Scy nat_t *nat = (nat_t *)current; 4680254219Scy 4681254219Scy old->nat_lock = nat->nat_lock; 4682254219Scy old->nat_next = (void *)nat->nat_next; 4683254219Scy old->nat_pnext = (void *)nat->nat_pnext; 4684254219Scy old->nat_hnext[0] = (void *)nat->nat_hnext[0]; 4685254219Scy old->nat_hnext[1] = (void *)nat->nat_hnext[1]; 4686254219Scy old->nat_phnext[0] = (void *)nat->nat_phnext[0]; 4687254219Scy old->nat_phnext[1] = (void *)nat->nat_phnext[1]; 4688254219Scy old->nat_hm = nat->nat_hm; 4689254219Scy old->nat_data = nat->nat_data; 4690254219Scy old->nat_me = (void *)nat->nat_me; 4691254219Scy old->nat_state = nat->nat_state; 4692254219Scy old->nat_aps = nat->nat_aps; 4693254219Scy old->nat_fr = nat->nat_fr; 4694254219Scy old->nat_ptr = (void *)nat->nat_ptr; 4695254219Scy old->nat_ifps[0] = nat->nat_ifps[0]; 4696254219Scy old->nat_ifps[1] = nat->nat_ifps[1]; 4697254219Scy old->nat_sync = nat->nat_sync; 4698254219Scy old->nat_tqe = nat->nat_tqe; 4699254219Scy old->nat_flags = nat->nat_flags; 4700254219Scy old->nat_sumd[0] = nat->nat_sumd[0]; 4701254219Scy old->nat_sumd[1] = nat->nat_sumd[1]; 4702254219Scy old->nat_ipsumd = nat->nat_ipsumd; 4703254219Scy old->nat_mssclamp = nat->nat_mssclamp; 4704254219Scy old->nat_pkts[0] = nat->nat_pkts[0]; 4705254219Scy old->nat_pkts[1] = nat->nat_pkts[1]; 4706254219Scy old->nat_bytes[0] = nat->nat_bytes[0]; 4707254219Scy old->nat_bytes[1] = nat->nat_bytes[1]; 4708254219Scy old->nat_ref = nat->nat_ref; 4709254219Scy old->nat_dir = nat->nat_dir; 4710254219Scy old->nat_p = nat->nat_pr[0]; 4711254219Scy old->nat_use = nat->nat_use; 4712254219Scy old->nat_hv[0] = nat->nat_hv[0]; 4713254219Scy old->nat_hv[1] = nat->nat_hv[1]; 4714254219Scy old->nat_rev = nat->nat_rev; 4715254219Scy old->nat_redir = nat->nat_redir; 4716254219Scy bcopy(nat->nat_ifnames[0], old->nat_ifnames[0], LIFNAMSIZ); 4717254219Scy bcopy(nat->nat_ifnames[1], old->nat_ifnames[1], LIFNAMSIZ); 4718254219Scy 4719254219Scy if (nat->nat_redir == NAT_REDIRECT) { 4720254219Scy old->nat_inip6 = nat->nat_ndst6; 4721254219Scy old->nat_outip6 = nat->nat_odst6; 4722254219Scy old->nat_oip6 = nat->nat_osrc6; 4723254219Scy old->nat_un.nat_unt.ts_sport = nat->nat_ndport; 4724254219Scy old->nat_un.nat_unt.ts_dport = nat->nat_odport; 4725254219Scy } else { 4726254219Scy old->nat_inip6 = nat->nat_osrc6; 4727254219Scy old->nat_outip6 = nat->nat_nsrc6; 4728254219Scy old->nat_oip6 = nat->nat_odst6; 4729254219Scy old->nat_un.nat_unt.ts_sport = nat->nat_osport; 4730254219Scy old->nat_un.nat_unt.ts_dport = nat->nat_nsport; 4731254219Scy } 4732254219Scy} 4733254219Scy 4734254219Scy 4735254219Scystatic void 4736254219Scynat_current_to_4_1_14(current, old) 4737254219Scy void *current; 4738254219Scy nat_4_1_14_t *old; 4739254219Scy{ 4740254219Scy nat_t *nat = (nat_t *)current; 4741254219Scy 4742254219Scy old->nat_lock = nat->nat_lock; 4743254219Scy old->nat_next = nat->nat_next; 4744254219Scy old->nat_pnext = NULL; 4745254219Scy old->nat_hnext[0] = NULL; 4746254219Scy old->nat_hnext[1] = NULL; 4747254219Scy old->nat_phnext[0] = NULL; 4748254219Scy old->nat_phnext[1] = NULL; 4749254219Scy old->nat_hm = nat->nat_hm; 4750254219Scy old->nat_data = nat->nat_data; 4751254219Scy old->nat_me = (void *)nat->nat_me; 4752254219Scy old->nat_state = nat->nat_state; 4753254219Scy old->nat_aps = nat->nat_aps; 4754254219Scy old->nat_fr = nat->nat_fr; 4755254219Scy old->nat_ptr = nat->nat_ptr; 4756254219Scy old->nat_ifps[0] = nat->nat_ifps[0]; 4757254219Scy old->nat_ifps[1] = nat->nat_ifps[1]; 4758254219Scy old->nat_sync = nat->nat_sync; 4759254219Scy old->nat_tqe = nat->nat_tqe; 4760254219Scy old->nat_flags = nat->nat_flags; 4761254219Scy old->nat_sumd[0] = nat->nat_sumd[0]; 4762254219Scy old->nat_sumd[1] = nat->nat_sumd[1]; 4763254219Scy old->nat_ipsumd = nat->nat_ipsumd; 4764254219Scy old->nat_mssclamp = nat->nat_mssclamp; 4765254219Scy old->nat_pkts[0] = nat->nat_pkts[0]; 4766254219Scy old->nat_pkts[1] = nat->nat_pkts[1]; 4767254219Scy old->nat_bytes[0] = nat->nat_bytes[0]; 4768254219Scy old->nat_bytes[1] = nat->nat_bytes[1]; 4769254219Scy old->nat_ref = nat->nat_ref; 4770254219Scy old->nat_dir = nat->nat_dir; 4771254219Scy old->nat_p = nat->nat_pr[0]; 4772254219Scy old->nat_use = nat->nat_use; 4773254219Scy old->nat_hv[0] = nat->nat_hv[0]; 4774254219Scy old->nat_hv[1] = nat->nat_hv[1]; 4775254219Scy old->nat_rev = nat->nat_rev; 4776254219Scy bcopy(nat->nat_ifnames[0], old->nat_ifnames[0], LIFNAMSIZ); 4777254219Scy bcopy(nat->nat_ifnames[1], old->nat_ifnames[1], LIFNAMSIZ); 4778254219Scy 4779254219Scy if (nat->nat_redir == NAT_REDIRECT) { 4780254219Scy old->nat_inip6 = nat->nat_ndst6; 4781254219Scy old->nat_outip6 = nat->nat_odst6; 4782254219Scy old->nat_oip6 = nat->nat_osrc6; 4783254219Scy old->nat_un.nat_unt.ts_sport = nat->nat_ndport; 4784254219Scy old->nat_un.nat_unt.ts_dport = nat->nat_odport; 4785254219Scy } else { 4786254219Scy old->nat_inip6 = nat->nat_osrc6; 4787254219Scy old->nat_outip6 = nat->nat_nsrc6; 4788254219Scy old->nat_oip6 = nat->nat_odst6; 4789254219Scy old->nat_un.nat_unt.ts_sport = nat->nat_osport; 4790254219Scy old->nat_un.nat_unt.ts_dport = nat->nat_nsport; 4791254219Scy } 4792254219Scy} 4793254219Scy 4794254219Scy 4795254219Scystatic void 4796254219Scynat_current_to_4_1_3(current, old) 4797254219Scy void *current; 4798254219Scy nat_4_1_3_t *old; 4799254219Scy{ 4800254219Scy nat_t *nat = (nat_t *)current; 4801254219Scy 4802254219Scy old->nat_lock = nat->nat_lock; 4803254219Scy old->nat_next = nat->nat_next; 4804254219Scy old->nat_pnext = NULL; 4805254219Scy old->nat_hnext[0] = NULL; 4806254219Scy old->nat_hnext[1] = NULL; 4807254219Scy old->nat_phnext[0] = NULL; 4808254219Scy old->nat_phnext[1] = NULL; 4809254219Scy old->nat_hm = nat->nat_hm; 4810254219Scy old->nat_data = nat->nat_data; 4811254219Scy old->nat_me = (void *)nat->nat_me; 4812254219Scy old->nat_state = nat->nat_state; 4813254219Scy old->nat_aps = nat->nat_aps; 4814254219Scy old->nat_fr = nat->nat_fr; 4815254219Scy old->nat_ptr = nat->nat_ptr; 4816254219Scy old->nat_ifps[0] = nat->nat_ifps[0]; 4817254219Scy old->nat_ifps[1] = nat->nat_ifps[1]; 4818254219Scy old->nat_sync = nat->nat_sync; 4819254219Scy old->nat_tqe = nat->nat_tqe; 4820254219Scy old->nat_flags = nat->nat_flags; 4821254219Scy old->nat_sumd[0] = nat->nat_sumd[0]; 4822254219Scy old->nat_sumd[1] = nat->nat_sumd[1]; 4823254219Scy old->nat_ipsumd = nat->nat_ipsumd; 4824254219Scy old->nat_mssclamp = nat->nat_mssclamp; 4825254219Scy old->nat_pkts[0] = nat->nat_pkts[0]; 4826254219Scy old->nat_pkts[1] = nat->nat_pkts[1]; 4827254219Scy old->nat_bytes[0] = nat->nat_bytes[0]; 4828254219Scy old->nat_bytes[1] = nat->nat_bytes[1]; 4829254219Scy old->nat_ref = nat->nat_ref; 4830254219Scy old->nat_dir = nat->nat_dir; 4831254219Scy old->nat_p = nat->nat_pr[0]; 4832254219Scy old->nat_use = nat->nat_use; 4833254219Scy old->nat_hv[0] = nat->nat_hv[0]; 4834254219Scy old->nat_hv[1] = nat->nat_hv[1]; 4835254219Scy old->nat_rev = nat->nat_rev; 4836254219Scy bcopy(nat->nat_ifnames[0], old->nat_ifnames[0], LIFNAMSIZ); 4837254219Scy bcopy(nat->nat_ifnames[1], old->nat_ifnames[1], LIFNAMSIZ); 4838254219Scy 4839254219Scy if (nat->nat_redir == NAT_REDIRECT) { 4840254219Scy old->nat_inip6 = nat->nat_ndst6; 4841254219Scy old->nat_outip6 = nat->nat_odst6; 4842254219Scy old->nat_oip6 = nat->nat_osrc6; 4843254219Scy old->nat_un.nat_unt.ts_sport = nat->nat_ndport; 4844254219Scy old->nat_un.nat_unt.ts_dport = nat->nat_odport; 4845254219Scy } else { 4846254219Scy old->nat_inip6 = nat->nat_osrc6; 4847254219Scy old->nat_outip6 = nat->nat_nsrc6; 4848254219Scy old->nat_oip6 = nat->nat_odst6; 4849254219Scy old->nat_un.nat_unt.ts_sport = nat->nat_osport; 4850254219Scy old->nat_un.nat_unt.ts_dport = nat->nat_nsport; 4851254219Scy } 4852254219Scy} 4853254219Scy 4854254219Scy#endif /* IPFILTER_COMPAT */ 4855