]> git.proxmox.com Git - mirror_frr.git/blobdiff - eigrpd/eigrp_hello.c
zebra: Allow ns delete to happen after under/over flow checks
[mirror_frr.git] / eigrpd / eigrp_hello.c
index 49647c6b85bbff60e48d383e0cddab69a723bb04..413a35f2fa5285c4acbfc91ab768a9f0fa40e574 100644 (file)
@@ -54,6 +54,7 @@
 #include "eigrpd/eigrp_vty.h"
 #include "eigrpd/eigrp_dump.h"
 #include "eigrpd/eigrp_macros.h"
+#include "eigrpd/eigrp_errors.h"
 
 /* Packet Type String. */
 static const struct message eigrp_general_tlv_type_str[] = {
@@ -89,15 +90,15 @@ int eigrp_hello_timer(struct thread *thread)
 
        if (IS_DEBUG_EIGRP(0, TIMERS))
                zlog_debug("Start Hello Timer (%s) Expire [%u]", IF_NAME(ei),
-                          EIGRP_IF_PARAM(ei, v_hello));
+                          ei->params.v_hello);
 
        /* Sending hello packet. */
        eigrp_hello_send(ei, EIGRP_HELLO_NORMAL, NULL);
 
        /* Hello timer set. */
        ei->t_hello = NULL;
-       thread_add_timer(master, eigrp_hello_timer, ei,
-                        EIGRP_IF_PARAM(ei, v_hello), &ei->t_hello);
+       thread_add_timer(master, eigrp_hello_timer, ei, ei->params.v_hello,
+                        &ei->t_hello);
 
        return 0;
 }
@@ -108,7 +109,7 @@ int eigrp_hello_timer(struct thread *thread)
  * @param[in]          nbr     neighbor the ACK should be sent to
  * @param[in]          param   pointer packet TLV is stored to
  *
- * @return u_int16_t   number of bytes added to packet stream
+ * @return uint16_t    number of bytes added to packet stream
  *
  * @par
  * Encode Parameter TLV, used to convey metric weights and the hold time.
@@ -183,7 +184,7 @@ eigrp_hello_parameter_decode(struct eigrp_neighbor *nbr,
        return nbr;
 }
 
-static u_char
+static uint8_t
 eigrp_hello_authentication_decode(struct stream *s,
                                  struct eigrp_tlv_hdr_type *tlv_header,
                                  struct eigrp_neighbor *nbr)
