mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-03 19:13:19 +00:00
pimd: Refactor pim message type to an enum
Change the pim message type to an enum and add the ability to output a string based upon message type. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
36d9e7dcea
commit
7643f0a1c6
@ -46,6 +46,25 @@ static int on_pim_hello_send(struct thread *t);
|
||||
static int pim_hello_send(struct interface *ifp,
|
||||
uint16_t holdtime);
|
||||
|
||||
static
|
||||
const char *pim_pim_msgtype2str (enum pim_msg_type type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case PIM_MSG_TYPE_HELLO: return "HELLO";
|
||||
case PIM_MSG_TYPE_REGISTER: return "REGISTER";
|
||||
case PIM_MSG_TYPE_REG_STOP: return "REGSTOP";
|
||||
case PIM_MSG_TYPE_JOIN_PRUNE: return "JP";
|
||||
case PIM_MSG_TYPE_BOOTSTRAP: return "BOOT";
|
||||
case PIM_MSG_TYPE_ASSERT: return "ASSERT";
|
||||
case PIM_MSG_TYPE_GRAFT: return "GRAFT";
|
||||
case PIM_MSG_TYPE_GRAFT_ACK: return "GACK";
|
||||
case PIM_MSG_TYPE_CANDIDATE: return "CANDIDATE";
|
||||
}
|
||||
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
static void sock_close(struct interface *ifp)
|
||||
{
|
||||
struct pim_interface *pim_ifp = ifp->info;
|
||||
@ -121,7 +140,7 @@ int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len)
|
||||
uint8_t *pim_msg;
|
||||
int pim_msg_len;
|
||||
uint8_t pim_version;
|
||||
uint8_t pim_type;
|
||||
enum pim_msg_type pim_type;
|
||||
uint16_t pim_checksum; /* received checksum */
|
||||
uint16_t checksum; /* computed checksum */
|
||||
struct pim_neighbor *neigh;
|
||||
@ -203,9 +222,9 @@ int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len)
|
||||
}
|
||||
|
||||
if (PIM_DEBUG_PIM_PACKETS) {
|
||||
zlog_debug("Recv PIM packet from %s to %s on %s: ttl=%d pim_version=%d pim_type=%d pim_msg_size=%d checksum=%x",
|
||||
src_str, dst_str, ifp->name, ip_hdr->ip_ttl,
|
||||
pim_version, pim_type, pim_msg_len, checksum);
|
||||
zlog_debug("Recv PIM %s packet from %s to %s on %s: ttl=%d pim_version=%d pim_msg_size=%d checksum=%x",
|
||||
pim_pim_msgtype2str (pim_type), src_str, dst_str, ifp->name,
|
||||
ip_hdr->ip_ttl, pim_version, pim_msg_len, checksum);
|
||||
}
|
||||
|
||||
switch (pim_type)
|
||||
|
@ -40,15 +40,17 @@
|
||||
#define PIM_DEFAULT_CAN_DISABLE_JOIN_SUPPRESSION (0) /* boolean */
|
||||
#define PIM_DEFAULT_T_PERIODIC (60) /* RFC 4601: 4.11. Timer Values */
|
||||
|
||||
#define PIM_MSG_TYPE_HELLO (0)
|
||||
#define PIM_MSG_TYPE_REGISTER (1)
|
||||
#define PIM_MSG_TYPE_REG_STOP (2)
|
||||
#define PIM_MSG_TYPE_JOIN_PRUNE (3)
|
||||
#define PIM_MSG_TYPE_BOOTSTRAP (4)
|
||||
#define PIM_MSG_TYPE_ASSERT (5)
|
||||
#define PIM_MSG_TYPE_GRAFT (6)
|
||||
#define PIM_MSG_TYPE_GRAFT_ACK (7)
|
||||
#define PIM_MSG_TYPE_CANDIDATE (8)
|
||||
enum pim_msg_type {
|
||||
PIM_MSG_TYPE_HELLO = 0,
|
||||
PIM_MSG_TYPE_REGISTER,
|
||||
PIM_MSG_TYPE_REG_STOP,
|
||||
PIM_MSG_TYPE_JOIN_PRUNE,
|
||||
PIM_MSG_TYPE_BOOTSTRAP,
|
||||
PIM_MSG_TYPE_ASSERT,
|
||||
PIM_MSG_TYPE_GRAFT,
|
||||
PIM_MSG_TYPE_GRAFT_ACK,
|
||||
PIM_MSG_TYPE_CANDIDATE
|
||||
};
|
||||
|
||||
#define PIM_MSG_HDR_OFFSET_VERSION(pim_msg) (pim_msg)
|
||||
#define PIM_MSG_HDR_OFFSET_TYPE(pim_msg) (pim_msg)
|
||||
|
Loading…
Reference in New Issue
Block a user