From: Sven Eckelmann <sven@narfation.org>
To: noahbpeterson1997@gmail.com
Cc: b.a.t.m.a.n@lists.open-mesh.org
Subject: Re: [PATCH] alfred: add more verbose error message
Date: Mon, 09 Sep 2024 11:18:55 +0200 [thread overview]
Message-ID: <4948861.31r3eYUQgx@ripper> (raw)
In-Reply-To: <172582836553.965.8382120135752040068@diktynna.open-mesh.org>
[-- Attachment #1: Type: text/plain, Size: 2053 bytes --]
On Sunday, 8 September 2024 22:46:05 CEST noahbpeterson1997@gmail.com wrote:
> diff --git a/netsock.c b/netsock.c
> index feed21d..04f95c7 100644
> --- a/netsock.c
> +++ b/netsock.c
> @@ -322,7 +322,23 @@ static int netsock_open(struct globals *globals, struct interface *interface)
> enable_raw_bind_capability(0);
>
> if (bind(sock, (struct sockaddr *)&sin6, sizeof(sin6)) < 0) {
> - perror("can't bind");
> + if (errno == EADDRNOTAVAIL)
> + fprintf(stderr, "can't bind to interface %s; "
> + "expected ipv6 address not found: "
> + "%02x%02x::%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
> + interface->interface,
> + (int)interface->address.ipv6.s6_addr[0],
> + (int)interface->address.ipv6.s6_addr[1],
> + (int)interface->address.ipv6.s6_addr[8],
> + (int)interface->address.ipv6.s6_addr[9],
> + (int)interface->address.ipv6.s6_addr[10],
> + (int)interface->address.ipv6.s6_addr[11],
> + (int)interface->address.ipv6.s6_addr[12],
> + (int)interface->address.ipv6.s6_addr[13],
> + (int)interface->address.ipv6.s6_addr[14],
> + (int)interface->address.ipv6.s6_addr[15]);
> + else
> + perror("can't bind");
> goto err;
> }
Ehrm, no - this is not a valid way to print IPv6 addresses and it makes to
many assumptions about the IPv6 address - which will then lead to more
problems in the future. For creating the ip address string:
char ipstr_buf[INET6_ADDRSTRLEN];
const char *ipstr;
....
ipstr = inet_ntop(AF_INET6, &interface->address.ipv6.s6_addr,
ipstr_buf, INET6_ADDRSTRLEN);
Kind regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
prev parent reply other threads:[~2024-09-09 9:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-08 20:46 [PATCH] alfred: add more verbose error message noahbpeterson1997
2024-09-09 9:18 ` Sven Eckelmann [this message]
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=4948861.31r3eYUQgx@ripper \
--to=sven@narfation.org \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
--cc=noahbpeterson1997@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.