@@ -268,15 +269,15 @@ static void eigrp_peer_termination_decode(struct eigrp_neighbor *nbr,
  * @param[in]          nbr_addr  pointer to neighbor address for Peer
  * Termination TLV
  *
- * @return u_int16_t    number of bytes added to packet stream
+ * @return uint16_t    number of bytes added to packet stream
  *
  * @par
  * Function used to encode Peer Termination TLV to Hello packet.
  */
-static u_int16_t eigrp_peer_termination_encode(struct stream *s,
-                                              struct in_addr *nbr_addr)
+static uint16_t eigrp_peer_termination_encode(struct stream *s,
+                                             struct in_addr *nbr_addr)
 {
-       u_int16_t length = EIGRP_TLV_PEER_TERMINATION_LEN;
+       uint16_t length = EIGRP_TLV_PEER_TERMINATION_LEN;
 
        /* fill in type and length */
        stream_putw(s, EIGRP_TLV_PEER_TERMINATION);
@@ -405,8 +406,8 @@ void eigrp_hello_receive(struct eigrp *eigrp, struct ip *iph,
                           inet_ntoa(nbr->src));
 }
 
-u_int32_t FRR_MAJOR;
-u_int32_t FRR_MINOR;
+uint32_t FRR_MAJOR;
+uint32_t FRR_MINOR;
 
 void eigrp_sw_version_initialize(void)
 {
@@ -417,9 +418,11 @@ void eigrp_sw_version_initialize(void)
        if (dash)
                dash[0] = '\0';
 
-       ret = sscanf(ver_string, "%d.%d", &FRR_MAJOR, &FRR_MINOR);
+       ret = sscanf(ver_string, "%" SCNu32 ".%" SCNu32, &FRR_MAJOR,
+                    &FRR_MINOR);
        if (ret != 2)
-               zlog_err("Did not Properly parse %s, please fix VERSION string",
+               flog_err(EC_EIGRP_PACKET,
+                        "Did not Properly parse %s, please fix VERSION string",
                         VERSION);
 }
 
@@ -428,22 +431,22 @@ void eigrp_sw_version_initialize(void)
  *
  * @param[in,out]      s       packet stream TLV is stored to
  *
- * @return u_int16_t   number of bytes added to packet stream
+ * @return uint16_t    number of bytes added to packet stream
  *
  * @par
  * Store the software version in the specified location.
  * This consists of two bytes of OS version, and two bytes of EIGRP
  * revision number.
  */
-static u_int16_t eigrp_sw_version_encode(struct stream *s)
+static uint16_t eigrp_sw_version_encode(struct stream *s)
 {
-       u_int16_t length = EIGRP_TLV_SW_VERSION_LEN;
+       uint16_t length = EIGRP_TLV_SW_VERSION_LEN;
 
        // setup the tlv fields
        stream_putw(s, EIGRP_TLV_SW_VERSION);
        stream_putw(s, length);
 
-       stream_putc(s, FRR_MAJOR);  //!< major os version
+       stream_putc(s, FRR_MAJOR); //!< major os version
        stream_putc(s, FRR_MINOR); //!< minor os version
 
        /* and the core eigrp version */
@@ -464,9 +467,9 @@ static u_int16_t eigrp_sw_version_encode(struct stream *s)
  * If doing mutli-topology, then store the supported TID list.
  * This is currently a place holder function
  */
-static u_int16_t eigrp_tidlist_encode(struct stream *s)
+static uint16_t eigrp_tidlist_encode(struct stream *s)
 {
-       // u_int16_t length = EIGRP_TLV_SW_VERSION_LEN;
+       // uint16_t length = EIGRP_TLV_SW_VERSION_LEN;
        return 0;
 }
 
@@ -475,15 +478,15 @@ static u_int16_t eigrp_tidlist_encode(struct stream *s)
  *
  * @param[in,out]       s       packet stream TLV is stored to
  *
- * @return u_int16_t    number of bytes added to packet stream
+ * @return uint16_t    number of bytes added to packet stream
  *
  * @par
  * Part of conditional receive process
  *
  */
-static u_int16_t eigrp_sequence_encode(struct stream *s)
+static uint16_t eigrp_sequence_encode(struct stream *s)
 {
-       u_int16_t length = EIGRP_TLV_SEQ_BASE_LEN;
+       uint16_t length = EIGRP_TLV_SEQ_BASE_LEN;
        struct eigrp *eigrp;
        struct eigrp_interface *ei;
        struct listnode *node, *node2, *nnode2;
@@ -507,7 +510,7 @@ static u_int16_t eigrp_sequence_encode(struct stream *s)
        for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, ei)) {
                for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) {
                        if (nbr->multicast_queue->count > 0) {
-                               length += (u_int16_t)stream_put_ipv4(
+                               length += (uint16_t)stream_put_ipv4(
                                        s, nbr->src.s_addr);
                                found = 1;
                        }
@@ -532,15 +535,15 @@ static u_int16_t eigrp_sequence_encode(struct stream *s)
  *
  * @param[in,out]       s       packet stream TLV is stored to
  *
- * @return u_int16_t    number of bytes added to packet stream
+ * @return uint16_t    number of bytes added to packet stream
  *
  * @par
  * Part of conditional receive process
  *
  */
-static u_int16_t eigrp_next_sequence_encode(struct stream *s)
+static uint16_t eigrp_next_sequence_encode(struct stream *s)
 {
-       u_int16_t length = EIGRP_NEXT_SEQUENCE_TLV_SIZE;
+       uint16_t length = EIGRP_NEXT_SEQUENCE_TLV_SIZE;
        struct eigrp *eigrp;
 
        eigrp = eigrp_lookup();
@@ -562,7 +565,7 @@ static u_int16_t eigrp_next_sequence_encode(struct stream *s)
  * @param[in]          ei      pointer to interface hello packet came in on
  * @param[in,out]      s       packet stream TLV is stored to
  *
- * @return u_int16_t   number of bytes added to packet stream
+ * @return uint16_t    number of bytes added to packet stream
  *
  * @par
  * Encode Parameter TLV, used to convey metric weights and the hold time.
@@ -571,10 +574,10 @@ static u_int16_t eigrp_next_sequence_encode(struct stream *s)
  * Note the addition of K6 for the new extended metrics, and does not apply to
  * older TLV packet formats.
  */
-static u_int16_t eigrp_hello_parameter_encode(struct eigrp_interface *ei,
-                                             struct stream *s, u_char flags)
+static uint16_t eigrp_hello_parameter_encode(struct eigrp_interface *ei,
+                                            struct stream *s, uint8_t flags)
 {
-       u_int16_t length = EIGRP_TLV_PARAMETER_LEN;
+       uint16_t length = EIGRP_TLV_PARAMETER_LEN;
 
        // add in the parameters TLV
        stream_putw(s, EIGRP_TLV_PARAMETER);
@@ -600,7 +603,7 @@ static u_int16_t eigrp_hello_parameter_encode(struct eigrp_interface *ei,
        }
 
        // and set hold time value..
-       stream_putw(s, IF_DEF_PARAMS(ei->ifp)->v_wait);
+       stream_putw(s, ei->params.v_wait);
 
        return length;
 }
@@ -622,27 +625,27 @@ static u_int16_t eigrp_hello_parameter_encode(struct eigrp_interface *ei,
  *
  */
 static struct eigrp_packet *eigrp_hello_encode(struct eigrp_interface *ei,
-                                              in_addr_t addr, u_int32_t ack,
-                                              u_char flags,
+                                              in_addr_t addr, uint32_t ack,
+                                              uint8_t flags,
                                               struct in_addr *nbr_addr)
 {
        struct eigrp_packet *ep;
-       u_int16_t length = EIGRP_HEADER_LEN;
+       uint16_t length = EIGRP_HEADER_LEN;
 
        // allocate a new packet to be sent
-       ep = eigrp_packet_new(ei->ifp->mtu, NULL);
+       ep = eigrp_packet_new(EIGRP_PACKET_MTU(ei->ifp->mtu), NULL);
 
        if (ep) {
                // encode common header feilds
-               eigrp_packet_header_init(EIGRP_OPC_HELLO, ei->eigrp, ep->s, 0, 0, ack);
+               eigrp_packet_header_init(EIGRP_OPC_HELLO, ei->eigrp, ep->s, 0,
+                                        0, ack);
 
                // encode Authentication TLV
-               if ((IF_DEF_PARAMS(ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5)
-                   && (IF_DEF_PARAMS(ei->ifp)->auth_keychain != NULL)) {
+               if ((ei->params.auth_type == EIGRP_AUTH_TYPE_MD5)
+                   && (ei->params.auth_keychain != NULL)) {
                        length += eigrp_add_authTLV_MD5_to_stream(ep->s, ei);
-               } else if ((IF_DEF_PARAMS(ei->ifp)->auth_type
-                           == EIGRP_AUTH_TYPE_SHA256)
-                          && (IF_DEF_PARAMS(ei->ifp)->auth_keychain != NULL)) {
+               } else if ((ei->params.auth_type == EIGRP_AUTH_TYPE_SHA256)
+                          && (ei->params.auth_keychain != NULL)) {
                        length += eigrp_add_authTLV_SHA256_to_stream(ep->s, ei);
                }
 
@@ -676,13 +679,12 @@ static struct eigrp_packet *eigrp_hello_encode(struct eigrp_interface *ei,
                // set soruce address for the hello packet
                ep->dst.s_addr = addr;
 
-               if ((IF_DEF_PARAMS(ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5)
-                   && (IF_DEF_PARAMS(ei->ifp)->auth_keychain != NULL)) {
+               if ((ei->params.auth_type == EIGRP_AUTH_TYPE_MD5)
+                   && (ei->params.auth_keychain != NULL)) {
                        eigrp_make_md5_digest(ei, ep->s,
                                              EIGRP_AUTH_BASIC_HELLO_FLAG);
-               } else if ((IF_DEF_PARAMS(ei->ifp)->auth_type
-                           == EIGRP_AUTH_TYPE_SHA256)
-                          && (IF_DEF_PARAMS(ei->ifp)->auth_keychain != NULL)) {
+               } else if ((ei->params.auth_type == EIGRP_AUTH_TYPE_SHA256)
+                          && (ei->params.auth_keychain != NULL)) {
                        eigrp_make_sha256_digest(ei, ep->s,
                                                 EIGRP_AUTH_BASIC_HELLO_FLAG);
                }
@@ -750,7 +752,7 @@ void eigrp_hello_send_ack(struct eigrp_neighbor *nbr)
  * sending.  If no packets are currently queues, the packet will be
  * sent immadiatly
  */
-void eigrp_hello_send(struct eigrp_interface *ei, u_char flags,
+void eigrp_hello_send(struct eigrp_interface *ei, uint8_t flags,
                      struct in_addr *nbr_addr)
 {
        struct eigrp_packet *ep = NULL;