troglobit / netcalc

Simplified clone of sipcalc with ipcalc looks
BSD 3-Clause "New" or "Revised" License
67 stars 12 forks source link

pipe from stdin not working reliably #7

Closed dkerr64 closed 7 years ago

dkerr64 commented 7 years ago

Piping from stdin is not working reliably. Sometimes works. Sometimes not...

netcalc 2601:186:4503:8130::1/64 works echo 2601:186:4503:8130::1/64 | netcalc - fails echo fe80::20d:b9ff:fe41:7155/64 | netcalc - works

when it fails... it does not output anything, just returns to command prompt.

Thanks David

abelbeck commented 7 years ago

@dkerr64 This appears to be a holdover from sipcalc's interface support and the size of IFNAMSIZ, which is usually 16, truncating the stdin argument. While some IPv6's seemed to work, they were not correct via stdin.

This hack makes it work.

--- a/netcalc.h 2017-02-24 10:31:18.000000000 -0600
+++ b/netcalc.h 2017-03-26 08:43:15.029904488 -0500
@@ -16,6 +16,8 @@
 #endif
 #include <err.h>       /* warnx() et al */
 #include <net/if.h>        /* IFNAMSIZ */
+#undef IFNAMSIZ
+#define IFNAMSIZ 128

 /*** Fallback to older types before stdint.h was defined ***/
 #ifndef HAVE_UINT8_T

With proper code examination, possibly I can create a PR to properly fix this.

troglobit commented 7 years ago

Yeah, I've gotten lost too many times in the old argbox code ... started refactoring the whole mess today, but PR #8 is better in all respects until I get some time again sort my refactor out.

troglobit commented 7 years ago

Merged, thanks!