/*
 *------------------------------------------------------------------
 * ip_api.c - vnet ip api
 *
 * Copyright (c) 2016 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *------------------------------------------------------------------
 */

#include <vnet/vnet.h>
#include <vlibmemory/api.h>

#include <vpp/stats/stats.h>
#include <vnet/interface.h>
#include <vnet/api_errno.h>
#include <vnet/ethernet/ethernet.h>
#include <vnet/ip/ip.h>
#include <vnet/ip/ip6_neighbor.h>
#include <vnet/fib/fib_table.h>
#include <vnet/fib/fib_api.h>
#include <vnet/dpo/drop_dpo.h>
#include <vnet/dpo/receive_dpo.h>
#include <vnet/dpo/lookup_dpo.h>
#include <vnet/dpo/classify_dpo.h>
#include <vnet/dpo/ip_null_dpo.h>
#include <vnet/ethernet/arp_packet.h>
#include <vnet/mfib/ip6_mfib.h>
#include <vnet/mfib/ip4_mfib.h>
#include <vnet/mfib/mfib_signal.h>
#include <vnet/mfib/mfib_entry.h>
#include <vnet/ip/ip_source_and_port_range_check.h>
#include <vnet/fib/ip4_fib.h>
#include <vnet/fib/ip6_fib.h>
#include <vnet/ip/ip6_hop_by_hop.h>
#include <vnet/ip/ip4_reassembly.h>
#include <vnet/ip/ip6_reassembly.h>

#include <vnet/vnet_msg_enum.h>

#define vl_typedefs		/* define message structures */
#include <vnet/vnet_all_api_h.h>
#undef vl_typedefs

#define vl_endianfun		/* define message structures */
#include <vnet/vnet_all_api_h.h>
#undef vl_endianfun

/* instantiate all the print functions we know about */
#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
#define vl_printfun
#include <vnet/vnet_all_api_h.h>
#undef vl_printfun

#include <vlibapi/api_helper_macros.h>


#define foreach_ip_api_msg                                              \
_(IP_FIB_DUMP, ip_fib_dump)                                             \
_(IP6_FIB_DUMP, ip6_fib_dump)                                           \
_(IP_MFIB_DUMP, ip_mfib_dump)                                           \
_(IP6_MFIB_DUMP, ip6_mfib_dump)                                         \
_(IP_NEIGHBOR_DUMP, ip_neighbor_dump)                                   \
_(IP_MROUTE_ADD_DEL, ip_mroute_add_del)                                 \
_(MFIB_SIGNAL_DUMP, mfib_signal_dump)                                   \
_(IP_ADDRESS_DUMP, ip_address_dump)                                     \
_(IP_DUMP, ip_dump)                                                     \
_(IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del)                             \
_(SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit)			\
_(WANT_IP4_ARP_EVENTS, want_ip4_arp_events)                             \
_(WANT_IP6_ND_EVENTS, want_ip6_nd_events)                               \
_(PROXY_ARP_ADD_DEL, proxy_arp_add_del)                                 \
_(PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable)       \
_(RESET_FIB, reset_fib)							\
_(IP_ADD_DEL_ROUTE, ip_add_del_route)                                   \
_(IP_TABLE_ADD_DEL, ip_table_add_del)                                   \
_(IP_PUNT_POLICE, ip_punt_police)                                       \
_(IP_PUNT_REDIRECT, ip_punt_redirect)                                   \
_(SET_IP_FLOW_HASH,set_ip_flow_hash)                                    \
_(SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config)           \
_(SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix)           \
_(IP6ND_PROXY_ADD_DEL, ip6nd_proxy_add_del)                             \
_(IP6ND_PROXY_DUMP, ip6nd_proxy_dump)                                   \
_(SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable )    \
_(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, 				\
  sw_interface_ip6_set_link_local_address)				\
_(IP_CONTAINER_PROXY_ADD_DEL, ip_container_proxy_add_del)               \
_(IOAM_ENABLE, ioam_enable)                                             \
_(IOAM_DISABLE, ioam_disable)                                           \
_(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,                               \
  ip_source_and_port_range_check_add_del)                               \
_(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,                     \
  ip_source_and_port_range_check_interface_add_del)                     \
_(IP_REASSEMBLY_SET, ip_reassembly_set)                                 \
_(IP_REASSEMBLY_GET, ip_reassembly_get)

extern void stats_dslock_with_hint (int hint, int tag);
extern void stats_dsunlock (void);

static void
send_ip_neighbor_details (u32 sw_if_index,
			  u8 is_ipv6,
			  u8 is_static,
			  u8 * mac_address,
			  u8 * ip_address, vl_api_registration_t * reg,
			  u32 context)
{
  vl_api_ip_neighbor_details_t *mp;

  mp = vl_msg_api_alloc (sizeof (*mp));
  memset (mp, 0, sizeof (*mp));
  mp->_vl_msg_id = ntohs (VL_API_IP_NEIGHBOR_DETAILS);
  mp->context = context;
  mp->sw_if_index = htonl (sw_if_index);
  mp->is_ipv6 = is_ipv6;
  mp->is_static = is_static;
  memcpy (mp->mac_address, mac_address, 6);
  memcpy (mp->ip_address, ip_address, (is_ipv6) ? 16 : 4);

  vl_api_send_msg (reg, (u8 *) mp);
}

static void
vl_api_ip_neighbor_dump_t_handler (vl_api_ip_neighbor_dump_t * mp)
{
  vl_api_registration_t *reg;

  reg = vl_api_client_index_to_registration (mp->client_index);
  if (!reg)
    return;

  u32 sw_if_index = ntohl (mp->sw_if_index);

  if (mp->is_ipv6)
    {
      ip6_neighbor_t *n, *ns;

      ns = ip6_neighbors_entries (sw_if_index);
      /* *INDENT-OFF* */
      vec_foreach (n, ns)
      {
        send_ip_neighbor_details
          (sw_if_index, mp->is_ipv6,
	   ((n->flags & IP6_NEIGHBOR_FLAG_STATIC) ? 1 : 0),
           (u8 *) n->link_layer_address,
           (u8 *) & (n->key.ip6_address.as_u8),
           reg, mp->context);
      }
      /* *INDENT-ON* */
      vec_free (ns);
    }
  else
    {
      ethernet_arp_ip4_entry_t *n, *ns;

      ns = ip4_neighbor_entries (sw_if_index);
      /* *INDENT-OFF* */
      vec_foreach (n, ns)
      {
        send_ip_neighbor_details (sw_if_index, mp->is_ipv6,
          ((n->flags & ETHERNET_ARP_IP4_ENTRY_FLAG_STATIC) ? 1 : 0),
          (u8*) n->ethernet_address,
          (u8*) & (n->ip4_address.as_u8),
          reg, mp->context);
      }
      /* *INDENT-ON* */
      vec_free (ns);
    }
}


