NAT44: nat44_static_mapping_details protocol=0 if addr_only=0 (VPP-1158)
Change-Id: I1e3cfc751e7657464fc850dc56ddf763df45f62e Signed-off-by: Matus Fabian <matfabia@cisco.com>
This commit is contained in:
@ -13,7 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
option version = "2.4.0";
|
option version = "2.4.1";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file nat.api
|
* @file nat.api
|
||||||
@ -343,9 +343,9 @@ define nat44_interface_output_feature_details {
|
|||||||
@param addr_only - 1 if address only mapping
|
@param addr_only - 1 if address only mapping
|
||||||
@param local_ip_address - local IPv4 address
|
@param local_ip_address - local IPv4 address
|
||||||
@param external_ip_address - external IPv4 address
|
@param external_ip_address - external IPv4 address
|
||||||
@param protocol - IP protocol
|
@param protocol - IP protocol, used only if addr_only=0
|
||||||
@param local_port - local port number
|
@param local_port - local port number, used only if addr_only=0
|
||||||
@param external_port - external port number
|
@param external_port - external port number, used only if addr_only=0
|
||||||
@param external_sw_if_index - external interface (if set
|
@param external_sw_if_index - external interface (if set
|
||||||
external_ip_address is ignored, ~0 means not
|
external_ip_address is ignored, ~0 means not
|
||||||
used)
|
used)
|
||||||
@ -386,9 +386,9 @@ define nat44_static_mapping_dump {
|
|||||||
@param addr_only - 1 if address only mapping
|
@param addr_only - 1 if address only mapping
|
||||||
@param local_ip_address - local IPv4 address
|
@param local_ip_address - local IPv4 address
|
||||||
@param external_ip_address - external IPv4 address
|
@param external_ip_address - external IPv4 address
|
||||||
@param protocol - IP protocol
|
@param protocol - IP protocol, valid only if addr_only=0
|
||||||
@param local_port - local port number
|
@param local_port - local port number, valid only if addr_only=0
|
||||||
@param external_port - external port number
|
@param external_port - external port number, valid only if addr_only=0
|
||||||
@param external_sw_if_index - external interface
|
@param external_sw_if_index - external interface
|
||||||
@param vfr_id - VRF ID
|
@param vfr_id - VRF ID
|
||||||
@param twice_nat - if 1 translate external host address and port
|
@param twice_nat - if 1 translate external host address and port
|
||||||
|
@ -764,14 +764,17 @@ send_nat44_static_mapping_details (snat_static_mapping_t * m,
|
|||||||
rmp->addr_only = m->addr_only;
|
rmp->addr_only = m->addr_only;
|
||||||
clib_memcpy (rmp->local_ip_address, &(m->local_addr), 4);
|
clib_memcpy (rmp->local_ip_address, &(m->local_addr), 4);
|
||||||
clib_memcpy (rmp->external_ip_address, &(m->external_addr), 4);
|
clib_memcpy (rmp->external_ip_address, &(m->external_addr), 4);
|
||||||
rmp->local_port = htons (m->local_port);
|
|
||||||
rmp->external_port = htons (m->external_port);
|
|
||||||
rmp->external_sw_if_index = ~0;
|
rmp->external_sw_if_index = ~0;
|
||||||
rmp->vrf_id = htonl (m->vrf_id);
|
rmp->vrf_id = htonl (m->vrf_id);
|
||||||
rmp->protocol = snat_proto_to_ip_proto (m->proto);
|
|
||||||
rmp->context = context;
|
rmp->context = context;
|
||||||
rmp->twice_nat = m->twice_nat;
|
rmp->twice_nat = m->twice_nat;
|
||||||
rmp->out2in_only = m->out2in_only;
|
rmp->out2in_only = m->out2in_only;
|
||||||
|
if (m->addr_only == 0)
|
||||||
|
{
|
||||||
|
rmp->protocol = snat_proto_to_ip_proto (m->proto);
|
||||||
|
rmp->external_port = htons (m->external_port);
|
||||||
|
rmp->local_port = htons (m->local_port);
|
||||||
|
}
|
||||||
if (m->tag)
|
if (m->tag)
|
||||||
strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
|
strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
|
||||||
|
|
||||||
@ -792,13 +795,16 @@ send_nat44_static_map_resolve_details (snat_static_map_resolve_t * m,
|
|||||||
ntohs (VL_API_NAT44_STATIC_MAPPING_DETAILS + sm->msg_id_base);
|
ntohs (VL_API_NAT44_STATIC_MAPPING_DETAILS + sm->msg_id_base);
|
||||||
rmp->addr_only = m->addr_only;
|
rmp->addr_only = m->addr_only;
|
||||||
clib_memcpy (rmp->local_ip_address, &(m->l_addr), 4);
|
clib_memcpy (rmp->local_ip_address, &(m->l_addr), 4);
|
||||||
rmp->local_port = htons (m->l_port);
|
|
||||||
rmp->external_port = htons (m->e_port);
|
|
||||||
rmp->external_sw_if_index = htonl (m->sw_if_index);
|
rmp->external_sw_if_index = htonl (m->sw_if_index);
|
||||||
rmp->vrf_id = htonl (m->vrf_id);
|
rmp->vrf_id = htonl (m->vrf_id);
|
||||||
rmp->protocol = snat_proto_to_ip_proto (m->proto);
|
|
||||||
rmp->context = context;
|
rmp->context = context;
|
||||||
rmp->twice_nat = m->twice_nat;
|
rmp->twice_nat = m->twice_nat;
|
||||||
|
if (m->addr_only == 0)
|
||||||
|
{
|
||||||
|
rmp->protocol = snat_proto_to_ip_proto (m->proto);
|
||||||
|
rmp->external_port = htons (m->e_port);
|
||||||
|
rmp->local_port = htons (m->l_port);
|
||||||
|
}
|
||||||
if (m->tag)
|
if (m->tag)
|
||||||
strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
|
strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
|
||||||
|
|
||||||
|
@ -1383,6 +1383,9 @@ class TestNAT44(MethodHolder):
|
|||||||
sm = self.vapi.nat44_static_mapping_dump()
|
sm = self.vapi.nat44_static_mapping_dump()
|
||||||
self.assertEqual(len(sm), 1)
|
self.assertEqual(len(sm), 1)
|
||||||
self.assertEqual((sm[0].tag).split('\0', 1)[0], '')
|
self.assertEqual((sm[0].tag).split('\0', 1)[0], '')
|
||||||
|
self.assertEqual(sm[0].protocol, 0)
|
||||||
|
self.assertEqual(sm[0].local_port, 0)
|
||||||
|
self.assertEqual(sm[0].external_port, 0)
|
||||||
|
|
||||||
# in2out
|
# in2out
|
||||||
pkts = self.create_stream_in(self.pg0, self.pg1)
|
pkts = self.create_stream_in(self.pg0, self.pg1)
|
||||||
|
Reference in New Issue
Block a user