* Encoding and decoding for PCEP Object TLVs.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef __FreeBSD__
+#include <sys/endian.h>
+#else
+#include <endian.h>
+#endif /* __FreeBSD__ */
#include <stdlib.h>
#include <string.h>
[PCEP_OBJ_TLV_TYPE_OBJECTIVE_FUNCTION_LIST] = pcep_decode_tlv_of_list,
};
-static void initialize_tlv_coders()
+static void initialize_tlv_coders(void)
{
static bool initialized = false;
return NULL;
}
- tlv_decoder_funcptr tlv_decoder = tlv_decoders[tlv_hdr.type];
+ tlv_decoder_funcptr tlv_decoder = NULL;
+ if (tlv_hdr.type == PCEP_OBJ_TYPE_CISCO_BSID) {
+ pcep_log(LOG_INFO,
+ "%s: Cisco BSID TLV decoder found for TLV type [%d]",
+ __func__, tlv_hdr.type);
+ tlv_decoder = tlv_decoders[PCEP_OBJ_TLV_TYPE_ARBITRARY];
+ } else {
+ tlv_decoder = tlv_decoders[tlv_hdr.type];
+ }
if (tlv_decoder == NULL) {
pcep_log(LOG_INFO, "%s: No TLV decoder found for TLV type [%d]",
__func__, tlv_hdr.type);
uint16_t buf_index = normalize_pcep_tlv_length(
TLV_HEADER_LENGTH + LENGTH_1WORD + num_psts);
while ((tlv->header.encoded_tlv_length - buf_index) > TLV_HEADER_LENGTH
- && num_iterations++ > MAX_ITERATIONS) {
+ && num_iterations++ < MAX_ITERATIONS) {
struct pcep_object_tlv_header *sub_tlv =
pcep_decode_tlv(tlv_body_buf + buf_index);
if (sub_tlv == NULL) {
return (struct pcep_object_tlv_header *)ipv4;
} else {
ipv4->is_ipv4 = false;
- struct pcep_object_tlv_srpag_pol_id *ipv6 =
- (struct pcep_object_tlv_srpag_pol_id *)ipv4;
+ struct pcep_object_tlv_srpag_pol_id *ipv6 = ipv4;
ipv6->color = ntohl(uint32_ptr[0]);
decode_ipv6(&uint32_ptr[1], &ipv6->end_point.ipv6);
return (struct pcep_object_tlv_header *)ipv6;