Change prints to debug (#1168)

This commit is contained in:
Ryan Mulder
2025-12-03 11:59:30 -05:00
committed by GitHub
parent b1c9d013ef
commit 0fd814867d
10 changed files with 59 additions and 60 deletions
+15 -15
View File
@@ -67,7 +67,7 @@ static void debug_print_ipv4(
const unsigned int count)
{
if (BIP_Debug) {
fprintf(
debug_fprintf(
stderr, "BIP: %s %s:%hu (%u bytes)\n", str, inet_ntoa(*addr),
ntohs(port), count);
fflush(stderr);
@@ -301,7 +301,7 @@ int bip_send_mpdu(
/* assumes that the driver has already been initialized */
if (BIP_Socket < 0) {
if (BIP_Debug) {
fprintf(stderr, "BIP: driver not initialized!\n");
debug_fprintf(stderr, "BIP: driver not initialized!\n");
fflush(stderr);
}
return BIP_Socket;
@@ -423,7 +423,7 @@ uint16_t bip_receive(
}
} else {
if (BIP_Debug) {
fprintf(stderr, "BIP: NPDU dropped!\n");
debug_fprintf(stderr, "BIP: NPDU dropped!\n");
fflush(stderr);
}
npdu_len = 0;
@@ -613,20 +613,20 @@ static void printRoute(struct route_info *rtInfo)
{
if (BIP_Debug) {
/* Print Destination address */
fprintf(
debug_fprintf(
stderr, "%s\t",
rtInfo->dstAddr ? ntoa(rtInfo->dstAddr) : "0.0.0.0 ");
/* Print Gateway address */
fprintf(
debug_fprintf(
stderr, "%s\t",
rtInfo->gateWay ? ntoa(rtInfo->gateWay) : "*.*.*.*");
/* Print Interface Name */
fprintf(stderr, "%s\t", rtInfo->ifName);
debug_fprintf(stderr, "%s\t", rtInfo->ifName);
/* Print Source address */
fprintf(
debug_fprintf(
stderr, "%s\n",
rtInfo->srcAddr ? ntoa(rtInfo->srcAddr) : "*.*.*.*");
}
@@ -707,19 +707,19 @@ static char *ifname_default(void)
/* Send the request */
if (send(sock, nlMsg, nlMsg->nlmsg_len, 0) < 0) {
fprintf(stderr, "BIP: Write To Socket Failed...\n");
debug_fprintf(stderr, "BIP: Write To Socket Failed...\n");
return BIP_Interface_Name;
}
/* Read the response */
if ((len = readNlSock(sock, msgBuf, sizeof(msgBuf), msgSeq, getpid())) <
0) {
fprintf(stderr, "BIP: Read From Socket Failed...\n");
debug_fprintf(stderr, "BIP: Read From Socket Failed...\n");
return BIP_Interface_Name;
}
/* Parse and print the response */
rtInfo = (struct route_info *)malloc(sizeof(struct route_info));
if (BIP_Debug) {
fprintf(stderr, "Destination\tGateway\tInterface\tSource\n");
debug_fprintf(stderr, "Destination\tGateway\tInterface\tSource\n");
}
for (; NLMSG_OK(nlMsg, len); nlMsg = NLMSG_NEXT(nlMsg, len)) {
memset(rtInfo, 0, sizeof(struct route_info));
@@ -790,8 +790,8 @@ void bip_set_interface(const char *ifname)
}
BIP_Address.s_addr = local_address.s_addr;
if (BIP_Debug) {
fprintf(stderr, "BIP: Interface: %s\n", ifname);
fprintf(stderr, "BIP: Address: %s\n", inet_ntoa(local_address));
debug_fprintf(stderr, "BIP: Interface: %s\n", ifname);
debug_fprintf(stderr, "BIP: Address: %s\n", inet_ntoa(local_address));
fflush(stderr);
}
/* cache interface netmask */
@@ -833,10 +833,10 @@ void bip_set_interface(const char *ifname)
}
#endif
if (BIP_Debug) {
fprintf(
debug_fprintf(
stderr, "BIP: Broadcast Address: %s\n",
inet_ntoa(BIP_Broadcast_Addr));
fprintf(
debug_fprintf(
stderr, "BIP: UDP Port: 0x%04X [%hu]\n", ntohs(BIP_Port),
ntohs(BIP_Port));
fflush(stderr);
@@ -926,7 +926,7 @@ bool bip_init(char *ifname)
bip_set_interface(ifname_default());
}
if (BIP_Address.s_addr == 0) {
fprintf(
debug_fprintf(
stderr, "BIP: Failed to get an IP address from %s!\n",
BIP_Interface_Name);
fflush(stderr);