Fix handling of lid-length TLV in DLEP session ACK
authorHenning Rogge <henning.rogge@fkie.fraunhofer.de>
Wed, 11 Apr 2018 11:14:02 +0000 (13:14 +0200)
committerHenning Rogge <henning.rogge@fkie.fraunhofer.de>
Wed, 11 Apr 2018 11:14:02 +0000 (13:14 +0200)
src-plugins/generic/dlep/dlep_reader.c
src-plugins/generic/dlep/dlep_session.h
src-plugins/generic/dlep/dlep_writer.c
src-plugins/generic/dlep/ext_lid/lid.c

index 3842ad4..91c8e8e 100644 (file)
@@ -180,7 +180,7 @@ dlep_reader_lid_length_tlv(uint16_t *length, struct dlep_session *session, struc
   const uint8_t *ptr;
   uint16_t tmp16;
   if (!value) {
-    value = dlep_session_get_tlv_value(session, DLEP_LID_TLV);
+    value = dlep_session_get_tlv_value(session, DLEP_LID_LENGTH_TLV);
     if (!value) {
       return -1;
     }
index 31263ad..8a3dcfd 100644 (file)
@@ -254,7 +254,7 @@ struct dlep_session_config {
   bool send_proxied;
 
   /*! length of LIDs used to communicate with router */
-  uint16_t lid_length;
+  int32_t lid_length;
 };
 
 /**
index aab5da3..bd6fb3a 100644 (file)
@@ -201,14 +201,6 @@ dlep_writer_add_mac_tlv(struct dlep_writer *writer, const struct oonf_layer2_nei
  */
 int
 dlep_writer_add_lid_tlv(struct dlep_writer *writer, const struct oonf_layer2_neigh_key *mac_lid) {
-  switch (netaddr_get_address_family(&mac_lid->addr)) {
-    case AF_MAC48:
-    case AF_EUI64:
-      break;
-    default:
-      return -1;
-  }
-
   dlep_writer_add_tlv(writer, DLEP_LID_TLV, mac_lid->link_id, mac_lid->link_id_length);
   return 0;
 }
index 9b628bc..6817d2d 100644 (file)
@@ -127,8 +127,8 @@ static struct dlep_extension_signal _signals[] = {
     .id = DLEP_SESSION_INITIALIZATION_ACK,
     .supported_tlvs = _session_initack_tlvs,
     .supported_tlv_count = ARRAYSIZE(_session_initack_tlvs),
-    .process_radio = _process_session_init_ack,
-    .add_router_tlvs = _write_session_init_ack,
+    .process_router = _process_session_init_ack,
+    .add_radio_tlvs = _write_session_init_ack,
   },
   {
     .id = DLEP_DESTINATION_UP,
@@ -191,6 +191,7 @@ static struct dlep_extension_signal _signals[] = {
 /* supported TLVs of this extension */
 static struct dlep_extension_tlv _tlvs[] = {
   { DLEP_LID_TLV, 1, OONF_LAYER2_MAX_LINK_ID },
+  { DLEP_LID_LENGTH_TLV, 2, 2 },
 };
 
 /* DLEP base extension, radio side */
@@ -263,6 +264,7 @@ _process_session_init_ack(struct dlep_extension *ext __attribute__((unused)), st
   uint16_t length;
 
   if (dlep_reader_lid_length_tlv(&length, session, NULL)) {
+    session->cfg.lid_length = DLEP_DEFAULT_LID_LENGTH;
     return DLEP_NEW_PARSER_OKAY;
   }
 
@@ -271,5 +273,7 @@ _process_session_init_ack(struct dlep_extension *ext __attribute__((unused)), st
         "Cannot handle link-id length this large");
     return DLEP_NEW_PARSER_TERMINDATED;
   }
+
+  session->cfg.lid_length = length;
   return DLEP_NEW_PARSER_OKAY;
 }