summaryrefslogtreecommitdiff
path: root/src/libexec
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexec')
-rw-r--r--src/libexec/sockip.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libexec/sockip.c b/src/libexec/sockip.c
new file mode 100644
index 0000000..542a88d
--- /dev/null
+++ b/src/libexec/sockip.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <netinet/in.h>
+
+int main(int argc,char *argv[]) {
+ struct sockaddr_in6 sa6;
+ unsigned int sl=sizeof(sa6);
+ char h[NI_MAXHOST], s[NI_MAXSERV];
+ if(getsockname(0,(struct sockaddr *)&sa6,&sl) == -1) return 1;
+ if(getnameinfo((struct sockaddr *)&sa6,sl,h,sizeof(h),s,sizeof(s),NI_NUMERICHOST|NI_NUMERICSERV)) return 2;
+ puts(h);
+ puts(s);
+ return 0;
+}