void
copy_fib_next_hop (fib_route_path_encode_t * api_rpath, void *fp_arg)
{
  int is_ip4;
  vl_api_fib_path_t *fp = (vl_api_fib_path_t *) fp_arg;

  if (api_rpath->rpath.frp_proto == DPO_PROTO_IP4)
    fp->afi = IP46_TYPE_IP4;
  else if (api_rpath->rpath.frp_proto == DPO_PROTO_IP6)
    fp->afi = IP46_TYPE_IP6;
  else
    {
      is_ip4 = ip46_address_is_ip4 (&api_rpath->rpath.frp_addr);
      if (is_ip4)
	fp->afi = IP46_TYPE_IP4;
      else
	fp->afi = IP46_TYPE_IP6;
    }
  if (fp->afi == IP46_TYPE_IP4)
    memcpy (fp->next_hop, &api_rpath->rpath.frp_addr.ip4,
	    sizeof (api_rpath->rpath.frp_addr.ip4));
  else
    memcpy (fp->next_hop, &api_rpath->rpath.frp_addr.ip6,
	    sizeof (api_rpath->rpath.frp_addr.ip6));
}

static void
send_ip_fib_details (vpe_api_main_t * am,
		     vl_api_registration_t * reg,
		     const fib_table_t * table,
		     const fib_prefix_t * pfx,
		     fib_route_path_encode_t * api_rpaths, u32 context)
{
  vl_api_ip_fib_details_t *mp;
  fib_route_path_encode_t *api_rpath;
  vl_api_fib_path_t *fp;
  int path_count;

  path_count = vec_len (api_rpaths);
  mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
  if (!mp)
    return;
  memset (mp, 0, sizeof (*mp));
  mp->_vl_msg_id = ntohs (VL_API_IP_FIB_DETAILS);
  mp->context = context;

  mp->table_id = htonl (table->ft_table_id);
  memcpy (mp->table_name, table->ft_desc,
	  clib_min (vec_len (table->ft_desc), sizeof (mp->table_name)));
  mp->address_length = pfx->fp_len;
  memcpy (mp->address, &pfx->fp_addr.ip4, sizeof (pfx->fp_addr.ip4));

  mp->count = htonl (path_count);
  fp = mp->path;
  vec_foreach (api_rpath, api_rpaths)
  {
    memset (fp, 0, sizeof (*fp));
    switch (api_rpath->dpo.dpoi_type)
      {
      case DPO_RECEIVE:
	fp->is_local = true;
	break;
      case DPO_DROP:
	fp->is_drop = true;
	break;
      case DPO_IP_NULL:
	switch (api_rpath->dpo.dpoi_index)
	  {
	  case IP_NULL_ACTION_NONE:
	    fp->is_drop = true;
	    break;
	  case IP_NULL_ACTION_SEND_ICMP_UNREACH:
	    fp->is_unreach = true;
	    break;
	  case IP_NULL_ACTION_SEND_ICMP_PROHIBIT:
	    fp->is_prohibit = true;
	    break;
	  default:
	    break;
	  }
	break;
      default:
	break;
      }
    fp->weight = api_rpath->rpath.frp_weight;
    fp->preference = api_rpath->rpath.frp_preference;
    fp->sw_if_index = htonl (api_rpath->rpath.frp_sw_if_index);
    copy_fib_next_hop (api_rpath, fp);
    fp++;
  }

  vl_api_send_msg (reg, (u8 *) mp);
}

typedef struct vl_api_ip_fib_dump_walk_ctx_t_
{
  fib_node_index_t *feis;
} vl_api_ip_fib_dump_walk_ctx_t;

static fib_table_walk_rc_t
vl_api_ip_fib_dump_walk (fib_node_index_t fei, void *arg)
{
  vl_api_ip_fib_dump_walk_ctx_t *ctx = arg;

  vec_add1 (ctx->feis, fei);

  return (FIB_TABLE_WALK_CONTINUE);
}

static void
vl_api_ip_fib_dump_t_handler (vl_api_ip_fib_dump_t * mp)
{
  vpe_api_main_t *am = &vpe_api_main;
  vl_api_registration_t *reg;
  ip4_main_t *im = &ip4_main;
  fib_table_t *fib_table;
  fib_node_index_t *lfeip;
  fib_prefix_t pfx;
  u32 fib_index;
  fib_route_path_encode_t *api_rpaths;
  vl_api_ip_fib_dump_walk_ctx_t ctx = {
    .feis = NULL,
  };

  reg = vl_api_client_index_to_registration (mp->client_index);
  if (!reg)
    return;

  /* *INDENT-OFF* */
  pool_foreach (fib_table, im->fibs,
  ({
    fib_table_walk(fib_table->ft_index,
                   FIB_PROTOCOL_IP4,
                   vl_api_ip_fib_dump_walk,
                   &ctx);
  }));
  /* *INDENT-ON* */

  vec_sort_with_function (ctx.feis, fib_entry_cmp_for_sort);

  vec_foreach (lfeip, ctx.feis)
  {
    fib_entry_get_prefix (*lfeip, &pfx);
    fib_index = fib_entry_get_fib_index (*lfeip);
    fib_table = fib_table_get (fib_index, pfx.fp_proto);
    api_rpaths = NULL;
    fib_entry_encode (*lfeip, &api_rpaths);
    send_ip_fib_details (am, reg, fib_table, &pfx, api_rpaths, mp->context);
    vec_free (api_rpaths);
  }

  vec_free (ctx.feis);
}

static void
send_ip6_fib_details (vpe_api_main_t * am,
		      vl_api_registration_t * reg,
		      const fib_table_t * table,
		      const fib_prefix_t * pfx,
		      fib_route_path_encode_t * api_rpaths, u32 context)
{
  vl_api_ip6_fib_details_t *mp;
  fib_route_path_encode_t *api_rpath;
  vl_api_fib_path_t *fp;
  int path_count;

  path_count = vec_len (api_rpaths);
  mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
  if (!mp)
    return;
  memset (mp, 0, sizeof (*mp));
  mp->_vl_msg_id = ntohs (VL_API_IP6_FIB_DETAILS);
  mp->context = context;

  mp->table_id = htonl (table->ft_table_id);
  mp->address_length = pfx->fp_len;
  memcpy (mp->address, &pfx->fp_addr.ip6, sizeof (pfx->fp_addr.ip6));
  memcpy (mp->table_name, table->ft_desc,
	  clib_min (vec_len (table->ft_desc), sizeof (mp->table_name)));

  mp->count = htonl (path_count);
  fp = mp->path;
  vec_foreach (api_rpath, api_rpaths)
  {
    memset (fp, 0, sizeof (*fp));
    switch (api_rpath->dpo.dpoi_type)
      {
      case DPO_RECEIVE:
	fp->is_local = true;
	break;
      case DPO_DROP:
	fp->is_drop = true;
	break;
      case DPO_IP_NULL:
	switch (api_rpath->dpo.dpoi_index)
	  {
	  case IP_NULL_DPO_ACTION_NUM + IP_NULL_ACTION_NONE:
	    fp->is_drop = true;
	    break;
	  case IP_NULL_DPO_ACTION_NUM + IP_NULL_ACTION_SEND_ICMP_UNREACH:
	    fp->is_unreach = true;
	    break;
	  case IP_NULL_DPO_ACTION_NUM + IP_NULL_ACTION_SEND_ICMP_PROHIBIT:
	    fp->is_prohibit = true;
	    break;
	  default:
	    break;
	  }
	break;
      default:
	break;
      }
    fp->weight = api_rpath->rpath.frp_weight;
    fp->preference = api_rpath->rpath.frp_preference;
    fp->sw_if_index = htonl (api_rpath->rpath.frp_sw_if_index);
    copy_fib_next_hop (api_rpath, fp);
    fp++;
  }

  vl_api_send_msg (reg, (u8 *) mp);
}

typedef struct apt_ip6_fib_show_ctx_t_
{
  u32 fib_index;
  fib_node_index_t *entries;
} api_ip6_fib_show_ctx_t;

