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