Browse Source

Parsing fixes.

Everton Marques 5 years ago
parent
commit
d459586904
3 changed files with 36 additions and 11 deletions
  1. 14 6
      pimd/pim_igmp.c
  2. 15 0
      pimd/pim_join.c
  3. 7 5
      pimd/pim_tlv.c

+ 14 - 6
pimd/pim_igmp.c

@@ -288,7 +288,8 @@ static int recv_igmp_query(struct igmp_sock *igmp, int query_version,
   uint16_t              checksum;
   int                   i;
 
-  group_addr = *(struct in_addr *)(igmp_msg + 4);
+  //group_addr = *(struct in_addr *)(igmp_msg + 4);
+  memcpy(&group_addr, igmp_msg + 4, sizeof(struct in_addr));
 
   ifp = igmp->interface;
   pim_ifp = ifp->info;
@@ -421,8 +422,12 @@ static int recv_igmp_query(struct igmp_sock *igmp, int query_version,
 	  /* Scan sources in query and lower their timers to LMQT */
 	  struct in_addr *sources = (struct in_addr *)(igmp_msg + IGMP_V3_SOURCES_OFFSET);
 	  for (i = 0; i < recv_num_sources; ++i) {
-	    struct in_addr src_addr = sources[i];
-	    struct igmp_source *src = igmp_find_source_by_addr(group, src_addr);
+	    //struct in_addr src_addr = sources[i];
+	    //struct igmp_source *src = igmp_find_source_by_addr(group, src_addr);
+	    struct in_addr src_addr;
+	    struct igmp_source *src;
+            memcpy(&src_addr, sources + i, sizeof(struct in_addr));
+	    src = igmp_find_source_by_addr(group, src_addr);
 	    if (src) {
 	      igmp_source_timer_lower_to_lmqt(src);
 	    }
@@ -506,7 +511,8 @@ static int igmp_v3_report(struct igmp_sock *igmp,
     rec_auxdatalen  = group_record[IGMP_V3_GROUP_RECORD_AUXDATALEN_OFFSET];
     rec_num_sources = ntohs(* (uint16_t *) (group_record + IGMP_V3_GROUP_RECORD_NUMSOURCES_OFFSET));
 
-    rec_group = *(struct in_addr *)(group_record + IGMP_V3_GROUP_RECORD_GROUP_OFFSET);
+    //rec_group = *(struct in_addr *)(group_record + IGMP_V3_GROUP_RECORD_GROUP_OFFSET);
+    memcpy(&rec_group, group_record + IGMP_V3_GROUP_RECORD_GROUP_OFFSET, sizeof(struct in_addr));
 
     if (PIM_DEBUG_IGMP_PACKETS) {
       zlog_debug("Recv IGMP report v3 from %s on %s: record=%d type=%d auxdatalen=%d sources=%d group=%s",
@@ -599,7 +605,8 @@ static int igmp_v2_report(struct igmp_sock *igmp,
 	      __FILE__, __PRETTY_FUNCTION__);
   }
 
-  group_addr = *(struct in_addr *)(igmp_msg + 4);
+  //group_addr = *(struct in_addr *)(igmp_msg + 4);
+  memcpy(&group_addr, igmp_msg + 4, sizeof(struct in_addr));
 
   /* non-existant group is created as INCLUDE {empty} */
   group = igmp_add_group_by_addr(igmp, group_addr, ifp->name);
@@ -655,7 +662,8 @@ static int igmp_v1_report(struct igmp_sock *igmp,
 	      __FILE__, __PRETTY_FUNCTION__);
   }
 
-  group_addr = *(struct in_addr *)(igmp_msg + 4);
+  //group_addr = *(struct in_addr *)(igmp_msg + 4);
+  memcpy(&group_addr, igmp_msg + 4, sizeof(struct in_addr));
 
   /* non-existant group is created as INCLUDE {empty} */
   group = igmp_add_group_by_addr(igmp, group_addr, ifp->name);

+ 15 - 0
pimd/pim_join.c

@@ -129,6 +129,11 @@ int pim_joinprune_recv(struct interface *ifp,
   addr_offset = pim_parse_addr_ucast(ifp->name, src_addr,
 				     &msg_upstream_addr,
 				     buf, pastend - buf);
+#if 0
+  zlog_warn("%s: pim_parse_addr_ucast addr_offset=%d",
+            __PRETTY_FUNCTION__,
+            addr_offset);
+#endif
   if (addr_offset < 1) {
     char src_str[100];
     pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));
@@ -194,6 +199,11 @@ int pim_joinprune_recv(struct interface *ifp,
     addr_offset = pim_parse_addr_group(ifp->name, src_addr,
 				       &msg_group_addr,
 				       buf, pastend - buf);
+#if 0
+    zlog_warn("%s: pim_parse_addr_group addr_offset=%d",
+              __PRETTY_FUNCTION__,
+              addr_offset);
+#endif
     if (addr_offset < 1) {
       return -5;
     }
@@ -236,6 +246,11 @@ int pim_joinprune_recv(struct interface *ifp,
 					  &msg_source_addr,
 					  &msg_source_flags,
 					  buf, pastend - buf);
+#if 0
+      zlog_warn("%s: pim_parse_addr_source addr_offset=%d",
+                __PRETTY_FUNCTION__,
+                addr_offset);
+#endif
       if (addr_offset < 1) {
 	return -7;
       }

+ 7 - 5
pimd/pim_tlv.c

@@ -450,7 +450,7 @@ int pim_parse_addr_group(const char *ifname, struct in_addr src_addr,
 
   family = *addr++;
   type = *addr++;
-  ++addr;
+  //++addr;
   ++addr; /* skip b_reserved_z fields */
   mask_len = *addr++;
 
@@ -533,9 +533,10 @@ int pim_parse_addr_source(const char *ifname,
     if (type) {
       char src_str[100];
       pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));
-      zlog_warn("%s: unknown source address encoding type=%d from %s on %s",
+      zlog_warn("%s: unknown source address encoding type=%d from %s on %s: %02x%02x%02x%02x%02x%02x%02x%02x",
 		__PRETTY_FUNCTION__,
-		type, src_str, ifname);
+		type, src_str, ifname,
+		buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);
       return -2;
     }
 
@@ -578,9 +579,10 @@ int pim_parse_addr_source(const char *ifname,
     {
       char src_str[100];
       pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));
-      zlog_warn("%s: unknown source address encoding family=%d from %s on %s",
+      zlog_warn("%s: unknown source address encoding family=%d from %s on %s: %02x%02x%02x%02x%02x%02x%02x%02x",
 		__PRETTY_FUNCTION__,
-		family, src_str, ifname);
+		family, src_str, ifname,
+		buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);
       return -5;
     }
   }