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:
|
havesl.h:
|
||||||
-rm -f $@
|
-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
|
-rm -f t
|
||||||
|
|
||||||
haveinline.h:
|
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_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
|
fmt_xlong.o scan_xlong.o fmt_ip6_flat.o: haveinline.h
|
||||||
|
@ -2,10 +2,11 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
|
#include "havesl.h"
|
||||||
|
|
||||||
int socket_accept4(int s,char *ip,uint16 *port) {
|
int socket_accept4(int s,char *ip,uint16 *port) {
|
||||||
struct sockaddr_in si;
|
struct sockaddr_in si;
|
||||||
unsigned int len = sizeof si;
|
socklen_t len = sizeof si;
|
||||||
int fd;
|
int fd;
|
||||||
if ((fd=accept(s,(struct sockaddr*) &si,&len))<0) return -1;
|
if ((fd=accept(s,(struct sockaddr*) &si,&len))<0) return -1;
|
||||||
*(uint32*)ip = *(uint32*)&si.sin_addr;
|
*(uint32*)ip = *(uint32*)&si.sin_addr;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
#include "ip6.h"
|
#include "ip6.h"
|
||||||
#include "haveip6.h"
|
#include "haveip6.h"
|
||||||
|
#include "havesl.h"
|
||||||
|
|
||||||
int socket_accept6(int s,char ip[16],uint16 *port,uint32 *scope_id)
|
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
|
#else
|
||||||
struct sockaddr_in sa;
|
struct sockaddr_in sa;
|
||||||
#endif
|
#endif
|
||||||
unsigned int dummy = sizeof sa;
|
socklen_t dummy = sizeof sa;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
fd = accept(s,(struct sockaddr *) &sa,&dummy);
|
fd = accept(s,(struct sockaddr *) &sa,&dummy);
|
||||||
|
@ -6,11 +6,7 @@
|
|||||||
|
|
||||||
int socket_connected(int s) {
|
int socket_connected(int s) {
|
||||||
struct sockaddr si;
|
struct sockaddr si;
|
||||||
#ifdef HAVE_SOCKLEN_T
|
|
||||||
socklen_t sl=sizeof si;
|
socklen_t sl=sizeof si;
|
||||||
#else
|
|
||||||
int sl=sizeof si;
|
|
||||||
#endif
|
|
||||||
if (getpeername(s,&si,&sl))
|
if (getpeername(s,&si,&sl))
|
||||||
return 0;
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include "byte.h"
|
#include "byte.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
|
#include "havesl.h"
|
||||||
|
|
||||||
int socket_local4(int s,char ip[4],uint16 *port)
|
int socket_local4(int s,char ip[4],uint16 *port)
|
||||||
{
|
{
|
||||||
struct sockaddr_in si;
|
struct sockaddr_in si;
|
||||||
unsigned int len = sizeof si;
|
socklen_t len = sizeof si;
|
||||||
|
|
||||||
if (getsockname(s,(struct sockaddr *) &si,&len) == -1) return -1;
|
if (getsockname(s,(struct sockaddr *) &si,&len) == -1) return -1;
|
||||||
*(uint32*)ip = *(uint32*)&si.sin_addr;
|
*(uint32*)ip = *(uint32*)&si.sin_addr;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "ip6.h"
|
#include "ip6.h"
|
||||||
#include "haveip6.h"
|
#include "haveip6.h"
|
||||||
#include "uint32.h"
|
#include "uint32.h"
|
||||||
|
#include "havesl.h"
|
||||||
|
|
||||||
int socket_local6(int s,char ip[16],uint16 *port,uint32 *scope_id)
|
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
|
#else
|
||||||
struct sockaddr_in si;
|
struct sockaddr_in si;
|
||||||
#endif
|
#endif
|
||||||
unsigned int len = sizeof si;
|
socklen_t len = sizeof si;
|
||||||
|
|
||||||
if (getsockname(s,(struct sockaddr *) &si,&len) == -1) return -1;
|
if (getsockname(s,(struct sockaddr *) &si,&len) == -1) return -1;
|
||||||
#ifdef LIBC_HAS_IP6
|
#ifdef LIBC_HAS_IP6
|
||||||
|
@ -3,10 +3,11 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
|
#include "havesl.h"
|
||||||
|
|
||||||
int socket_recv4(int s,char *buf,unsigned int len,char ip[4],uint16 *port) {
|
int socket_recv4(int s,char *buf,unsigned int len,char ip[4],uint16 *port) {
|
||||||
struct sockaddr_in si;
|
struct sockaddr_in si;
|
||||||
unsigned int Len = sizeof si;
|
socklen_t Len = sizeof si;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if ((r = recvfrom(s,buf,len,0,(struct sockaddr *) &si,&Len))<0) return -1;
|
if ((r = recvfrom(s,buf,len,0,(struct sockaddr *) &si,&Len))<0) return -1;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
#include "ip6.h"
|
#include "ip6.h"
|
||||||
#include "haveip6.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)
|
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
|
#else
|
||||||
struct sockaddr_in si;
|
struct sockaddr_in si;
|
||||||
#endif
|
#endif
|
||||||
unsigned int Len = sizeof si;
|
socklen_t Len = sizeof si;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
byte_zero(&si,Len);
|
byte_zero(&si,Len);
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include "byte.h"
|
#include "byte.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
|
#include "havesl.h"
|
||||||
|
|
||||||
int socket_remote4(int s,char ip[4],uint16 *port)
|
int socket_remote4(int s,char ip[4],uint16 *port)
|
||||||
{
|
{
|
||||||
struct sockaddr_in si;
|
struct sockaddr_in si;
|
||||||
unsigned int len = sizeof si;
|
socklen_t len = sizeof si;
|
||||||
|
|
||||||
if (getpeername(s,(struct sockaddr *) &si,&len) == -1) return -1;
|
if (getpeername(s,(struct sockaddr *) &si,&len) == -1) return -1;
|
||||||
*(uint32*)ip = *(uint32*)&si.sin_addr;
|
*(uint32*)ip = *(uint32*)&si.sin_addr;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "ip6.h"
|
#include "ip6.h"
|
||||||
#include "haveip6.h"
|
#include "haveip6.h"
|
||||||
#include "uint32.h"
|
#include "uint32.h"
|
||||||
|
#include "havesl.h"
|
||||||
|
|
||||||
int socket_remote6(int s,char ip[16],uint16 *port,uint32 *scope_id)
|
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
|
#else
|
||||||
struct sockaddr_in si;
|
struct sockaddr_in si;
|
||||||
#endif
|
#endif
|
||||||
unsigned int len = sizeof si;
|
socklen_t len = sizeof si;
|
||||||
|
|
||||||
if (getpeername(s,(struct sockaddr *) &si,&len) == -1) return -1;
|
if (getpeername(s,(struct sockaddr *) &si,&len) == -1) return -1;
|
||||||
#ifdef LIBC_HAS_IP6
|
#ifdef LIBC_HAS_IP6
|
||||||
|
Loading…
x
Reference in New Issue
Block a user