tc: use mac as filter and mask
This commit is contained in:
parent
fd74179fbb
commit
670f0e6a8f
20
tc.c
20
tc.c
|
@ -55,10 +55,14 @@ void tc_block_all()
|
||||||
void tc_allow_mac(const uint8_t mac[])
|
void tc_allow_mac(const uint8_t mac[])
|
||||||
{
|
{
|
||||||
char cmd[2048];
|
char cmd[2048];
|
||||||
|
char mac32[9];
|
||||||
|
char mac16[5];
|
||||||
|
snprintf(mac32, 9, "%2x%2x%2x%2x", mac[0], mac[1], mac[2], mac[3]);
|
||||||
|
snprintf(mac16, 5, "%2x%2x", mac[4], mac[5]);
|
||||||
snprintf(cmd, 2048, "tc filter add dev %s protocol all parent ffff: prio 99 "
|
snprintf(cmd, 2048, "tc filter add dev %s protocol all parent ffff: prio 99 "
|
||||||
"basic match \"u32(u32 0x%2x%2x%2x%2x 0xffffffff at -8)\" "
|
"basic match \"u32(u32 0x%s 0x%s at -8)\" "
|
||||||
"and \"u32(u16 0x%2x%2x 0xffff at -4)\" flowid :1 action pass",
|
"and \"u32(u16 0x%s 0x%s at -4)\" flowid :1 action pass",
|
||||||
g_interface, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
g_interface, mac32, mac32, mac16, mac16);
|
||||||
log_debug("CMD: %s\n", cmd);
|
log_debug("CMD: %s\n", cmd);
|
||||||
system(cmd);
|
system(cmd);
|
||||||
}
|
}
|
||||||
|
@ -66,10 +70,14 @@ void tc_allow_mac(const uint8_t mac[])
|
||||||
void tc_disallow_mac(const uint8_t mac[])
|
void tc_disallow_mac(const uint8_t mac[])
|
||||||
{
|
{
|
||||||
char cmd[2048];
|
char cmd[2048];
|
||||||
|
char mac32[9];
|
||||||
|
char mac16[5];
|
||||||
|
snprintf(mac32, 9, "%2x%2x%2x%2x", mac[0], mac[1], mac[2], mac[3]);
|
||||||
|
snprintf(mac16, 5, "%2x%2x", mac[4], mac[5]);
|
||||||
snprintf(cmd, 2048, "tc filter delete dev %s protocol all parent ffff: prio 99 "
|
snprintf(cmd, 2048, "tc filter delete dev %s protocol all parent ffff: prio 99 "
|
||||||
"basic match \"u32(u32 0x%2x%2x%2x%2x 0xffffffff at -8)\" "
|
"basic match \"u32(u32 0x%s 0x%s at -8)\" "
|
||||||
"and \"u32(u16 0x%2x%2x 0xffff at -4)\" flowid :1 action pass",
|
"and \"u32(u16 0x%s 0x%s at -4)\" flowid :1 action pass",
|
||||||
g_interface, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
g_interface, mac32, mac32, mac16, mac16);
|
||||||
log_debug("CMD: %s\n", cmd);
|
log_debug("CMD: %s\n", cmd);
|
||||||
system(cmd);
|
system(cmd);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue