mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 07:37:29 +00:00
ospf6d: decode message type with LOOKUP()
* ospf6_message.h * OSPF6_MESSAGE_TYPE_CANONICAL(): dismiss * OSPF6_MESSAGE_TYPE_NAME(): dismiss * ospf6_message.c * ospf6_message_type_str: rewrite as a message list, add max value * ospf6_packet_examin(): update to use LOOKUP() * ospf6_receive(): idem * ospf6_send(): idem
This commit is contained in:
parent
fa0796661c
commit
5031ed1347
@ -50,8 +50,16 @@
|
|||||||
#include <netinet/ip6.h>
|
#include <netinet/ip6.h>
|
||||||
|
|
||||||
unsigned char conf_debug_ospf6_message[6] = {0x03, 0, 0, 0, 0, 0};
|
unsigned char conf_debug_ospf6_message[6] = {0x03, 0, 0, 0, 0, 0};
|
||||||
const char *ospf6_message_type_str[] =
|
static const struct message ospf6_message_type_str [] =
|
||||||
{ "Unknown", "Hello", "DbDesc", "LSReq", "LSUpdate", "LSAck" };
|
{
|
||||||
|
{ OSPF6_MESSAGE_TYPE_HELLO, "Hello" },
|
||||||
|
{ OSPF6_MESSAGE_TYPE_DBDESC, "DbDesc" },
|
||||||
|
{ OSPF6_MESSAGE_TYPE_LSREQ, "LSReq" },
|
||||||
|
{ OSPF6_MESSAGE_TYPE_LSUPDATE, "LSUpdate" },
|
||||||
|
{ OSPF6_MESSAGE_TYPE_LSACK, "LSAck" },
|
||||||
|
};
|
||||||
|
static const size_t ospf6_message_type_str_max =
|
||||||
|
sizeof (ospf6_message_type_str) / sizeof (ospf6_message_type_str[0]);
|
||||||
|
|
||||||
/* Minimum (besides the standard OSPF packet header) lengths for OSPF
|
/* Minimum (besides the standard OSPF packet header) lengths for OSPF
|
||||||
packets of particular types, offset is the "type" field. */
|
packets of particular types, offset is the "type" field. */
|
||||||
@ -1194,7 +1202,7 @@ ospf6_packet_examin (struct ospf6_header *oh, const unsigned bytesonwire)
|
|||||||
{
|
{
|
||||||
if (IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_UNKNOWN, RECV))
|
if (IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_UNKNOWN, RECV))
|
||||||
zlog_debug ("%s: undersized (%u B) %s packet", __func__,
|
zlog_debug ("%s: undersized (%u B) %s packet", __func__,
|
||||||
bytesonwire, ospf6_message_type_str[oh->type]);
|
bytesonwire, LOOKUP (ospf6_message_type_str, oh->type));
|
||||||
return MSG_NG;
|
return MSG_NG;
|
||||||
}
|
}
|
||||||
/* type-specific deeper validation */
|
/* type-specific deeper validation */
|
||||||
@ -1207,7 +1215,7 @@ ospf6_packet_examin (struct ospf6_header *oh, const unsigned bytesonwire)
|
|||||||
return MSG_OK;
|
return MSG_OK;
|
||||||
if (IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_UNKNOWN, RECV))
|
if (IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_UNKNOWN, RECV))
|
||||||
zlog_debug ("%s: alignment error in %s packet",
|
zlog_debug ("%s: alignment error in %s packet",
|
||||||
__func__, ospf6_message_type_str[oh->type]);
|
__func__, LOOKUP (ospf6_message_type_str, oh->type));
|
||||||
return MSG_NG;
|
return MSG_NG;
|
||||||
case OSPF6_MESSAGE_TYPE_DBDESC:
|
case OSPF6_MESSAGE_TYPE_DBDESC:
|
||||||
/* RFC5340 A.3.3, packet header + OSPF6_DB_DESC_MIN_SIZE bytes followed
|
/* RFC5340 A.3.3, packet header + OSPF6_DB_DESC_MIN_SIZE bytes followed
|
||||||
@ -1226,7 +1234,7 @@ ospf6_packet_examin (struct ospf6_header *oh, const unsigned bytesonwire)
|
|||||||
return MSG_OK;
|
return MSG_OK;
|
||||||
if (IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_UNKNOWN, RECV))
|
if (IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_UNKNOWN, RECV))
|
||||||
zlog_debug ("%s: alignment error in %s packet",
|
zlog_debug ("%s: alignment error in %s packet",
|
||||||
__func__, ospf6_message_type_str[oh->type]);
|
__func__, LOOKUP (ospf6_message_type_str, oh->type));
|
||||||
return MSG_NG;
|
return MSG_NG;
|
||||||
case OSPF6_MESSAGE_TYPE_LSUPDATE:
|
case OSPF6_MESSAGE_TYPE_LSUPDATE:
|
||||||
/* RFC5340 A.3.5, packet header + OSPF6_LS_UPD_MIN_SIZE bytes followed
|
/* RFC5340 A.3.5, packet header + OSPF6_LS_UPD_MIN_SIZE bytes followed
|
||||||
@ -1256,7 +1264,7 @@ ospf6_packet_examin (struct ospf6_header *oh, const unsigned bytesonwire)
|
|||||||
return MSG_NG;
|
return MSG_NG;
|
||||||
}
|
}
|
||||||
if (test != MSG_OK && IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_UNKNOWN, RECV))
|
if (test != MSG_OK && IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_UNKNOWN, RECV))
|
||||||
zlog_debug ("%s: anomaly in %s packet", __func__, ospf6_message_type_str[oh->type]);
|
zlog_debug ("%s: anomaly in %s packet", __func__, LOOKUP (ospf6_message_type_str, oh->type));
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1577,7 +1585,7 @@ ospf6_receive (struct thread *thread)
|
|||||||
inet_ntop (AF_INET6, &src, srcname, sizeof (srcname));
|
inet_ntop (AF_INET6, &src, srcname, sizeof (srcname));
|
||||||
inet_ntop (AF_INET6, &dst, dstname, sizeof (dstname));
|
inet_ntop (AF_INET6, &dst, dstname, sizeof (dstname));
|
||||||
zlog_debug ("%s received on %s",
|
zlog_debug ("%s received on %s",
|
||||||
OSPF6_MESSAGE_TYPE_NAME (oh->type), oi->interface->name);
|
LOOKUP (ospf6_message_type_str, oh->type), oi->interface->name);
|
||||||
zlog_debug (" src: %s", srcname);
|
zlog_debug (" src: %s", srcname);
|
||||||
zlog_debug (" dst: %s", dstname);
|
zlog_debug (" dst: %s", dstname);
|
||||||
|
|
||||||
@ -1665,7 +1673,7 @@ ospf6_send (struct in6_addr *src, struct in6_addr *dst,
|
|||||||
else
|
else
|
||||||
memset (srcname, 0, sizeof (srcname));
|
memset (srcname, 0, sizeof (srcname));
|
||||||
zlog_debug ("%s send on %s",
|
zlog_debug ("%s send on %s",
|
||||||
OSPF6_MESSAGE_TYPE_NAME (oh->type), oi->interface->name);
|
LOOKUP (ospf6_message_type_str, oh->type), oi->interface->name);
|
||||||
zlog_debug (" src: %s", srcname);
|
zlog_debug (" src: %s", srcname);
|
||||||
zlog_debug (" dst: %s", dstname);
|
zlog_debug (" dst: %s", dstname);
|
||||||
|
|
||||||
|
@ -44,13 +44,6 @@ extern unsigned char conf_debug_ospf6_message[];
|
|||||||
#define OSPF6_MESSAGE_TYPE_LSACK 0x5 /* Flooding acknowledgment */
|
#define OSPF6_MESSAGE_TYPE_LSACK 0x5 /* Flooding acknowledgment */
|
||||||
#define OSPF6_MESSAGE_TYPE_ALL 0x6 /* For debug option */
|
#define OSPF6_MESSAGE_TYPE_ALL 0x6 /* For debug option */
|
||||||
|
|
||||||
#define OSPF6_MESSAGE_TYPE_CANONICAL(T) \
|
|
||||||
((T) > OSPF6_MESSAGE_TYPE_LSACK ? OSPF6_MESSAGE_TYPE_UNKNOWN : (T))
|
|
||||||
|
|
||||||
extern const char *ospf6_message_type_str[];
|
|
||||||
#define OSPF6_MESSAGE_TYPE_NAME(T) \
|
|
||||||
(ospf6_message_type_str[ OSPF6_MESSAGE_TYPE_CANONICAL (T) ])
|
|
||||||
|
|
||||||
/* OSPFv3 packet header */
|
/* OSPFv3 packet header */
|
||||||
#define OSPF6_HEADER_SIZE 16U
|
#define OSPF6_HEADER_SIZE 16U
|
||||||
struct ospf6_header
|
struct ospf6_header
|
||||||
|
Loading…
Reference in New Issue
Block a user