X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=vnet%2Fvnet%2Flisp-cp%2Flisp_cp_messages.h;h=278f60e17261cd492641964cda77baacf097ebee;hb=397fd7d39f023887e428de37a1929c366a99b8d5;hp=742e7fa0a09e7b731814ab5a96661ac081d5b2a8;hpb=beceab90520d38aa0b90427d0c829d67ca843161;p=vpp.git diff --git a/vnet/vnet/lisp-cp/lisp_cp_messages.h b/vnet/vnet/lisp-cp/lisp_cp_messages.h index 742e7fa0a09..278f60e1726 100644 --- a/vnet/vnet/lisp-cp/lisp_cp_messages.h +++ b/vnet/vnet/lisp-cp/lisp_cp_messages.h @@ -19,7 +19,7 @@ #include #define MAX_IP_PKT_LEN 4096 -#define MAX_IP_HDR_LEN 40 /* without options or IPv6 hdr extensions */ +#define MAX_IP_HDR_LEN 40 /* without options or IPv6 hdr extensions */ #define UDP_HDR_LEN 8 #define LISP_DATA_HDR_LEN 8 #define LISP_ECM_HDR_LEN 4 @@ -41,12 +41,13 @@ */ -typedef struct _eid_prefix_record_hdr { - u8 reserved; - u8 eid_prefix_length; +typedef struct _eid_prefix_record_hdr +{ + u8 reserved; + u8 eid_prefix_length; } __attribute__ ((__packed__)) eid_record_hdr_t; -void eid_rec_hdr_init(eid_record_hdr_t *ptr); +void eid_rec_hdr_init (eid_record_hdr_t * ptr); #define EID_REC_CAST(h_) ((eid_record_hdr_t *)(h_)) #define EID_REC_MLEN(h_) EID_REC_CAST((h_))->eid_prefix_length @@ -119,7 +120,7 @@ typedef struct u8 reserved2[3]; } ecm_hdr_t; -char *ecm_hdr_to_char(ecm_hdr_t *h); +char *ecm_hdr_to_char (ecm_hdr_t * h); #define ECM_TYPE(h_) ((ecm_hdr_t *)(h_))->type @@ -166,40 +167,40 @@ char *ecm_hdr_to_char(ecm_hdr_t *h); typedef struct { #if CLIB_ARCH_IS_LITTLE_ENDIAN - u8 solicit_map_request:1; - u8 rloc_probe:1; - u8 map_data_present:1; - u8 authoritative:1; - u8 type:4; + u8 solicit_map_request:1; + u8 rloc_probe:1; + u8 map_data_present:1; + u8 authoritative:1; + u8 type:4; #else - u8 type:4; - u8 authoritative:1; - u8 map_data_present:1; - u8 rloc_probe:1; - u8 solicit_map_request:1; + u8 type:4; + u8 authoritative:1; + u8 map_data_present:1; + u8 rloc_probe:1; + u8 solicit_map_request:1; #endif #if CLIB_ARCH_IS_LITTLE_ENDIAN - u8 reserved1:6; - u8 smr_invoked:1; - u8 pitr:1; + u8 reserved1:6; + u8 smr_invoked:1; + u8 pitr:1; #else - u8 pitr:1; - u8 smr_invoked:1; - u8 reserved1:6; + u8 pitr:1; + u8 smr_invoked:1; + u8 reserved1:6; #endif #if CLIB_ARCH_IS_LITTLE_ENDIAN - u8 additional_itr_rloc_count:5; - u8 reserved2:3; + u8 additional_itr_rloc_count:5; + u8 reserved2:3; #else - u8 reserved2:3; - u8 additional_itr_rloc_count:5; + u8 reserved2:3; + u8 additional_itr_rloc_count:5; #endif - u8 record_count; - u64 nonce; -}__attribute__ ((__packed__)) map_request_hdr_t; + u8 record_count; + u64 nonce; +} __attribute__ ((__packed__)) map_request_hdr_t; -void map_request_hdr_init(void *ptr); -char *map_request_hdr_to_char(map_request_hdr_t *h); +void map_request_hdr_init (void *ptr); +char *map_request_hdr_to_char (map_request_hdr_t * h); #define MREQ_TYPE(h_) (h_)->type #define MREQ_HDR_CAST(h_) ((map_request_hdr_t *)(h_)) @@ -214,12 +215,6 @@ char *map_request_hdr_to_char(map_request_hdr_t *h); * MAP-REPLY MESSAGE */ - /* Map Reply action codes */ - #define LISP_ACTION_NO_ACTION 0 - #define LISP_ACTION_FORWARD 1 - #define LISP_ACTION_DROP 2 - #define LISP_ACTION_SEND_MAP_REQUEST 3 - /* * Map-Reply Message Format * @@ -256,27 +251,28 @@ char *map_request_hdr_to_char(map_request_hdr_t *h); typedef struct { #if CLIB_ARCH_IS_LITTLE_ENDIAN - u8 reserved1:1; - u8 security:1; - u8 echo_nonce:1; - u8 rloc_probe:1; - u8 type:4; + u8 reserved1:1; + u8 security:1; + u8 echo_nonce:1; + u8 rloc_probe:1; + u8 type:4; #else - u8 type:4; - u8 rloc_probe:1; - u8 echo_nonce:1; - u8 security:1; - u8 reserved1:1; + u8 type:4; + u8 rloc_probe:1; + u8 echo_nonce:1; + u8 security:1; + u8 reserved1:1; #endif - u8 reserved2; - u8 reserved3; - u8 record_count; - u64 nonce; + u8 reserved2; + u8 reserved3; + u8 record_count; + u64 nonce; } __attribute__ ((__packed__)) map_reply_hdr_t; - void map_reply_hdr_init(void *ptr); - char *map_reply_hdr_to_char(map_reply_hdr_t *h); +void map_reply_hdr_init (void *ptr); +char *map_reply_hdr_to_char (map_reply_hdr_t * h); +#define MREP_TYPE(h_) MREP_HDR_CAST(h_)->type #define MREP_HDR_CAST(h_) ((map_reply_hdr_t *)(h_)) #define MREP_REC_COUNT(h_) MREP_HDR_CAST(h_)->record_count #define MREP_RLOC_PROBE(h_) MREP_HDR_CAST(h_)->rloc_probe @@ -284,9 +280,9 @@ typedef struct always_inline lisp_msg_type_e -lisp_msg_type (void * b) +lisp_msg_type (void *b) { - ecm_hdr_t * hdr = b; + ecm_hdr_t *hdr = b; if (!hdr) { return (NOT_LISP_MSG); @@ -295,15 +291,15 @@ lisp_msg_type (void * b) } always_inline void -increment_record_count (void * b) +increment_record_count (void *b) { switch (lisp_msg_type (b)) { case LISP_MAP_REQUEST: - MREQ_REC_COUNT(b) += 1; + MREQ_REC_COUNT (b) += 1; break; case LISP_MAP_REPLY: - MREP_REC_COUNT(b) += 1; + MREP_REC_COUNT (b) += 1; break; default: return; @@ -325,22 +321,23 @@ increment_record_count (void * b) * Fixed portion of the mapping record locator. Variable length * locator address follows. */ -typedef struct _locator_hdr { - u8 priority; - u8 weight; - u8 mpriority; - u8 mweight; - u8 unused1; +typedef struct _locator_hdr +{ + u8 priority; + u8 weight; + u8 mpriority; + u8 mweight; + u8 unused1; #ifdef CLIB_ARCH_IS_LITTLE_ENDIAN - u8 reachable:1; - u8 probed:1; - u8 local:1; - u8 unused2:5; + u8 reachable:1; + u8 probed:1; + u8 local:1; + u8 unused2:5; #else - u8 unused2:5; - u8 local:1; - u8 probed:1; - u8 reachable:1; + u8 unused2:5; + u8 local:1; + u8 probed:1; + u8 reachable:1; #endif } __attribute__ ((__packed__)) locator_hdr_t; @@ -391,22 +388,22 @@ typedef struct _mapping_record_hdr_t u8 authoritative:1; u8 action:3; #else - u8 action :3; - u8 authoritative :1; - u8 reserved1 :4; + u8 action:3; + u8 authoritative:1; + u8 reserved1:4; #endif u8 reserved2; #ifdef CLIB_ARCH_IS_LITTLE_ENDIAN u8 version_hi:4; u8 reserved3:4; #else - u8 reserved3 :4; - u8 version_hi :4; + u8 reserved3:4; + u8 version_hi:4; #endif u8 version_low; -}__attribute__ ((__packed__)) mapping_record_hdr_t; +} __attribute__ ((__packed__)) mapping_record_hdr_t; -void mapping_record_init_hdr(mapping_record_hdr_t *h); +void mapping_record_init_hdr (mapping_record_hdr_t * h); #define MAP_REC_EID_PLEN(h) ((mapping_record_hdr_t *)(h))->eid_prefix_length #define MAP_REC_LOC_COUNT(h) ((mapping_record_hdr_t *)(h))->locator_count @@ -416,12 +413,12 @@ void mapping_record_init_hdr(mapping_record_hdr_t *h); #define MAP_REC_EID(h) (u8 *)(h)+sizeof(mapping_record_hdr_t) #define MAP_REC_VERSION(h) (h)->version_hi << 8 | (h)->version_low -typedef enum lisp_actions +typedef enum { - ACT_NO_ACTION = 0, - ACT_NATIVE_FWD, - ACT_SEND_MREQ, - ACT_DROP + LISP_NO_ACTION, + LISP_FORWARD_NATIVE, + LISP_SEND_MAP_REQUEST, + LISP_DROP } lisp_action_e; typedef enum lisp_authoritative @@ -457,4 +454,160 @@ typedef struct _lcaf_hdr_t #define LCAF_FLAGS(h) ((lcaf_hdr_t *)(h))->flags #define LCAF_PAYLOAD(h) (u8 *)(h)+sizeof(lcaf_hdr_t) +/* + * Source/Dest Key Canonical Address Format: + * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Reserved | Source-ML | Dest-ML | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +typedef struct _lcaf_src_dst_hdr_t +{ + u16 reserved; + u8 src_mask_len; + u8 dst_mask_len; +} __attribute__ ((__packed__)) lcaf_src_dst_hdr_t; + +#define LCAF_SD_SRC_ML(_h) (_h)->src_mask_len +#define LCAF_SD_DST_ML(_h) (_h)->dst_mask_len + +/* + * The Map-Register message format is: + * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * |Type=3 |P| Reserved |M| Record Count | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Nonce . . . | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | . . . Nonce | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Key ID | Authentication Data Length | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * ~ Authentication Data ~ + * +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | | Record TTL | + * | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * R | Locator Count | EID mask-len | ACT |A| Reserved | + * e +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * c | Rsvd | Map-Version Number | EID-Prefix-AFI | + * o +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * r | EID-Prefix | + * d +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | /| Priority | Weight | M Priority | M Weight | + * | L +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | o | Unused Flags |L|p|R| Loc-AFI | + * | c +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | \| Locator | + * +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +typedef struct +{ +#if CLIB_ARCH_IS_LITTLE_ENDIAN + u8 res1:3; + u8 proxy_map_reply:1; + u8 type:4; +#else + u8 type:4; + u8 proxy_map_reply:1; + u8 res1:3; +#endif + + u8 res2; + +#if CLIB_ARCH_IS_LITTLE_ENDIAN + u8 want_map_notify:1; + u8 res3:7; +#else + u8 res3:7; + u8 want_map_notify:1; +#endif + + u8 record_count; + u64 nonce; + u16 key_id; + u16 auth_data_len; + u8 data[0]; +} __attribute__ ((__packed__)) map_register_hdr_t; + +#define MREG_TYPE(h_) (h_)->type +#define MREG_HDR_CAST(h_) ((map_register_hdr_t *)(h_)) +#define MREG_PROXY_MR(h_) (MREG_HDR_CAST(h_))->proxy_map_reply +#define MREG_WANT_MAP_NOTIFY(h_) (MREG_HDR_CAST(h_))->want_map_notify +#define MREG_REC_COUNT(h_) (MREG_HDR_CAST(h_))->record_count +#define MREG_NONCE(h_) (MREG_HDR_CAST(h_))->nonce +#define MREG_KEY_ID(h_) (MREG_HDR_CAST(h_))->key_id +#define MREG_AUTH_DATA_LEN(h_) (MREG_HDR_CAST(h_))->auth_data_len +#define MREG_DATA(h_) (MREG_HDR_CAST(h_))->data + +/* + * The Map-Notify message format is: + * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * |Type=4 | Reserved | Record Count | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Nonce . . . | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | . . . Nonce | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Key ID | Authentication Data Length | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * ~ Authentication Data ~ + * +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | | Record TTL | + * | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * R | Locator Count | EID mask-len | ACT |A| Reserved | + * e +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * c | Rsvd | Map-Version Number | EID-Prefix-AFI | + * o +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * r | EID-Prefix | + * d +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | /| Priority | Weight | M Priority | M Weight | + * | L +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | o | Unused Flags |L|p|R| Loc-AFI | + * | c +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | \| Locator | + * +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +*/ + +typedef struct +{ +#if CLIB_ARCH_IS_LITTLE_ENDIAN + u8 res1:4; + u8 type:4; +#else + u8 type:4; + u8 res1:4; +#endif + + u16 res2; + + u8 record_count; + u64 nonce; + u16 key_id; + u16 auth_data_len; + u8 data[0]; +} __attribute__ ((__packed__)) map_notify_hdr_t; + +#define MNOTIFY_TYPE(h_) (h_)->type +#define MNOTIFY_HDR_CAST(h_) ((map_register_hdr_t *)(h_)) +#define MNOTIFY_REC_COUNT(h_) (MREG_HDR_CAST(h_))->record_count +#define MNOTIFY_NONCE(h_) (MREG_HDR_CAST(h_))->nonce +#define MNOTIFY_KEY_ID(h_) (MREG_HDR_CAST(h_))->key_id +#define MNOTIFY_AUTH_DATA_LEN(h_) (MREG_HDR_CAST(h_))->auth_data_len +#define MNOTIFY_DATA(h_) (MREG_HDR_CAST(h_))->data + #endif /* VNET_LISP_GPE_LISP_CP_MESSAGES_H_ */ + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */