-/**
- * Function to get MAC addr of local link
- *
- * @params out_port
- * Physical port number
- *
- * @return
- * Outport Link MAC addr
- */
-
-struct ether_addr *get_local_link_hw_addr(uint8_t out_port)
-{
- return &link_hw_laddr[out_port];
-}
-
-/**
- * Function to get MAC addr from array instead of hash table
- *
- * @params out_port
- * Physical port number
- *
- * @return
- * Outport Link MAC addr
- */
-
-uint8_t local_dest_mac_present(uint8_t out_port)
-{
- return link_hw_laddr_valid[out_port];
-}
-
-/**
- * Function to get IPv4-IP NH from thread local array
- *
- * @params ip
- * IPv4 - IP
- * @params port
- * NH port number
- * @params nhip
- * NHIP of IPv4 type
- * @params p_nat
- * CGNAPT pipeline ptr
- *
- * @return
- * 1 on success, 0 for failure
- */
-
-static uint32_t local_get_nh_ipv4(
- uint32_t ip,
- uint32_t *port,
- uint32_t *nhip,
- struct pipeline_cgnapt *p_nat)
-{
- int i;
- for (i = 0; i < p_nat->local_lib_arp_route_ent_cnt; i++) {
- if (((p_nat->local_lib_arp_route_table[i].ip &
- p_nat->local_lib_arp_route_table[i].mask) ==
- (ip & p_nat->local_lib_arp_route_table[i].mask))) {
- *port = p_nat->local_lib_arp_route_table[i].port;
-
- *nhip = p_nat->local_lib_arp_route_table[i].nh;
- return 1;
- }
- }
- return 0;
-}
-
-/**
- * Function to make local copy for NH of type IPv4
- *
- * @params dest_if
- * Physical port number
- * @params p_nat
- * CGNAPT pipeline ptr
- *
- */
-
-static void do_local_nh_ipv4_cache(
- uint32_t dest_if,
- struct pipeline_cgnapt *p_nat)
-{
-
- /* Search for the entry and do local copy */
- int i;
-
- for (i = 0; i < MAX_ARP_RT_ENTRY; i++) {
- if (lib_arp_route_table[i].port == dest_if) {
-
- struct lib_arp_route_table_entry *lentry =
- &p_nat->local_lib_arp_route_table
- [p_nat->local_lib_arp_route_ent_cnt];
-
- lentry->ip = lib_arp_route_table[i].ip;
- lentry->mask = lib_arp_route_table[i].mask;
- lentry->port = lib_arp_route_table[i].port;
- lentry->nh = lib_arp_route_table[i].nh;
-
- p_nat->local_lib_arp_route_ent_cnt++;
- break;
- }
- }
-}
-
-
-/**
- * Function to get IPv6-IP NH from thread local array
- *
- * @params ip
- * Pointer to starting addr of IPv6
- * @params port
- * NH port number
- * @params nhip
- * NHIP of IPv6 type
- * @params p_nat
- * CGNAPT pipeline ptr
- *
- * @return
- * 1 on success, 0 for failure
- */
-
-static uint32_t local_get_nh_ipv6(
- uint8_t *ip,
- uint32_t *port,
- uint8_t nhip[],
- struct pipeline_cgnapt *p_nat)
-{
- int i = 0;
- uint8_t netmask_ipv6[16];
- uint8_t k = 0, l = 0, depthflags = 0, depthflags1 = 0;
-
- for (i = 0; i < p_nat->local_lib_nd_route_ent_cnt; i++) {
-
- convert_prefixlen_to_netmask_ipv6(
- p_nat->local_lib_nd_route_table[i].depth,
- netmask_ipv6);
-
- for (k = 0; k < 16; k++)
- if (p_nat->local_lib_nd_route_table[i].ipv6[k] &
- netmask_ipv6[k])
- depthflags++;
-
- for (l = 0; l < 16; l++)
- if (ip[l] & netmask_ipv6[l])
- depthflags1++;
-
- int j = 0;
- if (depthflags == depthflags1) {
- *port = p_nat->local_lib_nd_route_table[i].port;
-
- for (j = 0; j < 16; j++)
- nhip[j] = p_nat->local_lib_nd_route_table[i].
- nhipv6[j];
- return 1;
- }
-
- depthflags = 0;
- depthflags1 = 0;
- }
- return 0;
-}
-
-
-/**
- * Function to make local copy for NH of type IPv6
- *
- * @params dest_if
- * Physical port number
- * @params p_nat
- * CGNAPT pipeline ptr
- *
- */
-
-static void do_local_nh_ipv6_cache(
- uint32_t dest_if,
- struct pipeline_cgnapt *p_nat)
-{
- /* Search for the entry and do local copy */
- int i, l;
- for (i = 0; i < MAX_ND_RT_ENTRY; i++) {
-
- if (lib_nd_route_table[i].port == dest_if) {
-
- struct lib_nd_route_table_entry *lentry =
- &p_nat->local_lib_nd_route_table
- [p_nat->local_lib_nd_route_ent_cnt];
-
- for (l = 0; l < 16; l++) {
- lentry->ipv6[l] =
- lib_nd_route_table[i].ipv6[l];
- lentry->nhipv6[l] =
- lib_nd_route_table[i].nhipv6[l];
- }
- lentry->depth = lib_nd_route_table[i].depth;
- lentry->port = lib_nd_route_table[i].port;
-
- p_nat->local_lib_nd_route_ent_cnt++;
- break;
- } //if
- } //for
-}
-