static void
api_ip6_fib_table_put_entries (clib_bihash_kv_24_8_t * kvp, void *arg)
{
  api_ip6_fib_show_ctx_t *ctx = arg;

  if ((kvp->key[2] >> 32) == ctx->fib_index)
    {
      vec_add1 (ctx->entries, kvp->value);
    }
}

static void
api_ip6_fib_table_get_all (vl_api_registration_t * reg,
			   vl_api_ip6_fib_dump_t * mp,
			   fib_table_t * fib_table)
{
  vpe_api_main_t *am = &vpe_api_main;
  ip6_main_t *im6 = &ip6_main;
  fib_node_index_t *fib_entry_index;
  api_ip6_fib_show_ctx_t ctx = {
    .fib_index = fib_table->ft_index,
    .entries = NULL,
  };
  fib_route_path_encode_t *api_rpaths;
  fib_prefix_t pfx;

  BV (clib_bihash_foreach_key_value_pair)
    ((BVT (clib_bihash) *) & im6->ip6_table[IP6_FIB_TABLE_NON_FWDING].
     ip6_hash, api_ip6_fib_table_put_entries, &ctx);

  vec_sort_with_function (ctx.entries, fib_entry_cmp_for_sort);

  vec_foreach (fib_entry_index, ctx.entries)
  {
    fib_entry_get_prefix (*fib_entry_index, &pfx);
    api_rpaths = NULL;
    fib_entry_encode (*fib_entry_index, &api_rpaths);
    send_ip6_fib_details (am, reg, fib_table, &pfx, api_rpaths, mp->context);
    vec_free (api_rpaths);
  }

  vec_free (ctx.entries);
}

static void
vl_api_ip6_fib_dump_t_handler (vl_api_ip6_fib_dump_t * mp)
{
  vl_api_registration_t *reg;
  ip6_main_t *im6 = &ip6_main;
  fib_table_t *fib_table;

  reg = vl_api_client_index_to_registration (mp->client_index);
  if (!reg)
    return;

  /* *INDENT-OFF* */
  pool_foreach (fib_table, im6->fibs,
  ({
    api_ip6_fib_table_get_all(reg, mp, fib_table);
  }));
  /* *INDENT-ON* */
}

static void
send_ip_mfib_details (vl_api_registration_t * reg,
		      u32 context, u32 table_id, fib_node_index_t mfei)
{
  fib_route_path_encode_t *api_rpath, *api_rpaths = NULL;
  vl_api_ip_mfib_details_t *mp;
  mfib_entry_t *mfib_entry;
  vl_api_fib_path_t *fp;
  mfib_prefix_t pfx;
  int path_count;

  mfib_entry = mfib_entry_get (mfei);
  mfib_entry_get_prefix (mfei, &pfx);
  mfib_entry_encode (mfei, &api_rpaths);

  path_count = vec_len (api_rpaths);
  mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
  if (!mp)
    return;
  memset (mp, 0, sizeof (*mp));
  mp->_vl_msg_id = ntohs (VL_API_IP_MFIB_DETAILS);
  mp->context = context;

  mp->rpf_id = mfib_entry->mfe_rpf_id;
  mp->entry_flags = mfib_entry->mfe_flags;
  mp->table_id = htonl (table_id);
  mp->address_length = pfx.fp_len;
  memcpy (mp->grp_address, &pfx.fp_grp_addr.ip4,
	  sizeof (pfx.fp_grp_addr.ip4));
  memcpy (mp->src_address, &pfx.fp_src_addr.ip4,
	  sizeof (pfx.fp_src_addr.ip4));

  mp->count = htonl (path_count);
  fp = mp->path;
  vec_foreach (api_rpath, api_rpaths)
  {
    memset (fp, 0, sizeof (*fp));

    fp->weight = 0;
    fp->sw_if_index = htonl (api_rpath->rpath.frp_sw_if_index);
    copy_fib_next_hop (api_rpath, fp);
    fp++;
  }
  vec_free (api_rpaths);

  vl_api_send_msg (reg, (u8 *) mp);
}

typedef struct vl_api_ip_mfib_dump_ctc_t_
{
  fib_node_index_t *entries;
} vl_api_ip_mfib_dump_ctc_t;

static int
vl_api_ip_mfib_table_dump_walk (fib_node_index_t fei, void *arg)
{
  vl_api_ip_mfib_dump_ctc_t *ctx = arg;

  vec_add1 (ctx->entries, fei);

  return (0);
}

static void
vl_api_ip_mfib_dump_t_handler (vl_api_ip_mfib_dump_t * mp)
{
  vl_api_registration_t *reg;
  ip4_main_t *im = &ip4_main;
  mfib_table_t *mfib_table;
  fib_node_index_t *mfeip;
  vl_api_ip_mfib_dump_ctc_t ctx = {
    .entries = NULL,
  };

  reg = vl_api_client_index_to_registration (mp->client_index);
  if (!reg)
    return;

  /* *INDENT-OFF* */
  pool_foreach (mfib_table, im->mfibs,
  ({
    ip4_mfib_table_walk(&mfib_table->v4,
                        vl_api_ip_mfib_table_dump_walk,
                        &ctx);

    vec_sort_with_function (ctx.entries, mfib_entry_cmp_for_sort);

    vec_foreach (mfeip, ctx.entries)
    {
      send_ip_mfib_details (reg, mp->context,
                            mfib_table->mft_table_id,
                            *mfeip);
    }
    vec_reset_length (ctx.entries);

  }));
  /* *INDENT-ON* */

  vec_free (ctx.entries);
}

static void
send_ip6_mfib_details (vpe_api_main_t * am,
		       vl_api_registration_t * reg,
		       u32 table_id,
		       mfib_prefix_t * pfx,
		       fib_route_path_encode_t * api_rpaths, u32 context)
{
  vl_api_ip6_mfib_details_t *mp;
  fib_route_path_encode_t *api_rpath;
  vl_api_fib_path_t *fp;
  int path_count;

  path_count = vec_len (api_rpaths);
  mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
  if (!mp)
    return;
  memset (mp, 0, sizeof (*mp));
  mp->_vl_msg_id = ntohs (VL_API_IP6_MFIB_DETAILS);
  mp->context = context;

  mp->table_id = htonl (table_id);
  mp->address_length = pfx->fp_len;
  memcpy (mp->grp_address, &pfx->fp_grp_addr.ip6,
	  sizeof (pfx->fp_grp_addr.ip6));
  memcpy (mp->src_address, &pfx->fp_src_addr.ip6,
	  sizeof (pfx->fp_src_addr.ip6));

  mp->count = htonl (path_count);
  fp = mp->path;
  vec_foreach (api_rpath, api_rpaths)
  {
    memset (fp, 0, sizeof (*fp));

    fp->weight = 0;
    fp->sw_if_index = htonl (api_rpath->rpath.frp_sw_if_index);
    copy_fib_next_hop (api_rpath, fp);
    fp++;
  }

  vl_api_send_msg (reg, (u8 *) mp);
}

typedef struct vl_api_ip6_mfib_dump_ctc_t_
{
  fib_node_index_t *entries;
} vl_api_ip6_mfib_dump_ctc_t;

static int
vl_api_ip6_mfib_table_dump_walk (fib_node_index_t fei, void *arg)
{
  vl_api_ip6_mfib_dump_ctc_t *ctx = arg;

  vec_add1 (ctx->entries, fei);

  return (0);
}

