socklen_t compatibility cruft.
This commit is contained in:
parent
d6ae7e2265
commit
24ef5b3bfc
6
Makefile
6
Makefile
@ -94,7 +94,7 @@ haven2i.h:
|
||||
|
||||
havesl.h:
|
||||
-rm -f $@
|
||||
if $(DIET) $(CC) -o t trysl.c >/dev/null 2>&1; then echo "#define HAVE_SOCKLEN_T"; fi > $@
|
||||
if ! $(DIET) $(CC) -o t trysl.c >/dev/null 2>&1; then echo "typedef int socklen_t;"; fi > $@
|
||||
-rm -f t
|
||||
|
||||
haveinline.h:
|
||||
@ -108,6 +108,8 @@ socket_remote6.o socket_send6.o socket_tcp6.o socket_udp6.o: haveip6.h
|
||||
|
||||
socket_getifidx.o socket_getifname.o: haven2i.h
|
||||
|
||||
socket_connected.o: havesl.h
|
||||
socket_accept4.o socket_accept6.o socket_connected.o socket_local4.o \
|
||||
socket_local6.o socket_recv4.o socket_recv6.o socket_remote4.o \
|
||||
socket_remote6.o: havesl.h
|
||||
|
||||
fmt_xlong.o scan_xlong.o fmt_ip6_flat.o: haveinline.h
|
||||
|
@ -2,10 +2,11 @@
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include "socket.h"
|
||||
#include "havesl.h"
|
||||
|
||||
int socket_accept4(int s,char *ip,uint16 *port) {
|
||||
struct sockaddr_in si;
|
||||
unsigned int len = sizeof si;
|
||||
socklen_t len = sizeof si;
|
||||
int fd;
|
||||
if ((fd=accept(s,(struct sockaddr*) &si,&len))<0) return -1;
|
||||
*(uint32*)ip = *(uint32*)&si.sin_addr;
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "socket.h"
|
||||
#include "ip6.h"
|
||||
#include "haveip6.h"
|
||||
#include "havesl.h"
|
||||
|
||||
int socket_accept6(int s,char ip[16],uint16 *port,uint32 *scope_id)
|
||||
{
|
||||
@ -14,7 +15,7 @@ int socket_accept6(int s,char ip[16],uint16 *port,uint32 *scope_id)
|
||||
#else
|
||||
struct sockaddr_in sa;
|
||||
#endif
|
||||
unsigned int dummy = sizeof sa;
|
||||
socklen_t dummy = sizeof sa;
|
||||
int fd;
|
||||
|
||||
fd = accept(s,(struct sockaddr *) &sa,&dummy);
|
||||
|
@ -6,11 +6,7 @@
|
||||
|
||||
int socket_connected(int s) {
|
||||
struct sockaddr si;
|
||||
#ifdef HAVE_SOCKLEN_T
|
||||
socklen_t sl=sizeof si;
|
||||
#else
|
||||
int sl=sizeof si;
|
||||
#endif
|
||||
if (getpeername(s,&si,&sl))
|
||||
return 0;
|
||||
return 1;
|
||||
|
@ -4,11 +4,12 @@
|
||||
#include <netinet/in.h>
|
||||
#include "byte.h"
|
||||
#include "socket.h"
|
||||
#include "havesl.h"
|
||||
|
||||
int socket_local4(int s,char ip[4],uint16 *port)
|
||||
{
|
||||
struct sockaddr_in si;
|
||||
unsigned int len = sizeof si;
|
||||
socklen_t len = sizeof si;
|
||||
|
||||
if (getsockname(s,(struct sockaddr *) &si,&len) == -1) return -1;
|
||||
*(uint32*)ip = *(uint32*)&si.sin_addr;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "ip6.h"
|
||||
#include "haveip6.h"
|
||||
#include "uint32.h"
|
||||
#include "havesl.h"
|
||||
|
||||
int socket_local6(int s,char ip[16],uint16 *port,uint32 *scope_id)
|
||||
{
|
||||
@ -15,7 +16,7 @@ int socket_local6(int s,char ip[16],uint16 *port,uint32 *scope_id)
|
||||
#else
|
||||
struct sockaddr_in si;
|
||||
#endif
|
||||
unsigned int len = sizeof si;
|
||||
socklen_t len = sizeof si;
|
||||
|
||||
if (getsockname(s,(struct sockaddr *) &si,&len) == -1) return -1;
|
||||
#ifdef LIBC_HAS_IP6
|
||||
|
@ -3,10 +3,11 @@
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include "socket.h"
|
||||
#include "havesl.h"
|
||||
|
||||
int socket_recv4(int s,char *buf,unsigned int len,char ip[4],uint16 *port) {
|
||||
struct sockaddr_in si;
|
||||
unsigned int Len = sizeof si;
|
||||
socklen_t Len = sizeof si;
|
||||
int r;
|
||||
|
||||
if ((r = recvfrom(s,buf,len,0,(struct sockaddr *) &si,&Len))<0) return -1;
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "socket.h"
|
||||
#include "ip6.h"
|
||||
#include "haveip6.h"
|
||||
#include "havesl.h"
|
||||
|
||||
int socket_recv6(int s,char *buf,unsigned int len,char ip[16],uint16 *port,uint32 *scope_id)
|
||||
{
|
||||
@ -14,7 +15,7 @@ int socket_recv6(int s,char *buf,unsigned int len,char ip[16],uint16 *port,uint3
|
||||
#else
|
||||
struct sockaddr_in si;
|
||||
#endif
|
||||
unsigned int Len = sizeof si;
|
||||
socklen_t Len = sizeof si;
|
||||
int r;
|
||||
|
||||
byte_zero(&si,Len);
|
||||
|
@ -4,11 +4,12 @@
|
||||
#include <netinet/in.h>
|
||||
#include "byte.h"
|
||||
#include "socket.h"
|
||||
#include "havesl.h"
|
||||
|
||||
int socket_remote4(int s,char ip[4],uint16 *port)
|
||||
{
|
||||
struct sockaddr_in si;
|
||||
unsigned int len = sizeof si;
|
||||
socklen_t len = sizeof si;
|
||||
|
||||
if (getpeername(s,(struct sockaddr *) &si,&len) == -1) return -1;
|
||||
*(uint32*)ip = *(uint32*)&si.sin_addr;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "ip6.h"
|
||||
#include "haveip6.h"
|
||||
#include "uint32.h"
|
||||
#include "havesl.h"
|
||||
|
||||
int socket_remote6(int s,char ip[16],uint16 *port,uint32 *scope_id)
|
||||
{
|
||||
@ -15,7 +16,7 @@ int socket_remote6(int s,char ip[16],uint16 *port,uint32 *scope_id)
|
||||
#else
|
||||
struct sockaddr_in si;
|
||||
#endif
|
||||
unsigned int len = sizeof si;
|
||||
socklen_t len = sizeof si;
|
||||
|
||||
if (getpeername(s,(struct sockaddr *) &si,&len) == -1) return -1;
|
||||
#ifdef LIBC_HAS_IP6
|
||||
|
Loading…
x
Reference in New Issue
Block a user