Changeset View
Changeset View
Standalone View
Standalone View
sys/netpfil/ipfw/nat64/nat64_translate.h
/*- | /*- | ||||
* Copyright (c) 2015-2018 Yandex LLC | * SPDX-License-Identifier: BSD-2-Clause-FreeBSD | ||||
* Copyright (c) 2015-2018 Andrey V. Elsukov <ae@FreeBSD.org> | |||||
* All rights reserved. | |||||
* | * | ||||
* Copyright (c) 2015-2019 Yandex LLC | |||||
* Copyright (c) 2015-2019 Andrey V. Elsukov <ae@FreeBSD.org> | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
* are met: | * are met: | ||||
* | * | ||||
* 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||
* notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | ||||
* 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright | ||||
* notice, this list of conditions and the following disclaimer in the | * notice, this list of conditions and the following disclaimer in the | ||||
Show All 27 Lines | struct nat64_stats { | ||||
uint64_t nomatch4; /* No addr/port match */ | uint64_t nomatch4; /* No addr/port match */ | ||||
uint64_t noproto; /* Protocol not supported */ | uint64_t noproto; /* Protocol not supported */ | ||||
uint64_t nomem; /* mbufs allocation failed */ | uint64_t nomem; /* mbufs allocation failed */ | ||||
uint64_t dropped; /* number of packets silently | uint64_t dropped; /* number of packets silently | ||||
* dropped due to some errors/ | * dropped due to some errors/ | ||||
* unsupported/etc. | * unsupported/etc. | ||||
*/ | */ | ||||
uint64_t jrequests; /* number of jobs requests queued */ | uint64_t jrequests; /* jobs requests queued */ | ||||
uint64_t jcalls; /* number of jobs handler calls */ | uint64_t jcalls; /* jobs handler calls */ | ||||
uint64_t jhostsreq; /* number of hosts requests */ | uint64_t jhostsreq; /* hosts requests */ | ||||
uint64_t jportreq; | uint64_t jportreq; /* PG allocation requests */ | ||||
uint64_t jhostfails; | uint64_t jhostfails; /* hosts requests failed */ | ||||
uint64_t jportfails; | uint64_t jportfails; /* PG allocation failed */ | ||||
uint64_t jmaxlen; | uint64_t jmaxlen; | ||||
uint64_t jnomem; | uint64_t jnomem; | ||||
uint64_t jreinjected; | uint64_t jreinjected; | ||||
uint64_t screated; | uint64_t screated; | ||||
uint64_t sdeleted; | uint64_t sdeleted; | ||||
uint64_t spgcreated; | uint64_t spgcreated; | ||||
uint64_t spgdeleted; | uint64_t spgdeleted; | ||||
Show All 17 Lines | |||||
#define UDP(p) ((struct udphdr *)(p)) | #define UDP(p) ((struct udphdr *)(p)) | ||||
#define ICMP(p) ((struct icmphdr *)(p)) | #define ICMP(p) ((struct icmphdr *)(p)) | ||||
#define ICMP6(p) ((struct icmp6_hdr *)(p)) | #define ICMP6(p) ((struct icmp6_hdr *)(p)) | ||||
#define NAT64SKIP 0 | #define NAT64SKIP 0 | ||||
#define NAT64RETURN 1 | #define NAT64RETURN 1 | ||||
#define NAT64MFREE -1 | #define NAT64MFREE -1 | ||||
/* | |||||
* According to RFC6877: | |||||
* PLAT is provider-side translator (XLAT) that translates N:1 global | |||||
* IPv6 addresses to global IPv4 addresses, and vice versa. | |||||
* | |||||
* CLAT is customer-side translator (XLAT) that algorithmically | |||||
* translates 1:1 private IPv4 addresses to global IPv6 addresses, | |||||
* and vice versa. | |||||
*/ | |||||
struct nat64_config { | struct nat64_config { | ||||
struct in6_addr clat_prefix; | |||||
struct in6_addr plat_prefix; | |||||
uint32_t flags; | uint32_t flags; | ||||
#define NAT64_WKPFX 0x00010000 /* prefix6 is WKPFX */ | #define NAT64_WKPFX 0x00010000 /* prefix is well-known */ | ||||
struct in6_addr prefix6; | #define NAT64_CLATPFX 0x00020000 /* dst prefix is configured */ | ||||
uint8_t plen6; | #define NAT64_PLATPFX 0x00040000 /* src prefix is configured */ | ||||
uint8_t clat_plen; | |||||
uint8_t plat_plen; | |||||
struct nat64_counters stats; | struct nat64_counters stats; | ||||
}; | }; | ||||
static inline int | static inline int | ||||
nat64_check_ip6(struct in6_addr *addr) | nat64_check_ip6(struct in6_addr *addr) | ||||
{ | { | ||||
Show All 31 Lines | |||||
int nat64_getlasthdr(struct mbuf *m, int *offset); | int nat64_getlasthdr(struct mbuf *m, int *offset); | ||||
int nat64_do_handle_ip4(struct mbuf *m, struct in6_addr *saddr, | int nat64_do_handle_ip4(struct mbuf *m, struct in6_addr *saddr, | ||||
struct in6_addr *daddr, uint16_t lport, struct nat64_config *cfg, | struct in6_addr *daddr, uint16_t lport, struct nat64_config *cfg, | ||||
void *logdata); | void *logdata); | ||||
int nat64_do_handle_ip6(struct mbuf *m, uint32_t aaddr, uint16_t aport, | int nat64_do_handle_ip6(struct mbuf *m, uint32_t aaddr, uint16_t aport, | ||||
struct nat64_config *cfg, void *logdata); | struct nat64_config *cfg, void *logdata); | ||||
int nat64_handle_icmp6(struct mbuf *m, int hlen, uint32_t aaddr, | int nat64_handle_icmp6(struct mbuf *m, int hlen, uint32_t aaddr, | ||||
uint16_t aport, struct nat64_config *cfg, void *logdata); | uint16_t aport, struct nat64_config *cfg, void *logdata); | ||||
void nat64_embed_ip4(const struct nat64_config *cfg, in_addr_t ia, | void nat64_embed_ip4(struct in6_addr *ip6, int plen, in_addr_t ia); | ||||
struct in6_addr *ip6); | in_addr_t nat64_extract_ip4(const struct in6_addr *ip6, int plen); | ||||
in_addr_t nat64_extract_ip4(const struct nat64_config *cfg, | |||||
const struct in6_addr *ip6); | |||||
void nat64_set_output_method(int); | void nat64_set_output_method(int); | ||||
int nat64_get_output_method(void); | int nat64_get_output_method(void); | ||||
#endif | #endif | ||||