static void
vl_api_ip6_mfib_dump_t_handler (vl_api_ip6_mfib_dump_t * mp)
{
  vpe_api_main_t *am = &vpe_api_main;
  vl_api_registration_t *reg;
  ip6_main_t *im = &ip6_main;
  mfib_table_t *mfib_table;
  fib_node_index_t *mfeip;
  mfib_prefix_t pfx;
  fib_route_path_encode_t *api_rpaths = NULL;
  vl_api_ip6_mfib_dump_ctc_t ctx = {
    .entries = NULL,
  };

  reg = vl_api_client_index_to_registration (mp->client_index);
  if (!reg)
    return;


  /* *INDENT-OFF* */
  pool_foreach (mfib_table, im->mfibs,
  ({
    ip6_mfib_table_walk(&mfib_table->v6,
                        vl_api_ip6_mfib_table_dump_walk,
                        &ctx);

    vec_sort_with_function (ctx.entries, mfib_entry_cmp_for_sort);

    vec_foreach(mfeip, ctx.entries)
    {
      mfib_entry_get_prefix (*mfeip, &pfx);
      mfib_entry_encode (*mfeip, &api_rpaths);
      send_ip6_mfib_details (am, reg,
                             mfib_table->mft_table_id,
                             &pfx, api_rpaths,
                             mp->context);
    }
    vec_reset_length (api_rpaths);
    vec_reset_length (ctx.entries);

  }));
  /* *INDENT-ON* */

  vec_free (ctx.entries);
  vec_free (api_rpaths);
}

static void
vl_api_ip_punt_police_t_handler (vl_api_ip_punt_police_t * mp,
				 vlib_main_t * vm)
{
  vl_api_ip_punt_police_reply_t *rmp;
  int rv = 0;

  if (mp->is_ip6)
    ip6_punt_policer_add_del (mp->is_add, ntohl (mp->policer_index));
  else
    ip4_punt_policer_add_del (mp->is_add, ntohl (mp->policer_index));

  REPLY_MACRO (VL_API_IP_PUNT_POLICE_REPLY);
}

static void
vl_api_ip_punt_redirect_t_handler (vl_api_ip_punt_redirect_t * mp,
				   vlib_main_t * vm)
{
  vl_api_ip_punt_redirect_reply_t *rmp;
  int rv = 0;

  if (mp->is_add)
    {
      ip46_address_t nh;

      memset (&nh, 0, sizeof (nh));

      if (mp->is_ip6)
	{
	  memcpy (&nh.ip6, mp->nh, sizeof (nh.ip6));

	  ip6_punt_redirect_add (ntohl (mp->rx_sw_if_index),
				 ntohl (mp->tx_sw_if_index), &nh);
	}
      else
	{
	  memcpy (&nh.ip4, mp->nh, sizeof (nh.ip4));

	  ip4_punt_redirect_add (ntohl (mp->rx_sw_if_index),
				 ntohl (mp->tx_sw_if_index), &nh);
	}
    }
  else
    {
      if (mp->is_ip6)
	{
	  ip6_punt_redirect_del (ntohl (mp->rx_sw_if_index));
	}
      else
	{
	  ip4_punt_redirect_del (ntohl (mp->rx_sw_if_index));
	}
    }

  REPLY_MACRO (VL_API_IP_PUNT_REDIRECT_REPLY);
}

static void
vl_api_ip_neighbor_add_del_t_handler (vl_api_ip_neighbor_add_del_t * mp,
				      vlib_main_t * vm)
{
  vl_api_ip_neighbor_add_del_reply_t *rmp;
  vnet_main_t *vnm = vnet_get_main ();
  int rv = 0;

  VALIDATE_SW_IF_INDEX (mp);

  stats_dslock_with_hint (1 /* release hint */ , 7 /* tag */ );

  /*
   * there's no validation here of the ND/ARP entry being added.
   * The expectation is that the FIB will ensure that nothing bad
   * will come of adding bogus entries.
   */
  if (mp->is_ipv6)
    {
      if (mp->is_add)
	rv = vnet_set_ip6_ethernet_neighbor
	  (vm, ntohl (mp->sw_if_index),
	   (ip6_address_t *) (mp->dst_address),
	   mp->mac_address, sizeof (mp->mac_address), mp->is_static,
	   mp->is_no_adj_fib);
      else
	rv = vnet_unset_ip6_ethernet_neighbor
	  (vm, ntohl (mp->sw_if_index),
	   (ip6_address_t *) (mp->dst_address),
	   mp->mac_address, sizeof (mp->mac_address));
    }
  else
    {
      ethernet_arp_ip4_over_ethernet_address_t a;

      clib_memcpy (&a.ethernet, mp->mac_address, 6);
      clib_memcpy (&a.ip4, mp->dst_address, 4);

      if (mp->is_add)
	rv = vnet_arp_set_ip4_over_ethernet (vnm, ntohl (mp->sw_if_index),
					     &a, mp->is_static,
					     mp->is_no_adj_fib);
      else
	rv =
	  vnet_arp_unset_ip4_over_ethernet (vnm, ntohl (mp->sw_if_index), &a);
    }

  stats_dsunlock ();

  BAD_SW_IF_INDEX_LABEL;
  REPLY_MACRO (VL_API_IP_NEIGHBOR_ADD_DEL_REPLY);
}

void
ip_table_delete (fib_protocol_t fproto, u32 table_id, u8 is_api)
{
  u32 fib_index, mfib_index;

  /*
   * ignore action on the default table - this is always present
   * and cannot be added nor deleted from the API
   */
  if (0 != table_id)
    {
      /*
       * The API holds only one lock on the table.
       * i.e. it can be added many times via the API but needs to be
       * deleted only once.
       * The FIB index for unicast and multicast is not necessarily the
       * same, since internal VPP systesm (like LISP and SR) create
       * their own unicast tables.
       */
      fib_index = fib_table_find (fproto, table_id);
      mfib_index = mfib_table_find (fproto, table_id);

      if (~0 != fib_index)
	{
	  fib_table_unlock (fib_index, fproto,
			    (is_api ? FIB_SOURCE_API : FIB_SOURCE_CLI));
	}
      if (~0 != mfib_index)
	{
	  mfib_table_unlock (mfib_index, fproto,
			     (is_api ? MFIB_SOURCE_API : MFIB_SOURCE_CLI));
	}
    }
}

void
vl_api_ip_table_add_del_t_handler (vl_api_ip_table_add_del_t * mp)
{
  vl_api_ip_table_add_del_reply_t *rmp;
  fib_protocol_t fproto = (mp->is_ipv6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4);
  u32 table_id = ntohl (mp->table_id);
  int rv = 0;

  if (mp->is_add)
    {
      ip_table_create (fproto, table_id, 1, mp->name);
    }
  else
    {
      ip_table_delete (fproto, table_id, 1);
    }

  REPLY_MACRO (VL_API_IP_TABLE_ADD_DEL_REPLY);
}

