Skip to content

Commit 3d7f3bd

Browse files
patrickdk77PhirePhly
authored andcommitted
Extra logging for APRS-IS connect to show IP addr
Signed-off-by Kenneth Finnegan <[email protected]>
1 parent fa1708d commit 3d7f3bd

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

aprsis.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,14 +318,34 @@ static void aprsis_reconnect(struct aprsis *A)
318318
a->ai_protocol);
319319
errcode = errno;
320320

321-
if (A->server_socket < 0)
321+
if (A->server_socket < 0) {
322+
if (debug) printf("aprsis failed to open socket.\n");
322323
continue;
324+
}
325+
326+
if(debug) {
327+
char addrstr[INET6_ADDRSTRLEN];
328+
void *sin_ptr = NULL;
329+
switch (a->ai_family) {
330+
case AF_INET:
331+
sin_ptr = &((struct sockaddr_in *) a->ai_addr)->sin_addr;
332+
break;
333+
case AF_INET6:
334+
sin_ptr = &((struct sockaddr_in6 *) a->ai_addr)->sin6_addr;
335+
break;
336+
}
337+
inet_ntop (a->ai_family, sin_ptr, addrstr, INET6_ADDRSTRLEN);
338+
339+
printf("aprsis connection attempt IPv%d address: %s\n",
340+
(a->ai_family == PF_INET6) ? 6 : 4, addrstr);
341+
}
323342

324343
errstr = "connection failed";
325344
i = connect(A->server_socket, a->ai_addr, a->ai_addrlen);
326345
errcode = errno;
327346

328347
if (i < 0) {
348+
if (debug) printf("aprsis connection failed.\n");
329349
/* If connection fails, try next possible address */
330350
close(A->server_socket);
331351
A->server_socket = -1;

0 commit comments

Comments
 (0)