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