int
add_del_route_t_handler (u8 is_multipath,
			 u8 is_add,
			 u8 is_drop,
			 u8 is_unreach,
			 u8 is_prohibit,
			 u8 is_local,
			 u8 is_multicast,
			 u8 is_classify,
			 u32 classify_table_index,
			 u8 is_resolve_host,
			 u8 is_resolve_attached,
			 u8 is_interface_rx,
			 u8 is_rpf_id,
			 u8 is_dvr,
			 u8 is_source_lookup,
			 u8 is_udp_encap,
			 u32 fib_index,
			 const fib_prefix_t * prefix,
			 dpo_proto_t next_hop_proto,
			 const ip46_address_t * next_hop,
			 u32 next_hop_id,
			 u32 next_hop_sw_if_index,
			 u8 next_hop_fib_index,
			 u16 next_hop_weight,
			 u16 next_hop_preference,
			 mpls_label_t next_hop_via_label,
			 mpls_label_t * next_hop_out_label_stack)
{
  vnet_classify_main_t *cm = &vnet_classify_main;
  fib_route_path_flags_t path_flags = FIB_ROUTE_PATH_FLAG_NONE;
  fib_route_path_t path = {
    .frp_proto = next_hop_proto,
    .frp_addr = (NULL == next_hop ? zero_addr : *next_hop),
    .frp_sw_if_index = next_hop_sw_if_index,
    .frp_fib_index = next_hop_fib_index,
    .frp_weight = next_hop_weight,
    .frp_preference = next_hop_preference,
    .frp_label_stack = next_hop_out_label_stack,
  };
  fib_route_path_t *paths = NULL;
  fib_entry_flag_t entry_flags = FIB_ENTRY_FLAG_NONE;

  /*
   * the special INVALID label meams we are not recursing via a
   * label. Exp-null value is never a valid via-label so that
   * also means it's not a via-label and means clients that set
   * it to 0 by default get the expected behaviour
   */
  if ((MPLS_LABEL_INVALID != next_hop_via_label) && (0 != next_hop_via_label))
    {
      path.frp_proto = DPO_PROTO_MPLS;
      path.frp_local_label = next_hop_via_label;
      path.frp_eos = MPLS_NON_EOS;
    }
  if (is_dvr)
    path_flags |= FIB_ROUTE_PATH_DVR;
  if (is_resolve_host)
    path_flags |= FIB_ROUTE_PATH_RESOLVE_VIA_HOST;
  if (is_resolve_attached)
    path_flags |= FIB_ROUTE_PATH_RESOLVE_VIA_ATTACHED;
  if (is_interface_rx)
    path_flags |= FIB_ROUTE_PATH_INTF_RX;
  if (is_rpf_id)
    path_flags |= FIB_ROUTE_PATH_RPF_ID;
  if (is_source_lookup)
    path_flags |= FIB_ROUTE_PATH_SOURCE_LOOKUP;
  if (is_multicast)
    entry_flags |= FIB_ENTRY_FLAG_MULTICAST;
  if (is_udp_encap)
    {
      path_flags |= FIB_ROUTE_PATH_UDP_ENCAP;
      path.frp_udp_encap_id = next_hop_id;
    }
  if (path.frp_sw_if_index == ~0 && ip46_address_is_zero (&path.frp_addr)
      && path.frp_fib_index != ~0)
    {
      path_flags |= FIB_ROUTE_PATH_DEAG;
    }

  path.frp_flags = path_flags;

  if (is_multipath)
    {
      stats_dslock_with_hint (1 /* release hint */ , 10 /* tag */ );


      vec_add1 (paths, path);

      if (is_add)
	fib_table_entry_path_add2 (fib_index,
				   prefix,
				   FIB_SOURCE_API, entry_flags, paths);
      else
	fib_table_entry_path_remove2 (fib_index,
				      prefix, FIB_SOURCE_API, paths);

      vec_free (paths);
      stats_dsunlock ();
      return 0;
    }

  stats_dslock_with_hint (1 /* release hint */ , 2 /* tag */ );

  if (is_drop || is_local || is_classify || is_unreach || is_prohibit)
    {
      /*
       * special route types that link directly to the adj
       */
      if (is_add)
	{
	  dpo_id_t dpo = DPO_INVALID;
	  dpo_proto_t dproto;

	  dproto = fib_proto_to_dpo (prefix->fp_proto);

	  if (is_drop)
	    ip_null_dpo_add_and_lock (dproto, IP_NULL_ACTION_NONE, &dpo);
	  else if (is_local)
	    receive_dpo_add_or_lock (dproto, ~0, NULL, &dpo);
	  else if (is_unreach)
	    ip_null_dpo_add_and_lock (dproto,
				      IP_NULL_ACTION_SEND_ICMP_UNREACH, &dpo);
	  else if (is_prohibit)
	    ip_null_dpo_add_and_lock (dproto,
				      IP_NULL_ACTION_SEND_ICMP_PROHIBIT,
				      &dpo);
	  else if (is_classify)
	    {
	      if (pool_is_free_index (cm->tables,
				      ntohl (classify_table_index)))
		{
		  stats_dsunlock ();
		  return VNET_API_ERROR_NO_SUCH_TABLE;
		}

	      dpo_set (&dpo, DPO_CLASSIFY, dproto,
		       classify_dpo_create (dproto,
					    ntohl (classify_table_index)));
	    }
	  else
	    {
	      stats_dsunlock ();
	      return VNET_API_ERROR_NO_SUCH_TABLE;
	    }

	  fib_table_entry_special_dpo_update (fib_index,
					      prefix,
					      FIB_SOURCE_API,
					      FIB_ENTRY_FLAG_EXCLUSIVE, &dpo);
	  dpo_reset (&dpo);
	}
      else
	{
	  fib_table_entry_special_remove (fib_index, prefix, FIB_SOURCE_API);
	}
    }
  else
    {
      if (is_add)
	{
	  vec_add1 (paths, path);
	  fib_table_entry_update (fib_index,
				  prefix, FIB_SOURCE_API, entry_flags, paths);
	  vec_free (paths);
	}
      else
	{
	  fib_table_entry_delete (fib_index, prefix, FIB_SOURCE_API);
	}
    }

  stats_dsunlock ();
  return (0);
}

int
add_del_route_check (fib_protocol_t table_proto,
		     u32 table_id,
		     u32 next_hop_sw_if_index,
		     dpo_proto_t next_hop_table_proto,
		     u32 next_hop_table_id,
		     u8 is_rpf_id, u32 * fib_index, u32 * next_hop_fib_index)
{
  vnet_main_t *vnm = vnet_get_main ();

  *fib_index = fib_table_find (table_proto, ntohl (table_id));
  if (~0 == *fib_index)
    {
      /* No such VRF, and we weren't asked to create one */
      return VNET_API_ERROR_NO_SUCH_FIB;
    }

  if (!is_rpf_id && ~0 != ntohl (next_hop_sw_if_index))
    {
      if (pool_is_free_index (vnm->interface_main.sw_interfaces,
			      ntohl (next_hop_sw_if_index)))
	{
	  return VNET_API_ERROR_NO_MATCHING_INTERFACE;
	}
    }
  else
    {
      fib_protocol_t fib_nh_proto;

      if (next_hop_table_proto > DPO_PROTO_MPLS)
	return (0);

      fib_nh_proto = dpo_proto_to_fib (next_hop_table_proto);

      if (is_rpf_id)
	*next_hop_fib_index = mfib_table_find (fib_nh_proto,
					       ntohl (next_hop_table_id));
      else
	*next_hop_fib_index = fib_table_find (fib_nh_proto,
					      ntohl (next_hop_table_id));

      if (~0 == *next_hop_fib_index)
	{
	  /* No such VRF, and we weren't asked to create one */
	  return VNET_API_ERROR_NO_SUCH_FIB;
	}
    }

  return (0);
}

