gluon-radvd-filterd: fix c indentation
This commit is contained in:
parent
36f407877b
commit
e797ad4c2f
@ -59,10 +59,10 @@
|
|||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define CHECK(stmt) \
|
#define CHECK(stmt) \
|
||||||
if(!(stmt)) { \
|
if(!(stmt)) { \
|
||||||
fprintf(stderr, "check failed: " #stmt "\n"); \
|
fprintf(stderr, "check failed: " #stmt "\n"); \
|
||||||
goto check_failed; \
|
goto check_failed; \
|
||||||
}
|
}
|
||||||
#define DEBUG_MSG(msg, ...) fprintf(stderr, msg "\n", ##__VA_ARGS__)
|
#define DEBUG_MSG(msg, ...) fprintf(stderr, msg "\n", ##__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define CHECK(stmt) if(!(stmt)) goto check_failed;
|
#define CHECK(stmt) if(!(stmt)) goto check_failed;
|
||||||
@ -78,8 +78,8 @@
|
|||||||
|
|
||||||
#define foreach_safe(item, safe, list) \
|
#define foreach_safe(item, safe, list) \
|
||||||
for ((item) = (list); \
|
for ((item) = (list); \
|
||||||
(item) && (((safe) = item->next) || 1); \
|
(item) && (((safe) = item->next) || 1); \
|
||||||
(item) = (safe))
|
(item) = (safe))
|
||||||
|
|
||||||
struct router {
|
struct router {
|
||||||
struct router *next;
|
struct router *next;
|
||||||
@ -103,7 +103,7 @@ static struct global {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int fork_execvp_timeout(struct timespec *timeout, const char *file,
|
static int fork_execvp_timeout(struct timespec *timeout, const char *file,
|
||||||
const char *const argv[]);
|
const char *const argv[]);
|
||||||
|
|
||||||
static void error_message(int status, int errnum, char *message, ...) {
|
static void error_message(int status, int errnum, char *message, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@ -120,7 +120,7 @@ static void error_message(int status, int errnum, char *message, ...) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int timespec_diff(struct timespec *tv1, struct timespec *tv2,
|
static int timespec_diff(struct timespec *tv1, struct timespec *tv2,
|
||||||
struct timespec *tvdiff)
|
struct timespec *tvdiff)
|
||||||
{
|
{
|
||||||
tvdiff->tv_sec = tv1->tv_sec - tv2->tv_sec;
|
tvdiff->tv_sec = tv1->tv_sec - tv2->tv_sec;
|
||||||
if (tv1->tv_nsec < tv2->tv_nsec) {
|
if (tv1->tv_nsec < tv2->tv_nsec) {
|
||||||
@ -219,8 +219,8 @@ static int init_packet_socket(unsigned int ifindex) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct sock_fprog radv_filter = {
|
struct sock_fprog radv_filter = {
|
||||||
.len = ARRAY_SIZE(radv_filter_code),
|
.len = ARRAY_SIZE(radv_filter_code),
|
||||||
.filter = radv_filter_code,
|
.filter = radv_filter_code,
|
||||||
};
|
};
|
||||||
|
|
||||||
int sock = socket(AF_PACKET, SOCK_DGRAM|SOCK_CLOEXEC, htons(ETH_P_IPV6));
|
int sock = socket(AF_PACKET, SOCK_DGRAM|SOCK_CLOEXEC, htons(ETH_P_IPV6));
|
||||||
@ -382,7 +382,7 @@ static void expire_routers(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int parse_tt_global(struct nl_msg *msg,
|
static int parse_tt_global(struct nl_msg *msg,
|
||||||
void *arg __attribute__((unused)))
|
void *arg __attribute__((unused)))
|
||||||
{
|
{
|
||||||
static const enum batadv_nl_attrs mandatory[] = {
|
static const enum batadv_nl_attrs mandatory[] = {
|
||||||
BATADV_ATTR_TT_ADDRESS,
|
BATADV_ATTR_TT_ADDRESS,
|
||||||
@ -406,7 +406,7 @@ static int parse_tt_global(struct nl_msg *msg,
|
|||||||
return NL_OK;
|
return NL_OK;
|
||||||
|
|
||||||
if (nla_parse(attrs, BATADV_ATTR_MAX, genlmsg_attrdata(ghdr, 0),
|
if (nla_parse(attrs, BATADV_ATTR_MAX, genlmsg_attrdata(ghdr, 0),
|
||||||
genlmsg_len(ghdr), batadv_genl_policy)) {
|
genlmsg_len(ghdr), batadv_genl_policy)) {
|
||||||
return NL_OK;
|
return NL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,14 +428,14 @@ static int parse_tt_global(struct nl_msg *msg,
|
|||||||
return NL_OK;
|
return NL_OK;
|
||||||
|
|
||||||
DEBUG_MSG("Found originator for " F_MAC ", it's " F_MAC,
|
DEBUG_MSG("Found originator for " F_MAC ", it's " F_MAC,
|
||||||
F_MAC_VAR(router->src), F_MAC_VAR(mac_b));
|
F_MAC_VAR(router->src), F_MAC_VAR(mac_b));
|
||||||
router->originator = mac_b;
|
router->originator = mac_b;
|
||||||
|
|
||||||
return NL_OK;
|
return NL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_originator(struct nl_msg *msg,
|
static int parse_originator(struct nl_msg *msg,
|
||||||
void *arg __attribute__((unused)))
|
void *arg __attribute__((unused)))
|
||||||
{
|
{
|
||||||
|
|
||||||
static const enum batadv_nl_attrs mandatory[] = {
|
static const enum batadv_nl_attrs mandatory[] = {
|
||||||
@ -460,7 +460,7 @@ static int parse_originator(struct nl_msg *msg,
|
|||||||
return NL_OK;
|
return NL_OK;
|
||||||
|
|
||||||
if (nla_parse(attrs, BATADV_ATTR_MAX, genlmsg_attrdata(ghdr, 0),
|
if (nla_parse(attrs, BATADV_ATTR_MAX, genlmsg_attrdata(ghdr, 0),
|
||||||
genlmsg_len(ghdr), batadv_genl_policy)) {
|
genlmsg_len(ghdr), batadv_genl_policy)) {
|
||||||
return NL_OK;
|
return NL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,7 +481,7 @@ static int parse_originator(struct nl_msg *msg,
|
|||||||
return NL_OK;
|
return NL_OK;
|
||||||
|
|
||||||
DEBUG_MSG("Found TQ for router " F_MAC " (originator " F_MAC "), it's %d",
|
DEBUG_MSG("Found TQ for router " F_MAC " (originator " F_MAC "), it's %d",
|
||||||
F_MAC_VAR(router->src), F_MAC_VAR(router->originator), tq);
|
F_MAC_VAR(router->src), F_MAC_VAR(router->originator), tq);
|
||||||
router->tq = tq;
|
router->tq = tq;
|
||||||
if (router->tq > G.max_tq)
|
if (router->tq > G.max_tq)
|
||||||
G.max_tq = router->tq;
|
G.max_tq = router->tq;
|
||||||
@ -490,7 +490,7 @@ static int parse_originator(struct nl_msg *msg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int parse_tt_local(struct nl_msg *msg,
|
static int parse_tt_local(struct nl_msg *msg,
|
||||||
void *arg __attribute__((unused)))
|
void *arg __attribute__((unused)))
|
||||||
{
|
{
|
||||||
static const enum batadv_nl_attrs mandatory[] = {
|
static const enum batadv_nl_attrs mandatory[] = {
|
||||||
BATADV_ATTR_TT_ADDRESS,
|
BATADV_ATTR_TT_ADDRESS,
|
||||||
@ -512,7 +512,7 @@ static int parse_tt_local(struct nl_msg *msg,
|
|||||||
return NL_OK;
|
return NL_OK;
|
||||||
|
|
||||||
if (nla_parse(attrs, BATADV_ATTR_MAX, genlmsg_attrdata(ghdr, 0),
|
if (nla_parse(attrs, BATADV_ATTR_MAX, genlmsg_attrdata(ghdr, 0),
|
||||||
genlmsg_len(ghdr), batadv_genl_policy)) {
|
genlmsg_len(ghdr), batadv_genl_policy)) {
|
||||||
return NL_OK;
|
return NL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -528,7 +528,7 @@ static int parse_tt_local(struct nl_msg *msg,
|
|||||||
return NL_OK;
|
return NL_OK;
|
||||||
|
|
||||||
DEBUG_MSG("Found router " F_MAC " in transtable_local, assigning TQ %d",
|
DEBUG_MSG("Found router " F_MAC " in transtable_local, assigning TQ %d",
|
||||||
F_MAC_VAR(router->src), LOCAL_TQ);
|
F_MAC_VAR(router->src), LOCAL_TQ);
|
||||||
router->tq = LOCAL_TQ;
|
router->tq = LOCAL_TQ;
|
||||||
if (router->tq > G.max_tq)
|
if (router->tq > G.max_tq)
|
||||||
G.max_tq = router->tq;
|
G.max_tq = router->tq;
|
||||||
@ -770,7 +770,7 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
if (G.routers != NULL &&
|
if (G.routers != NULL &&
|
||||||
timespec_diff(&now, &next_update, &diff)) {
|
timespec_diff(&now, &next_update, &diff)) {
|
||||||
expire_routers();
|
expire_routers();
|
||||||
|
|
||||||
// all routers could have expired, check again
|
// all routers could have expired, check again
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
&(var).ether_addr_octet[2], &(var).ether_addr_octet[3], \
|
&(var).ether_addr_octet[2], &(var).ether_addr_octet[3], \
|
||||||
&(var).ether_addr_octet[4], &(var).ether_addr_octet[5]
|
&(var).ether_addr_octet[4], &(var).ether_addr_octet[5]
|
||||||
#define MAC2ETHER(_ether, _mac) memcpy((_ether).ether_addr_octet, \
|
#define MAC2ETHER(_ether, _mac) memcpy((_ether).ether_addr_octet, \
|
||||||
(_mac), ETH_ALEN)
|
(_mac), ETH_ALEN)
|
||||||
|
|
||||||
#define ether_addr_equal(_a, _b) (memcmp((_a).ether_addr_octet, \
|
#define ether_addr_equal(_a, _b) (memcmp((_a).ether_addr_octet, \
|
||||||
(_b).ether_addr_octet, ETH_ALEN) == 0)
|
(_b).ether_addr_octet, ETH_ALEN) == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user