From: Marek Lindner <mareklindner@neomailbox.ch>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Marek Lindner <mareklindner@neomailbox.ch>
Subject: [PATCH 1/3] alfred: move interface check into helper function
Date: Wed, 12 Jan 2022 22:05:04 +0100 [thread overview]
Message-ID: <20220112210506.3488775-1-mareklindner@neomailbox.ch> (raw)
In-Reply-To: <10410848.OOsao9LFFs@rousseau>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
alfred.h | 1 +
server.c | 4 ++--
util.c | 11 +++++++++++
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/alfred.h b/alfred.h
index 0e4dd26..c595b06 100644
--- a/alfred.h
+++ b/alfred.h
@@ -204,5 +204,6 @@ int time_diff(struct timespec *tv1, struct timespec *tv2,
void time_random_seed(void);
uint16_t get_random_id(void);
bool is_valid_ether_addr(uint8_t *addr);
+bool is_iface_disabled(char *iface);
int ipv4_arp_request(struct interface *interface, const alfred_addr *addr,
struct ether_addr *mac);
diff --git a/server.c b/server.c
index 85bf453..1efc211 100644
--- a/server.c
+++ b/server.c
@@ -205,7 +205,7 @@ static void update_server_info(struct globals *globals)
if (globals->opmode == OPMODE_PRIMARY)
return;
- if (strcmp(globals->mesh_iface, "none") != 0) {
+ if (!is_iface_disabled(globals->mesh_iface)) {
tg_hash = tg_hash_new(globals->mesh_iface);
if (!tg_hash) {
fprintf(stderr, "Failed to create translation hash\n");
@@ -385,7 +385,7 @@ int alfred_server(struct globals *globals)
return -1;
}
- if (strcmp(globals->mesh_iface, "none") != 0 &&
+ if (!is_iface_disabled(globals->mesh_iface) &&
batadv_interface_check(globals->mesh_iface) < 0 &&
!globals->force) {
fprintf(stderr, "Can't start server: batman-adv interface %s not found\n",
diff --git a/util.c b/util.c
index 42a625a..eabef57 100644
--- a/util.c
+++ b/util.c
@@ -67,6 +67,17 @@ bool is_valid_ether_addr(uint8_t addr[ETH_ALEN])
return true;
}
+bool is_iface_disabled(char *iface)
+{
+ if (!iface)
+ return false;
+
+ if (strcmp(iface, "none") != 0)
+ return false;
+
+ return true;
+}
+
static void ipv4_request_mac_resolve(const alfred_addr *addr)
{
const struct sockaddr *sockaddr;
--
2.32.0.rc0
next prev parent reply other threads:[~2022-01-12 21:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-12 21:02 alfred: allow startup without network interface Marek Lindner
2022-01-12 21:05 ` Marek Lindner [this message]
2022-01-12 21:05 ` [PATCH 2/3] alfred: Allow operating without any interface specified Marek Lindner
2022-01-12 21:05 ` [PATCH 3/3] alfred: properly initialize stack buffer before sending over unix socket Marek Lindner
2022-01-21 15:34 ` Sven Eckelmann
2022-01-22 0:41 ` Marek Lindner
2022-01-22 8:03 ` Sven Eckelmann
2022-01-22 13:06 ` Marek Lindner
2022-01-12 21:11 ` alfred: allow startup without network interface Marek Lindner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220112210506.3488775-1-mareklindner@neomailbox.ch \
--to=mareklindner@neomailbox.ch \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox