Refactoring the MPLS utils
This commit is contained in:
@@ -15,23 +15,23 @@ unsigned char data[] = {
|
||||
|
||||
TEST(MPLS_UTILS, GET)
|
||||
{
|
||||
const struct mpls_hdr *hdr = (struct mpls_hdr *)data;
|
||||
const struct mpls_label *hdr = (struct mpls_label *)data;
|
||||
|
||||
EXPECT_TRUE(mpls_hdr_get_label(hdr) == 0xbe490);
|
||||
EXPECT_TRUE(mpls_hdr_get_exp(hdr) == 0);
|
||||
EXPECT_TRUE(mpls_hdr_get_bos(hdr) == 0);
|
||||
EXPECT_TRUE(mpls_hdr_get_ttl(hdr) == 255);
|
||||
EXPECT_TRUE(mpls_label_get_label(hdr) == 0xbe490);
|
||||
EXPECT_TRUE(mpls_label_get_tc(hdr) == 0);
|
||||
EXPECT_TRUE(mpls_label_get_bos(hdr) == 0);
|
||||
EXPECT_TRUE(mpls_label_get_ttl(hdr) == 255);
|
||||
}
|
||||
|
||||
TEST(MPLS_UTILS, SET)
|
||||
{
|
||||
char buff[4] = {0};
|
||||
struct mpls_hdr *hdr = (struct mpls_hdr *)buff;
|
||||
struct mpls_label *hdr = (struct mpls_label *)buff;
|
||||
|
||||
mpls_hdr_set_label(hdr, 0xbe490);
|
||||
mpls_hdr_set_exp(hdr, 0);
|
||||
mpls_hdr_set_bos(hdr, 0);
|
||||
mpls_hdr_set_ttl(hdr, 255);
|
||||
mpls_label_set_label(hdr, 0xbe490);
|
||||
mpls_label_set_tc(hdr, 0);
|
||||
mpls_label_set_bos(hdr, 0);
|
||||
mpls_label_set_ttl(hdr, 255);
|
||||
EXPECT_TRUE(memcmp(buff, data, 4) == 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user