diff options
author | David Timber <mieabby@gmail.com> | 2020-08-17 18:16:49 +0930 |
---|---|---|
committer | David Timber <mieabby@gmail.com> | 2020-08-17 18:35:31 +0930 |
commit | 7bd3eb3b1ad4209ac4cf4b46f849213d46bc33aa (patch) | |
tree | 0e7a16fb3d36ada8a2a494f8dc063e8b67350d58 /src/proone-ipaddr-arr.c | |
parent | d7cc11191dfd3fead5e596fcbc24f40d1317819e (diff) |
Employ pthsem ...
* Use uint8_t array for hardcoded binary data
* Add proone-ipaddr-arr to hardcode DoT servers
* Convert X509 data
* Brought back M68k and ARC archs just in case
* Add CLOCK_REALTIME in prne_mbedtls_entropy_proc_src_f for more entropy
* Remove installation of signal handlers. Use sigwait() instead
* Bugfix: prne_rnd_anum_str() returned null characters
* Add prne_dbgpf() and prne_dbgperr()
* prne_assert(): put errno into a register so it's visible in the core dump
Diffstat (limited to 'src/proone-ipaddr-arr.c')
-rw-r--r-- | src/proone-ipaddr-arr.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/proone-ipaddr-arr.c b/src/proone-ipaddr-arr.c new file mode 100644 index 0000000..ae8e7bd --- /dev/null +++ b/src/proone-ipaddr-arr.c @@ -0,0 +1,45 @@ +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> + +#include <arpa/inet.h> +#include <regex.h> + + +int main (const int argc, const char **args) { + static const int AF[2] = { AF_INET, AF_INET6 }; + char buf[512]; + uint8_t addr[16]; + size_t i; + regex_t re_trim; + regmatch_t rm[2]; + + assert(regcomp(&re_trim, "(\\S+)", REG_EXTENDED) == 0); + + while (fgets(buf, sizeof(buf), stdin) != NULL) { + if (regexec(&re_trim, buf, 2, rm, 0) != 0) { + goto CYCLE; + } + assert(rm[1].rm_so >= 0 && rm[1].rm_eo >= 0); + buf[rm[1].rm_eo] = 0; + + for (i = 0; i < 2; i += 1) { + memset(addr, 0, sizeof(addr)); + + if (inet_pton(AF[i], buf + rm[1].rm_so, addr) != 0) { + printf("{ 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x }", + addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], addr[6], addr[7], addr[8], addr[9], addr[10], addr[11], addr[12], addr[13], addr[14], addr[15]); + break; + } + } + +CYCLE: + printf("\n"); + } + + regfree(&re_trim); + + return 0; +} |