Lines 45-50
__FBSDID("$FreeBSD$");
Link Here
|
45 |
|
45 |
|
46 |
#include <net/if.h> |
46 |
#include <net/if.h> |
47 |
#include <net/if_var.h> |
47 |
#include <net/if_var.h> |
|
|
48 |
#include <net/if_pflog.h> |
48 |
#include <netinet/in.h> |
49 |
#include <netinet/in.h> |
49 |
#include <netinet/ip.h> |
50 |
#include <netinet/ip.h> |
50 |
#include <netinet/ip_var.h> |
51 |
#include <netinet/ip_var.h> |
Lines 53-58
__FBSDID("$FreeBSD$");
Link Here
|
53 |
#include <netinet/udp.h> |
54 |
#include <netinet/udp.h> |
54 |
|
55 |
|
55 |
#include <netpfil/ipfw/ip_fw_private.h> |
56 |
#include <netpfil/ipfw/ip_fw_private.h> |
|
|
57 |
#include <netpfil/pf/pf.h> |
56 |
|
58 |
|
57 |
#include <machine/in_cksum.h> /* XXX for in_cksum */ |
59 |
#include <machine/in_cksum.h> /* XXX for in_cksum */ |
58 |
|
60 |
|
Lines 279-285
free_nat_instance(struct cfg_nat *ptr)
Link Here
|
279 |
free(ptr, M_IPFW); |
281 |
free(ptr, M_IPFW); |
280 |
} |
282 |
} |
281 |
|
283 |
|
|
|
284 |
static void |
285 |
init_loghdr(struct pfloghdr *plog, uint32_t id) |
286 |
{ |
282 |
|
287 |
|
|
|
288 |
memset(plog, 0, sizeof(*plog)); |
289 |
plog->length = PFLOG_REAL_HDRLEN; |
290 |
plog->af = AF_INET; |
291 |
plog->action = PF_NAT; |
292 |
plog->dir = PF_IN; |
293 |
plog->rulenr = htonl(id); |
294 |
strlcpy(plog->ifname, "NAT44", sizeof(plog->ifname)); |
295 |
} |
296 |
|
283 |
/* |
297 |
/* |
284 |
* ipfw_nat - perform mbuf header translation. |
298 |
* ipfw_nat - perform mbuf header translation. |
285 |
* |
299 |
* |
Lines 290-295
free_nat_instance(struct cfg_nat *ptr)
Link Here
|
290 |
static int |
304 |
static int |
291 |
ipfw_nat(struct ip_fw_args *args, struct cfg_nat *t, struct mbuf *m) |
305 |
ipfw_nat(struct ip_fw_args *args, struct cfg_nat *t, struct mbuf *m) |
292 |
{ |
306 |
{ |
|
|
307 |
struct pfloghdr loghdr; |
293 |
struct mbuf *mcl; |
308 |
struct mbuf *mcl; |
294 |
struct ip *ip; |
309 |
struct ip *ip; |
295 |
/* XXX - libalias duct tape */ |
310 |
/* XXX - libalias duct tape */ |
Lines 363-368
ipfw_nat(struct ip_fw_args *args, struct cfg_nat *
Link Here
|
363 |
mcl->m_len + M_TRAILINGSPACE(mcl), 0); |
378 |
mcl->m_len + M_TRAILINGSPACE(mcl), 0); |
364 |
if (retval == PKT_ALIAS_OK) { |
379 |
if (retval == PKT_ALIAS_OK) { |
365 |
/* Nat instance recognises state */ |
380 |
/* Nat instance recognises state */ |
|
|
381 |
if (t->mode & PKT_ALIAS_LOG) |
382 |
init_loghdr(&loghdr, t->id); |
366 |
found = 1; |
383 |
found = 1; |
367 |
break; |
384 |
break; |
368 |
} |
385 |
} |
Lines 373-378
ipfw_nat(struct ip_fw_args *args, struct cfg_nat *
Link Here
|
373 |
return (IP_FW_NAT); |
390 |
return (IP_FW_NAT); |
374 |
} |
391 |
} |
375 |
} else { |
392 |
} else { |
|
|
393 |
if (t->mode & PKT_ALIAS_LOG) { |
394 |
init_loghdr(&loghdr, t->id); |
395 |
ipfw_bpf_mtap2(&loghdr, PFLOG_HDRLEN, mcl); |
396 |
} |
376 |
if (args->flags & IPFW_ARGS_IN) |
397 |
if (args->flags & IPFW_ARGS_IN) |
377 |
retval = LibAliasIn(t->lib, c, |
398 |
retval = LibAliasIn(t->lib, c, |
378 |
mcl->m_len + M_TRAILINGSPACE(mcl)); |
399 |
mcl->m_len + M_TRAILINGSPACE(mcl)); |
Lines 453-458
ipfw_nat(struct ip_fw_args *args, struct cfg_nat *
Link Here
|
453 |
} |
474 |
} |
454 |
} |
475 |
} |
455 |
args->m = mcl; |
476 |
args->m = mcl; |
|
|
477 |
if (t->mode & PKT_ALIAS_LOG) { |
478 |
loghdr.dir = PF_OUT; |
479 |
ipfw_bpf_mtap2(&loghdr, PFLOG_HDRLEN, mcl); |
480 |
} |
456 |
return (IP_FW_NAT); |
481 |
return (IP_FW_NAT); |
457 |
} |
482 |
} |
458 |
|
483 |
|