Consolidate the [un]format_mac_address implementations
[vpp.git] / src / vnet / lisp-cp / lisp_types.h
index a65a479..ff7880b 100644 (file)
@@ -90,6 +90,8 @@ typedef enum
   GID_ADDR_MAC,
   GID_ADDR_SRC_DST,
   GID_ADDR_NSH,
+  GID_ADDR_ARP,
+  GID_ADDR_NDP,
   GID_ADDR_NO_ADDRESS,
   GID_ADDR_TYPES
 } gid_address_type_t;
@@ -101,6 +103,7 @@ typedef enum
   LCAF_AFI_LIST_TYPE,
   LCAF_INSTANCE_ID,
   LCAF_SOURCE_DEST = 12,
+  LCAF_NSH = 17,
   LCAF_TYPES
 } lcaf_type_t;
 
@@ -165,12 +168,28 @@ typedef struct
   u8 si;
 } nsh_t;
 
+#define nsh_spi(_a) (_a)->spi
+#define nsh_si(_a) (_a)->si
+
+typedef struct
+{
+  ip_address_t addr;
+  u32 bd;
+} lcaf_arp_ndp_t;
+
+#define lcaf_arp_ndp_ip(_a) (_a)->addr
+#define lcaf_arp_ndp_ip_ver(_a) ip_addr_version(&lcaf_arp_ndp_ip(_a))
+#define lcaf_arp_ndp_ip4(_a) ip_addr_v4(&lcaf_arp_ndp_ip(_a))
+#define lcaf_arp_ndp_ip6(_a) ip_addr_v6(&lcaf_arp_ndp_ip(_a))
+#define lcaf_arp_ndp_bd(_a) (_a)->bd
+
 typedef struct
 {
   /* the union needs to be at the beginning! */
   union
   {
     source_dest_t sd;
+    lcaf_arp_ndp_t arp_ndp;
     vni_t uni;
   };
   u8 type;
@@ -189,6 +208,7 @@ typedef struct _gid_address_t
     lcaf_t lcaf;
     u8 mac[6];
     source_dest_t sd;
+    lcaf_arp_ndp_t arp_ndp;
     nsh_t nsh;
   };
   u8 type;
@@ -200,8 +220,6 @@ u8 *format_ip_address (u8 * s, va_list * args);
 uword unformat_ip_address (unformat_input_t * input, va_list * args);
 u8 *format_ip_prefix (u8 * s, va_list * args);
 uword unformat_ip_prefix (unformat_input_t * input, va_list * args);
-u8 *format_mac_address (u8 * s, va_list * args);
-uword unformat_mac_address (unformat_input_t * input, va_list * args);
 
 u16 ip4_address_size_to_put ();
 u16 ip6_address_size_to_put ();
@@ -246,6 +264,8 @@ void gid_address_ip_set (gid_address_t * dst, void *src, u8 version);
 #define gid_address_lcaf(_a) (_a)->lcaf
 #define gid_address_mac(_a) (_a)->mac
 #define gid_address_nsh(_a) (_a)->nsh
+#define gid_address_nsh_spi(_a) nsh_spi(&gid_address_nsh(_a))
+#define gid_address_nsh_si(_a) nsh_si(&gid_address_nsh(_a))
 #define gid_address_vni(_a) (_a)->vni
 #define gid_address_vni_mask(_a) (_a)->vni_mask
 #define gid_address_sd_dst_ippref(_a) sd_dst_ippref(&(_a)->sd)
@@ -257,9 +277,17 @@ void gid_address_ip_set (gid_address_t * dst, void *src, u8 version);
 #define gid_address_sd_dst(_a) sd_dst(&gid_address_sd(_a))
 #define gid_address_sd_src_type(_a) sd_src_type(&gid_address_sd(_a))
 #define gid_address_sd_dst_type(_a) sd_dst_type(&gid_address_sd(_a))
+#define gid_address_arp_ndp(_a) (_a)->arp_ndp
+#define gid_address_arp_ndp_bd(_a) lcaf_arp_ndp_bd(&gid_address_arp_ndp(_a))
+#define gid_address_arp_ndp_ip(_a) lcaf_arp_ndp_ip(&gid_address_arp_ndp(_a))
+#define gid_address_arp_ip4(_a) lcaf_arp_ndp_ip4(&gid_address_arp_ndp(_a))
+#define gid_address_ndp_ip6(_a) lcaf_arp_ndp_ip6(&gid_address_arp_ndp(_a))
+#define gid_address_ndp_bd gid_address_arp_ndp_bd
+#define gid_address_arp_bd gid_address_arp_ndp_bd
 
 /* 'sub'address functions */
 #define foreach_gid_address_type_fcns  \
+  _(no_addr)                      \
   _(ip_prefix)                    \
   _(lcaf)                         \
   _(mac)                          \
@@ -335,12 +363,15 @@ typedef struct
   /* valid only for remote mappings */
   u8 is_static:1;
   u8 pitr_set:1;
-  u8 rsvd:4;
-
+  u8 nsh_set:1;
+  u8 almost_expired:1;
+  u8 delete_after_expiration:1;
+  u8 rsvd:1;
 
   u8 *key;
   lisp_key_type_t key_id;
   u8 timer_set;
+  counter_t packets;
 } mapping_t;
 
 uword