static int
ip4_add_del_route_t_handler (vl_api_ip_add_del_route_t * mp)
{
  u32 fib_index, next_hop_fib_index;
  mpls_label_t *label_stack = NULL;
  int rv, ii, n_labels;;

  rv = add_del_route_check (FIB_PROTOCOL_IP4,
			    mp->table_id,
			    mp->next_hop_sw_if_index,
			    DPO_PROTO_IP4,
			    mp->next_hop_table_id,
			    0, &fib_index, &next_hop_fib_index);

  if (0 != rv)
    return (rv);

  fib_prefix_t pfx = {
    .fp_len = mp->dst_address_length,
    .fp_proto = FIB_PROTOCOL_IP4,
  };
  clib_memcpy (&pfx.fp_addr.ip4, mp->dst_address, sizeof (pfx.fp_addr.ip4));

  ip46_address_t nh;
  memset (&nh, 0, sizeof (nh));
  memcpy (&nh.ip4, mp->next_hop_address, sizeof (nh.ip4));

  n_labels = mp->next_hop_n_out_labels;
  if (n_labels == 0)
    ;
  else if (1 == n_labels)
    vec_add1 (label_stack, ntohl (mp->next_hop_out_label_stack[0]));
  else
    {
      vec_validate (label_stack, n_labels - 1);
      for (ii = 0; ii < n_labels; ii++)
	label_stack[ii] = ntohl (mp->next_hop_out_label_stack[ii]);
    }

  return (add_del_route_t_handler (mp->is_multipath,
				   mp->is_add,
				   mp->is_drop,
				   mp->is_unreach,
				   mp->is_prohibit,
				   mp->is_local, 0,
				   mp->is_classify,<style>
@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exception */
.highlight .nf { color: #a6e22e } /* Name.Function */
.highlight .nl { color: #f8f8f2 } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #a6e22e } /* Name.Other */
.highlight .py { color: #f8f8f2 } /* Name.Property */
.highlight .nt { color: #f92672 } /* Name.Tag */
.highlight .nv { color: #f8f8f2 } /* Name.Variable */
.highlight .ow { color: #f92672 } /* Operator.Word */
.highlight .w { color: #f8f8f2 } /* Text.Whitespace */
.highlight .mb { color: #ae81ff } /* Literal.Number.Bin */
.highlight .mf { color: #ae81ff } /* Literal.Number.Float */
.highlight .mh { color: #ae81ff } /* Literal.Number.Hex */
.highlight .mi { color: #ae81ff } /* Literal.Number.Integer */
.highlight .mo { color: #ae81ff } /* Literal.Number.Oct */
.highlight .sa { color: #e6db74 } /* Literal.String.Affix */
.highlight .sb { color: #e6db74 } /* Literal.String.Backtick */
.highlight .sc { color: #e6db74 } /* Literal.String.Char */
.highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */
.highlight .sd { color: #e6db74 } /* Literal.String.Doc */
.highlight .s2 { color: #e6db74 } /* Literal.String.Double */
.highlight .se { color: #ae81ff } /* Literal.String.Escape */
.highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */
.highlight .si { color: #e6db74 } /* Literal.String.Interpol */
.highlight .sx { color: #e6db74 } /* Literal.String.Other */
.highlight .sr { color: #e6db74 } /* Literal.String.Regex */
.highlight .s1 { color: #e6db74 } /* Literal.String.Single */
.highlight .ss { color: #e6db74 } /* Literal.String.Symbol */
.highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #a6e22e } /* Name.Function.Magic */
.highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */
.highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */
.highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */
.highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */
.highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */
}
@media (prefers-color-scheme: light) {
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
}
</style><div class="highlight"><pre><span></span><span class="cm">/*</span>
<span class="cm"> * ip/ports.def: tcp/udp port definitions</span>
<span class="cm"> *</span>
<span class="cm"> * Eliot Dresselhaus</span>
<span class="cm"> * August, 2005</span>
<span class="cm"> *</span>
<span class="cm"> * Permission is hereby granted, free of charge, to any person obtaining</span>
<span class="cm"> * a copy of this software and associated documentation files (the</span>
<span class="cm"> * &quot;Software&quot;), to deal in the Software without restriction, including</span>
<span class="cm"> * without limitation the rights to use, copy, modify, merge, publish,</span>
<span class="cm"> * distribute, sublicense, and/or sell copies of the Software, and to</span>
<span class="cm"> * permit persons to whom the Software is furnished to do so, subject to</span>
<span class="cm"> * the following conditions:</span>
<span class="cm"> *</span>
<span class="cm"> * The above copyright notice and this permission notice shall be</span>
<span class="cm"> * included in all copies or substantial portions of the Software.</span>
<span class="cm"> *</span>
<span class="cm"> *  THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,</span>
<span class="cm"> *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span>
<span class="cm"> *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span>
<span class="cm"> *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE</span>
<span class="cm"> *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION</span>
<span class="cm"> *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION</span>
<span class="cm"> *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</span>
<span class="cm"> */</span>

<span class="cm">/*</span>
<span class="cm">PORT NUMBERS</span>

<span class="cm">(last updated 18 October 2005) </span>

<span class="cm">The port numbers are divided into three ranges: the Well Known Ports,</span>
<span class="cm">the Registered Ports, and the Dynamic and/or Private Ports.</span>

<span class="cm">The Well Known Ports are those from 0 through 1023.</span>

<span class="cm">The Registered Ports are those from 1024 through 49151</span>

<span class="cm">The Dynamic and/or Private Ports are those from 49152 through 65535</span>


<span class="cm">************************************************************************</span>
<span class="cm">* PLEASE NOTE THE FOLLOWING:                                           *</span>
<span class="cm">*                                                                      *</span>
<span class="cm">* 1. UNASSIGNED PORT NUMBERS SHOULD NOT BE USED.  THE IANA WILL ASSIGN *</span>
<span class="cm">* THE NUMBER FOR THE PORT AFTER YOUR APPLICATION HAS BEEN APPROVED.    *</span>
<span class="cm">*                                                                      *</span>
<span class="cm">* 2. ASSIGNMENT OF A PORT NUMBER DOES NOT IN ANY WAY IMPLY AN          *</span>
<span class="cm">* ENDORSEMENT OF AN APPLICATION OR PRODUCT, AND THE FACT THAT NETWORK  *</span>
<span class="cm">* TRAFFIC IS FLOWING TO OR FROM A REGISTERED PORT DOES NOT MEAN THAT   *</span>
<span class="cm">* IT IS &quot;GOOD&quot; TRAFFIC. FIREWALL AND SYSTEM ADMINISTRATORS SHOULD      *</span>
<span class="cm">* CHOOSE HOW TO CONFIGURE THEIR SYSTEMS BASED ON THEIR KNOWLEDGE OF    *</span>
<span class="cm">* THE TRAFFIC IN QUESTION, NOT WHETHER THERE IS A PORT NUMBER          *</span>
<span class="cm">* REGISTERED OR NOT.                                                   *</span>
<span class="cm">************************************************************************</span>


<span class="cm">WELL KNOWN PORT NUMBERS</span>

<span class="cm">The Well Known Ports are assigned by the IANA and on most systems can</span>
<span class="cm">only be used by system (or root) processes or by programs executed by</span>
<span class="cm">privileged users.</span>

<span class="cm">Ports are used in the TCP [RFC793] to name the ends of logical</span>
<span class="cm">connections which carry long term conversations.  For the purpose of</span>
<span class="cm">providing services to unknown callers, a service contact port is</span>
<span class="cm">defined.  This list specifies the port used by the server process as</span>
<span class="cm">its contact port.  The contact port is sometimes called the</span>
<span class="cm">&quot;well-known port&quot;.</span>

<span class="cm">To the extent possible, these same port assignments are used with the</span>
<span class="cm">UDP [RFC768].</span>

<span class="cm">The range for assigned ports managed by the IANA is 0-1023.</span>
<span class="cm">*/</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">TCPMUX</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">COMPRESS_NET_MANAGEMENT</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">COMPRESS_NET</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">RJE</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">ECHO</span><span class="p">,</span> <span class="mi">7</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">DISCARD</span><span class="p">,</span> <span class="mi">9</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SYSTAT</span><span class="p">,</span> <span class="mi">11</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">DAYTIME</span><span class="p">,</span> <span class="mi">13</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">QOTD</span><span class="p">,</span> <span class="mi">17</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">MSP</span><span class="p">,</span> <span class="mi">18</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">CHARGEN</span><span class="p">,</span> <span class="mi">19</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">FTP_DATA</span><span class="p">,</span> <span class="mi">20</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">FTP</span><span class="p">,</span> <span class="mi">21</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SSH</span><span class="p">,</span> <span class="mi">22</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">TELNET</span><span class="p">,</span> <span class="mi">23</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SMTP</span><span class="p">,</span> <span class="mi">25</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NSW_FE</span><span class="p">,</span> <span class="mi">27</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">MSG_ICP</span><span class="p">,</span> <span class="mi">29</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">MSG_AUTH</span><span class="p">,</span> <span class="mi">31</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">DSP</span><span class="p">,</span> <span class="mi">33</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">TIME</span><span class="p">,</span> <span class="mi">37</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">RAP</span><span class="p">,</span> <span class="mi">38</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">RLP</span><span class="p">,</span> <span class="mi">39</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">GRAPHICS</span><span class="p">,</span> <span class="mi">41</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NAME</span><span class="p">,</span> <span class="mi">42</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NAMESERVER</span><span class="p">,</span> <span class="mi">42</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NICNAME</span><span class="p">,</span> <span class="mi">43</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">MPM_FLAGS</span><span class="p">,</span> <span class="mi">44</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">MPM</span><span class="p">,</span> <span class="mi">45</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">MPM_SND</span><span class="p">,</span> <span class="mi">46</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NI_FTP</span><span class="p">,</span> <span class="mi">47</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">AUDITD</span><span class="p">,</span> <span class="mi">48</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">TACACS</span><span class="p">,</span> <span class="mi">49</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">RE_MAIL_CK</span><span class="p">,</span> <span class="mi">50</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">LA_MAINT</span><span class="p">,</span> <span class="mi">51</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">XNS_TIME</span><span class="p">,</span> <span class="mi">52</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">DNS</span><span class="p">,</span> <span class="mi">53</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">XNS_CH</span><span class="p">,</span> <span class="mi">54</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">ISI_GL</span><span class="p">,</span> <span class="mi">55</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">XNS_AUTH</span><span class="p">,</span> <span class="mi">56</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">XNS_MAIL</span><span class="p">,</span> <span class="mi">58</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NI_MAIL</span><span class="p">,</span> <span class="mi">61</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">ACAS</span><span class="p">,</span> <span class="mi">62</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">WHOIS_PLUS_PLUS</span><span class="p">,</span> <span class="mi">63</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">COVIA</span><span class="p">,</span> <span class="mi">64</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">TACACS_DS</span><span class="p">,</span> <span class="mi">65</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">ORACLE_SQL_NET</span><span class="p">,</span> <span class="mi">66</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">BOOTPS</span><span class="p">,</span> <span class="mi">67</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">BOOTPC</span><span class="p">,</span> <span class="mi">68</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">TFTP</span><span class="p">,</span> <span class="mi">69</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">GOPHER</span><span class="p">,</span> <span class="mi">70</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NETRJS_1</span><span class="p">,</span> <span class="mi">71</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NETRJS_2</span><span class="p">,</span> <span class="mi">72</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NETRJS_3</span><span class="p">,</span> <span class="mi">73</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NETRJS_4</span><span class="p">,</span> <span class="mi">74</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">DEOS</span><span class="p">,</span> <span class="mi">76</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">VETTCP</span><span class="p">,</span> <span class="mi">78</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">FINGER</span><span class="p">,</span> <span class="mi">79</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">WWW</span><span class="p">,</span> <span class="mi">80</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">HOSTS2_NS</span><span class="p">,</span> <span class="mi">81</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">XFER</span><span class="p">,</span> <span class="mi">82</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">MIT_ML_DEV</span><span class="p">,</span> <span class="mi">83</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">CTF</span><span class="p">,</span> <span class="mi">84</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">MIT_ML_DEV1</span><span class="p">,</span> <span class="mi">85</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">MFCOBOL</span><span class="p">,</span> <span class="mi">86</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">KERBEROS</span><span class="p">,</span> <span class="mi">88</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SU_MIT_TG</span><span class="p">,</span> <span class="mi">89</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">DNSIX</span><span class="p">,</span> <span class="mi">90</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">MIT_DOV</span><span class="p">,</span> <span class="mi">91</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NPP</span><span class="p">,</span> <span class="mi">92</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">DCP</span><span class="p">,</span> <span class="mi">93</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">OBJCALL</span><span class="p">,</span> <span class="mi">94</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SUPDUP</span><span class="p">,</span> <span class="mi">95</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">DIXIE</span><span class="p">,</span> <span class="mi">96</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SWIFT_RVF</span><span class="p">,</span> <span class="mi">97</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">TACNEWS</span><span class="p">,</span> <span class="mi">98</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">METAGRAM</span><span class="p">,</span> <span class="mi">99</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NEWACCT</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">HOSTNAME</span><span class="p">,</span> <span class="mi">101</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">ISO_TSAP</span><span class="p">,</span> <span class="mi">102</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">GPPITNP</span><span class="p">,</span> <span class="mi">103</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">ACR_NEMA</span><span class="p">,</span> <span class="mi">104</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">CSO</span><span class="p">,</span> <span class="mi">105</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">CSNET_NS</span><span class="p">,</span> <span class="mi">105</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="mo">3C</span><span class="n">OM_TSMUX</span><span class="p">,</span> <span class="mi">106</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">RTELNET</span><span class="p">,</span> <span class="mi">107</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SNAGAS</span><span class="p">,</span> <span class="mi">108</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">POP2</span><span class="p">,</span> <span class="mi">109</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">POP3</span><span class="p">,</span> <span class="mi">110</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SUNRPC</span><span class="p">,</span> <span class="mi">111</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">MCIDAS</span><span class="p">,</span> <span class="mi">112</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">IDENT</span><span class="p">,</span> <span class="mi">113</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SFTP</span><span class="p">,</span> <span class="mi">115</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">ANSANOTIFY</span><span class="p">,</span> <span class="mi">116</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">UUCP_PATH</span><span class="p">,</span> <span class="mi">117</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SQLSERV</span><span class="p">,</span> <span class="mi">118</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NNTP</span><span class="p">,</span> <span class="mi">119</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">CFDPTKT</span><span class="p">,</span> <span class="mi">120</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">ERPC</span><span class="p">,</span> <span class="mi">121</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SMAKYNET</span><span class="p">,</span> <span class="mi">122</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NTP</span><span class="p">,</span> <span class="mi">123</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">ANSATRADER</span><span class="p">,</span> <span class="mi">124</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">LOCUS_MAP</span><span class="p">,</span> <span class="mi">125</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NXEDIT</span><span class="p">,</span> <span class="mi">126</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">LOCUS_CON</span><span class="p">,</span> <span class="mi">127</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">GSS_XLICEN</span><span class="p">,</span> <span class="mi">128</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">PWDGEN</span><span class="p">,</span> <span class="mi">129</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">CISCO_FNA</span><span class="p">,</span> <span class="mi">130</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">CISCO_TNA</span><span class="p">,</span> <span class="mi">131</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">CISCO_SYS</span><span class="p">,</span> <span class="mi">132</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">STATSRV</span><span class="p">,</span> <span class="mi">133</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">INGRES_NET</span><span class="p">,</span> <span class="mi">134</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">EPMAP</span><span class="p">,</span> <span class="mi">135</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">PROFILE</span><span class="p">,</span> <span class="mi">136</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NETBIOS_NS</span><span class="p">,</span> <span class="mi">137</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NETBIOS_DGM</span><span class="p">,</span> <span class="mi">138</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NETBIOS_SSN</span><span class="p">,</span> <span class="mi">139</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">EMFIS_DATA</span><span class="p">,</span> <span class="mi">140</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">EMFIS_CNTL</span><span class="p">,</span> <span class="mi">141</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">BL_IDM</span><span class="p">,</span> <span class="mi">142</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">IMAP</span><span class="p">,</span> <span class="mi">143</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">UMA</span><span class="p">,</span> <span class="mi">144</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">UAAC</span><span class="p">,</span> <span class="mi">145</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">ISO_TP0</span><span class="p">,</span> <span class="mi">146</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">ISO_IP</span><span class="p">,</span> <span class="mi">147</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">JARGON</span><span class="p">,</span> <span class="mi">148</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">AED_512</span><span class="p">,</span> <span class="mi">149</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SQL_NET</span><span class="p">,</span> <span class="mi">150</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">HEMS</span><span class="p">,</span> <span class="mi">151</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">BFTP</span><span class="p">,</span> <span class="mi">152</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SGMP</span><span class="p">,</span> <span class="mi">153</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NETSC_PROD</span><span class="p">,</span> <span class="mi">154</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NETSC_DEV</span><span class="p">,</span> <span class="mi">155</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SQLSRV</span><span class="p">,</span> <span class="mi">156</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">KNET_CMP</span><span class="p">,</span> <span class="mi">157</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">PCMAIL_SRV</span><span class="p">,</span> <span class="mi">158</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NSS_ROUTING</span><span class="p">,</span> <span class="mi">159</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SGMP_TRAPS</span><span class="p">,</span> <span class="mi">160</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SNMP</span><span class="p">,</span> <span class="mi">161</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SNMPTRAP</span><span class="p">,</span> <span class="mi">162</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">CMIP_MAN</span><span class="p">,</span> <span class="mi">163</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">CMIP_AGENT</span><span class="p">,</span> <span class="mi">164</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">XNS_COURIER</span><span class="p">,</span> <span class="mi">165</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">S_NET</span><span class="p">,</span> <span class="mi">166</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NAMP</span><span class="p">,</span> <span class="mi">167</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">RSVD</span><span class="p">,</span> <span class="mi">168</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SEND</span><span class="p">,</span> <span class="mi">169</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">PRINT_SRV</span><span class="p">,</span> <span class="mi">170</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">MULTIPLEX</span><span class="p">,</span> <span class="mi">171</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">CL1</span><span class="p">,</span> <span class="mi">172</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">XYPLEX_MUX</span><span class="p">,</span> <span class="mi">173</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">MAILQ</span><span class="p">,</span> <span class="mi">174</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">VMNET</span><span class="p">,</span> <span class="mi">175</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">GENRAD_MUX</span><span class="p">,</span> <span class="mi">176</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">XDMCP</span><span class="p">,</span> <span class="mi">177</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">NEXTSTEP</span><span class="p">,</span> <span class="mi">178</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">BGP</span><span class="p">,</span> <span class="mi">179</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">RIS</span><span class="p">,</span> <span class="mi">180</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">UNIFY</span><span class="p">,</span> <span class="mi">181</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">AUDIT</span><span class="p">,</span> <span class="mi">182</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">OCBINDER</span><span class="p">,</span> <span class="mi">183</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">OCSERVER</span><span class="p">,</span> <span class="mi">184</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">REMOTE_KIS</span><span class="p">,</span> <span class="mi">185</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">KIS</span><span class="p">,</span> <span class="mi">186</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">ACI</span><span class="p">,</span> <span class="mi">187</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">MUMPS</span><span class="p">,</span> <span class="mi">188</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">QFT</span><span class="p">,</span> <span class="mi">189</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">GACP</span><span class="p">,</span> <span class="mi">190</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">PROSPERO</span><span class="p">,</span> <span class="mi">191</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">OSU_NMS</span><span class="p">,</span> <span class="mi">192</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SRMP</span><span class="p">,</span> <span class="mi">193</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">IRC</span><span class="p">,</span> <span class="mi">194</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">DN6_NLM_AUD</span><span class="p">,</span> <span class="mi">195</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">DN6_SMM_RED</span><span class="p">,</span> <span class="mi">196</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">DLS</span><span class="p">,</span> <span class="mi">197</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">DLS_MON</span><span class="p">,</span> <span class="mi">198</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SMUX</span><span class="p">,</span> <span class="mi">199</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SRC</span><span class="p">,</span> <span class="mi">200</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">AT_RTMP</span><span class="p">,</span> <span class="mi">201</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">AT_NBP</span><span class="p">,</span> <span class="mi">202</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">AT_3</span><span class="p">,</span> <span class="mi">203</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">AT_ECHO</span><span class="p">,</span> <span class="mi">204</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">AT_5</span><span class="p">,</span> <span class="mi">205</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">AT_ZIS</span><span class="p">,</span> <span class="mi">206</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">AT_7</span><span class="p">,</span> <span class="mi">207</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">AT_8</span><span class="p">,</span> <span class="mi">208</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">QMTP</span><span class="p">,</span> <span class="mi">209</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">Z39_50</span><span class="p">,</span> <span class="mi">210</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">TI914CG</span><span class="p">,</span> <span class="mi">211</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">ANET</span><span class="p">,</span> <span class="mi">212</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">IPX</span><span class="p">,</span> <span class="mi">213</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">VMPWSCS</span><span class="p">,</span> <span class="mi">214</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">SOFTPC</span><span class="p">,</span> <span class="mi">215</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">CAILIC</span><span class="p">,</span> <span class="mi">216</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">DBASE</span><span class="p">,</span> <span class="mi">217</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">MPP</span><span class="p">,</span> <span class="mi">218</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">UARPS</span><span class="p">,</span> <span class="mi">219</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">IMAP3</span><span class="p">,</span> <span class="mi">220</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">FLN_SPX</span><span class="p">,</span> <span class="mi">221</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">(</span><span class="n">RSH_SPX</span><span class="p">,</span> <span class="mi">222</span><span class="p">)</span>
<span class="n">ip_port</span> <span class="p">