summaryrefslogtreecommitdiffstats
path: root/eigrpd/eigrp_hello.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-04-08 20:44:58 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-04-08 20:44:58 +0200
commitf9e5c9ca061ae9d8693a766bff99b4ec63b6f5f9 (patch)
tree2d02c2e44cf49608e89749ecebf9569defc599f8 /eigrpd/eigrp_hello.c
parenteigrpd: Only install up to eigrp->max_paths into rib. (diff)
downloadfrr-f9e5c9ca061ae9d8693a766bff99b4ec63b6f5f9.tar.xz
frr-f9e5c9ca061ae9d8693a766bff99b4ec63b6f5f9.zip
eigrpd: Cleanup tab/spacing of the *.c files
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'eigrpd/eigrp_hello.c')
-rw-r--r--eigrpd/eigrp_hello.c253
1 files changed, 129 insertions, 124 deletions
diff --git a/eigrpd/eigrp_hello.c b/eigrpd/eigrp_hello.c
index 81bc408b6..240aa3678 100644
--- a/eigrpd/eigrp_hello.c
+++ b/eigrpd/eigrp_hello.c
@@ -59,14 +59,14 @@
/* Packet Type String. */
static const struct message eigrp_general_tlv_type_str[] =
{
- { EIGRP_TLV_PARAMETER, "PARAMETER" },
- { EIGRP_TLV_AUTH, "AUTH" },
- { EIGRP_TLV_SEQ, "SEQ" },
- { EIGRP_TLV_SW_VERSION, "SW_VERSION" },
- { EIGRP_TLV_NEXT_MCAST_SEQ, "NEXT_MCAST_SEQ" },
- { EIGRP_TLV_PEER_TERMINATION, "PEER_TERMINATION" },
- { EIGRP_TLV_PEER_MTRLIST, "PEER_MTRLIST" },
- { EIGRP_TLV_PEER_TIDLIST, "PEER_TIDLIST" },
+ { EIGRP_TLV_PARAMETER, "PARAMETER" },
+ { EIGRP_TLV_AUTH, "AUTH" },
+ { EIGRP_TLV_SEQ, "SEQ" },
+ { EIGRP_TLV_SW_VERSION, "SW_VERSION" },
+ { EIGRP_TLV_NEXT_MCAST_SEQ, "NEXT_MCAST_SEQ" },
+ { EIGRP_TLV_PEER_TERMINATION, "PEER_TERMINATION" },
+ { EIGRP_TLV_PEER_MTRLIST, "PEER_MTRLIST" },
+ { EIGRP_TLV_PEER_TIDLIST, "PEER_TIDLIST" },
};
static const size_t eigrp_general_tlv_type_str_max = sizeof(eigrp_general_tlv_type_str) /
@@ -76,9 +76,9 @@ static const size_t eigrp_general_tlv_type_str_max = sizeof(eigrp_general_tlv_ty
/*
* @fn eigrp_hello_timer
*
- * @param[in] thread current execution thread timer is associated with
+ * @param[in] thread current execution thread timer is associated with
*
- * @return int always returns 0
+ * @return int always returns 0
*
* @par
* Called once per "hello" time interval, default 5 seconds
@@ -102,7 +102,7 @@ eigrp_hello_timer (struct thread *thread)
/* Hello timer set. */
ei->t_hello = thread_add_timer(master, eigrp_hello_timer, ei,
- EIGRP_IF_PARAM(ei, v_hello));
+ EIGRP_IF_PARAM(ei, v_hello));
return 0;
}
@@ -124,7 +124,7 @@ eigrp_hello_timer (struct thread *thread)
*/
static void
eigrp_hello_parameter_decode (struct eigrp_neighbor *nbr,
- struct eigrp_tlv_hdr_type *tlv)
+ struct eigrp_tlv_hdr_type *tlv)
{
struct eigrp *eigrp = nbr->ei->eigrp;
struct TLV_Parameter_Type *param = (struct TLV_Parameter_Type *)tlv;
@@ -150,43 +150,43 @@ eigrp_hello_parameter_decode (struct eigrp_neighbor *nbr,
{
if (eigrp_nbr_state_get(nbr) == EIGRP_NEIGHBOR_DOWN)
- {
- zlog_info("Neighbor %s (%s) is pending: new adjacency",
- inet_ntoa(nbr->src), ifindex2ifname(nbr->ei->ifp->ifindex, VRF_DEFAULT));
+ {
+ zlog_info("Neighbor %s (%s) is pending: new adjacency",
+ inet_ntoa(nbr->src), ifindex2ifname(nbr->ei->ifp->ifindex, VRF_DEFAULT));
- /* Expedited hello sent */
- eigrp_hello_send(nbr->ei, EIGRP_HELLO_NORMAL, NULL);
+ /* Expedited hello sent */
+ eigrp_hello_send(nbr->ei, EIGRP_HELLO_NORMAL, NULL);
-// if(ntohl(nbr->ei->address->u.prefix4.s_addr) > ntohl(nbr->src.s_addr))
- eigrp_update_send_init(nbr);
+ // if(ntohl(nbr->ei->address->u.prefix4.s_addr) > ntohl(nbr->src.s_addr))
+ eigrp_update_send_init(nbr);
- eigrp_nbr_state_set(nbr, EIGRP_NEIGHBOR_PENDING);
- }
+ eigrp_nbr_state_set(nbr, EIGRP_NEIGHBOR_PENDING);
+ }
}
else
{
if (eigrp_nbr_state_get(nbr) != EIGRP_NEIGHBOR_DOWN)
- {
- if ((param->K1 & param->K2 & param->K3 & param->K4 & param->K5) == 255)
- {
+ {
+ if ((param->K1 & param->K2 & param->K3 & param->K4 & param->K5) == 255)
+ {
zlog_info ("Neighbor %s (%s) is down: Interface PEER-TERMINATION received",
inet_ntoa (nbr->src),ifindex2ifname (nbr->ei->ifp->ifindex, VRF_DEFAULT));
eigrp_nbr_delete (nbr);
- }
- else
- {
+ }
+ else
+ {
zlog_info ("Neighbor %s (%s) going down: Kvalue mismatch",
inet_ntoa (nbr->src),ifindex2ifname (nbr->ei->ifp->ifindex, VRF_DEFAULT));
eigrp_nbr_state_set(nbr, EIGRP_NEIGHBOR_DOWN);
- }
- }
+ }
+ }
}
}
static u_char
-eigrp_hello_authentication_decode(struct stream *s, struct eigrp_tlv_hdr_type *tlv_header, struct eigrp_neighbor *nbr)
+eigrp_hello_authentication_decode(struct stream *s, struct eigrp_tlv_hdr_type *tlv_header,
+ struct eigrp_neighbor *nbr)
{
-
struct TLV_MD5_Authentication_Type *md5;
md5 = (struct TLV_MD5_Authentication_Type *) tlv_header;
@@ -194,7 +194,8 @@ eigrp_hello_authentication_decode(struct stream *s, struct eigrp_tlv_hdr_type *t
if(md5->auth_type == EIGRP_AUTH_TYPE_MD5)
return eigrp_check_md5_digest(s, md5, nbr, EIGRP_AUTH_BASIC_HELLO_FLAG);
else if (md5->auth_type == EIGRP_AUTH_TYPE_SHA256)
- return eigrp_check_sha256_digest(s, (struct TLV_SHA256_Authentication_Type *) tlv_header, nbr, EIGRP_AUTH_BASIC_HELLO_FLAG);
+ return eigrp_check_sha256_digest(s, (struct TLV_SHA256_Authentication_Type *)tlv_header,
+ nbr, EIGRP_AUTH_BASIC_HELLO_FLAG);
return 0;
}
@@ -214,7 +215,7 @@ eigrp_hello_authentication_decode(struct stream *s, struct eigrp_tlv_hdr_type *t
*/
static void
eigrp_sw_version_decode (struct eigrp_neighbor *nbr,
- struct eigrp_tlv_hdr_type *tlv)
+ struct eigrp_tlv_hdr_type *tlv)
{
struct TLV_Software_Type *version = (struct TLV_Software_Type *)tlv;
@@ -240,22 +241,22 @@ eigrp_sw_version_decode (struct eigrp_neighbor *nbr,
*/
static void
eigrp_peer_termination_decode (struct eigrp_neighbor *nbr,
- struct eigrp_tlv_hdr_type *tlv)
+ struct eigrp_tlv_hdr_type *tlv)
{
- struct TLV_Peer_Termination_type *param = (struct TLV_Peer_Termination_type *)tlv;
-
- uint32_t my_ip = nbr->ei->address->u.prefix4.s_addr;
- uint32_t received_ip = param->neighbor_ip;
-
- if(my_ip == received_ip)
- {
- zlog_info ("Neighbor %s (%s) is down: Peer Termination received",
- inet_ntoa (nbr->src),ifindex2ifname (nbr->ei->ifp->ifindex, VRF_DEFAULT));
- /* set neighbor to DOWN */
- nbr->state = EIGRP_NEIGHBOR_DOWN;
- /* delete neighbor */
- eigrp_nbr_delete (nbr);
- }
+ struct TLV_Peer_Termination_type *param = (struct TLV_Peer_Termination_type *)tlv;
+
+ uint32_t my_ip = nbr->ei->address->u.prefix4.s_addr;
+ uint32_t received_ip = param->neighbor_ip;
+
+ if(my_ip == received_ip)
+ {
+ zlog_info ("Neighbor %s (%s) is down: Peer Termination received",
+ inet_ntoa (nbr->src),ifindex2ifname (nbr->ei->ifp->ifindex, VRF_DEFAULT));
+ /* set neighbor to DOWN */
+ nbr->state = EIGRP_NEIGHBOR_DOWN;
+ /* delete neighbor */
+ eigrp_nbr_delete (nbr);
+ }
}
/**
@@ -272,30 +273,30 @@ eigrp_peer_termination_decode (struct eigrp_neighbor *nbr,
static u_int16_t
eigrp_peer_termination_encode (struct stream *s, struct in_addr *nbr_addr)
{
- u_int16_t length = EIGRP_TLV_PEER_TERMINATION_LEN;
+ u_int16_t length = EIGRP_TLV_PEER_TERMINATION_LEN;
- /* fill in type and length */
- stream_putw(s, EIGRP_TLV_PEER_TERMINATION);
- stream_putw(s, length);
+ /* fill in type and length */
+ stream_putw(s, EIGRP_TLV_PEER_TERMINATION);
+ stream_putw(s, length);
- /* fill in unknown field 0x04 */
- stream_putc(s, 0x04);
+ /* fill in unknown field 0x04 */
+ stream_putc(s, 0x04);
- /* finally neighbor IP address */
- stream_put_ipv4(s, nbr_addr->s_addr);
+ /* finally neighbor IP address */
+ stream_put_ipv4(s, nbr_addr->s_addr);
- return(length);
+ return(length);
}
/*
* @fn eigrp_hello_receive
*
- * @param[in] eigrp eigrp routing process
- * @param[in] iph pointer to ip header
- * @param[in] eigrph pointer to eigrp header
- * @param[in] s input ip stream
- * @param[in] ei eigrp interface packet arrived on
- * @param[in] size size of eigrp packet
+ * @param[in] eigrp eigrp routing process
+ * @param[in] iph pointer to ip header
+ * @param[in] eigrph pointer to eigrp header
+ * @param[in] s input ip stream
+ * @param[in] ei eigrp interface packet arrived on
+ * @param[in] size size of eigrp packet
*
* @return void
*
@@ -310,12 +311,12 @@ eigrp_peer_termination_encode (struct stream *s, struct in_addr *nbr_addr)
*/
void
eigrp_hello_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header *eigrph,
- struct stream *s, struct eigrp_interface *ei, int size)
+ struct stream *s, struct eigrp_interface *ei, int size)
{
struct eigrp_tlv_hdr_type *tlv_header;
struct eigrp_neighbor *nbr;
- uint16_t type;
- uint16_t length;
+ uint16_t type;
+ uint16_t length;
/* get neighbor struct */
nbr = eigrp_nbr_get(ei, eigrph, iph);
@@ -325,8 +326,8 @@ eigrp_hello_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header *e
if (IS_DEBUG_EIGRP_PACKET(eigrph->opcode - 1, RECV))
zlog_debug("Processing Hello size[%u] int(%s) nbr(%s)",
- size, ifindex2ifname(nbr->ei->ifp->ifindex, VRF_DEFAULT),
- inet_ntoa(nbr->src));
+ size, ifindex2ifname(nbr->ei->ifp->ifindex, VRF_DEFAULT),
+ inet_ntoa(nbr->src));
size -= EIGRP_HEADER_LEN;
if (size < 0)
@@ -340,40 +341,40 @@ eigrp_hello_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header *e
if ((length > 0) && (length <= size))
{
- if (IS_DEBUG_EIGRP_PACKET(0, RECV))
- zlog_debug(" General TLV(%s)", LOOKUP(eigrp_general_tlv_type_str, type));
-
- // determine what General TLV is being processed
- switch (type)
- {
- case EIGRP_TLV_PARAMETER:
- eigrp_hello_parameter_decode(nbr, tlv_header);
- break;
- case EIGRP_TLV_AUTH:
- {
+ if (IS_DEBUG_EIGRP_PACKET(0, RECV))
+ zlog_debug(" General TLV(%s)", LOOKUP(eigrp_general_tlv_type_str, type));
+
+ // determine what General TLV is being processed
+ switch (type)
+ {
+ case EIGRP_TLV_PARAMETER:
+ eigrp_hello_parameter_decode(nbr, tlv_header);
+ break;
+ case EIGRP_TLV_AUTH:
+ {
if(eigrp_hello_authentication_decode(s,tlv_header,nbr) == 0)
return;
else
break;
break;
- }
- case EIGRP_TLV_SEQ:
- break;
- case EIGRP_TLV_SW_VERSION:
- eigrp_sw_version_decode(nbr, tlv_header);
- break;
- case EIGRP_TLV_NEXT_MCAST_SEQ:
- break;
- case EIGRP_TLV_PEER_TERMINATION:
- eigrp_peer_termination_decode(nbr, tlv_header);
- break;
- case EIGRP_TLV_PEER_MTRLIST:
- case EIGRP_TLV_PEER_TIDLIST:
- break;
- default:
- break;
- }
- }
+ }
+ case EIGRP_TLV_SEQ:
+ break;
+ case EIGRP_TLV_SW_VERSION:
+ eigrp_sw_version_decode(nbr, tlv_header);
+ break;
+ case EIGRP_TLV_NEXT_MCAST_SEQ:
+ break;
+ case EIGRP_TLV_PEER_TERMINATION:
+ eigrp_peer_termination_decode(nbr, tlv_header);
+ break;
+ case EIGRP_TLV_PEER_MTRLIST:
+ case EIGRP_TLV_PEER_TIDLIST:
+ break;
+ default:
+ break;
+ }
+ }
tlv_header = (struct eigrp_tlv_hdr_type *)(((char *)tlv_header) + length);
size -= length;
@@ -391,8 +392,7 @@ eigrp_hello_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header *e
}
if (IS_DEBUG_EIGRP_PACKET(0, RECV))
- zlog_debug("Hello Packet received from %s", inet_ntoa(nbr->src));
-
+ zlog_debug("Hello Packet received from %s", inet_ntoa(nbr->src));
}
/**
@@ -418,8 +418,8 @@ eigrp_sw_version_encode (struct stream *s)
// encode the version of quagga we're running
// DVS: need to figure out a cleaner way to do this
- stream_putc(s, 0); //!< major os version
- stream_putc(s, 99); //!< minor os version
+ stream_putc(s, 0); //!< major os version
+ stream_putc(s, 99); //!< minor os version
/* and the core eigrp version */
stream_putc(s, EIGRP_MAJOR_VERSION);
@@ -532,9 +532,9 @@ eigrp_next_sequence_encode (struct stream *s)
}
// add in the parameters TLV
- stream_putw(s, EIGRP_TLV_NEXT_MCAST_SEQ);
- stream_putw(s, EIGRP_NEXT_SEQUENCE_TLV_SIZE);
- stream_putl(s,eigrp->sequence_number+1);
+ stream_putw(s, EIGRP_TLV_NEXT_MCAST_SEQ);
+ stream_putw(s, EIGRP_NEXT_SEQUENCE_TLV_SIZE);
+ stream_putl(s,eigrp->sequence_number+1);
return length;
}
@@ -557,7 +557,7 @@ eigrp_next_sequence_encode (struct stream *s)
static u_int16_t
eigrp_hello_parameter_encode (struct eigrp_interface *ei, struct stream *s, u_char flags)
{
- u_int16_t length = EIGRP_TLV_PARAMETER_LEN;
+ u_int16_t length = EIGRP_TLV_PARAMETER_LEN;
// add in the parameters TLV
stream_putw(s, EIGRP_TLV_PARAMETER);
@@ -605,7 +605,8 @@ eigrp_hello_parameter_encode (struct eigrp_interface *ei, struct stream *s, u_ch
*
*/
static struct eigrp_packet *
-eigrp_hello_encode (struct eigrp_interface *ei, in_addr_t addr, u_int32_t ack, u_char flags, struct in_addr *nbr_addr)
+eigrp_hello_encode (struct eigrp_interface *ei, in_addr_t addr, u_int32_t ack,
+ u_char flags, struct in_addr *nbr_addr)
{
struct eigrp_packet *ep;
u_int16_t length = EIGRP_HEADER_LEN;
@@ -619,11 +620,13 @@ eigrp_hello_encode (struct eigrp_interface *ei, in_addr_t addr, u_int32_t ack, u
eigrp_packet_header_init(EIGRP_OPC_HELLO, ei, 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((IF_DEF_PARAMS (ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5) &&
+ (IF_DEF_PARAMS (ei->ifp)->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((IF_DEF_PARAMS (ei->ifp)->auth_type == EIGRP_AUTH_TYPE_SHA256) &&
+ (IF_DEF_PARAMS (ei->ifp)->auth_keychain != NULL))
{
length += eigrp_add_authTLV_SHA256_to_stream(ep->s,ei);
}
@@ -648,7 +651,7 @@ eigrp_hello_encode (struct eigrp_interface *ei, in_addr_t addr, u_int32_t ack, u
/* encode Peer Termination TLV if needed */
if(flags & EIGRP_HELLO_GRACEFUL_SHUTDOWN_NBR)
- length += eigrp_peer_termination_encode(ep->s, nbr_addr);
+ length += eigrp_peer_termination_encode(ep->s, nbr_addr);
// Set packet length
ep->length = length;
@@ -656,11 +659,13 @@ eigrp_hello_encode (struct eigrp_interface *ei, in_addr_t addr, u_int32_t ack, u
// 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((IF_DEF_PARAMS (ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5) &&
+ (IF_DEF_PARAMS (ei->ifp)->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((IF_DEF_PARAMS (ei->ifp)->auth_type == EIGRP_AUTH_TYPE_SHA256) &&
+ (IF_DEF_PARAMS (ei->ifp)->auth_keychain != NULL))
{
eigrp_make_sha256_digest(ei,ep->s, EIGRP_AUTH_BASIC_HELLO_FLAG);
}
@@ -696,21 +701,21 @@ eigrp_hello_send_ack (struct eigrp_neighbor *nbr)
if (ep)
{
if (IS_DEBUG_EIGRP_PACKET(0, SEND))
- zlog_debug("Queueing [Hello] Ack Seq [%u] nbr [%s]",
- nbr->recv_sequence_number, inet_ntoa(nbr->src));
+ zlog_debug("Queueing [Hello] Ack Seq [%u] nbr [%s]",
+ nbr->recv_sequence_number, inet_ntoa(nbr->src));
/* Add packet to the top of the interface output queue*/
eigrp_fifo_push_head(nbr->ei->obuf, ep);
/* Hook thread to write packet. */
if (nbr->ei->on_write_q == 0)
- {
- listnode_add(nbr->ei->eigrp->oi_write_q, nbr->ei);
- nbr->ei->on_write_q = 1;
- }
+ {
+ listnode_add(nbr->ei->eigrp->oi_write_q, nbr->ei);
+ nbr->ei->on_write_q = 1;
+ }
if (nbr->ei->eigrp->t_write == NULL)
- nbr->ei->eigrp->t_write =
- thread_add_write(master, eigrp_write, nbr->ei->eigrp, nbr->ei->eigrp->fd);
+ nbr->ei->eigrp->t_write =
+ thread_add_write(master, eigrp_write, nbr->ei->eigrp, nbr->ei->eigrp->fd);
}
}
@@ -734,9 +739,9 @@ eigrp_hello_send (struct eigrp_interface *ei, u_char flags, struct in_addr *nbr_
struct eigrp_packet *ep = NULL;
/* If this is passive interface, do not send EIGRP Hello.
- if ((EIGRP_IF_PASSIVE_STATUS (ei) == EIGRP_IF_PASSIVE) ||
- (ei->type != EIGRP_IFTYPE_NBMA))
- return;
+ if ((EIGRP_IF_PASSIVE_STATUS (ei) == EIGRP_IF_PASSIVE) ||
+ (ei->type != EIGRP_IFTYPE_NBMA))
+ return;
*/
if (IS_DEBUG_EIGRP_PACKET(0, SEND))
@@ -762,13 +767,13 @@ eigrp_hello_send (struct eigrp_interface *ei, u_char flags, struct in_addr *nbr_
if(flags & EIGRP_HELLO_GRACEFUL_SHUTDOWN)
{
ei->eigrp->t_write =
- thread_execute(master, eigrp_write, ei->eigrp, ei->eigrp->fd);
+ thread_execute(master, eigrp_write, ei->eigrp, ei->eigrp->fd);
}
else
{
ei->eigrp->t_write =
thread_add_write(master, eigrp_write, ei->eigrp, ei->eigrp->fd);
}
- }
+ }
}
}