summaryrefslogtreecommitdiff
path: root/ucspi-tcp-0.88/socket_local.c
diff options
context:
space:
mode:
Diffstat (limited to 'ucspi-tcp-0.88/socket_local.c')
-rw-r--r--ucspi-tcp-0.88/socket_local.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/ucspi-tcp-0.88/socket_local.c b/ucspi-tcp-0.88/socket_local.c
new file mode 100644
index 0000000..1473d91
--- /dev/null
+++ b/ucspi-tcp-0.88/socket_local.c
@@ -0,0 +1,17 @@
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include "byte.h"
+#include "socket.h"
+
+int socket_local4(int s,char ip[4],uint16 *port)
+{
+ struct sockaddr_in sa;
+ int dummy = sizeof sa;
+
+ if (getsockname(s,(struct sockaddr *) &sa,&dummy) == -1) return -1;
+ byte_copy(ip,4,(char *) &sa.sin_addr);
+ uint16_unpack_big((char *) &sa.sin_port,port);
+ return 0;
+}