* net_defs.h, net_udp.c, net_wins.c, net_wipx.c, net_sdlnet.c: prefixed

the members of qsockaddr structure with a "q".


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@207 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Ozkan Sezer 2010-06-21 09:20:32 +00:00
parent 56d6aa3899
commit ca7aa6c733
6 changed files with 36 additions and 36 deletions

View file

@ -31,8 +31,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
struct qsockaddr struct qsockaddr
{ {
short sa_family; short qsa_family;
unsigned char sa_data[14]; unsigned char qsa_data[14];
}; };
#define NET_HEADERSIZE (2 * sizeof(unsigned int)) #define NET_HEADERSIZE (2 * sizeof(unsigned int))

View file

@ -1012,7 +1012,7 @@ static qsocket_t *_Datagram_CheckNewConnections (void)
#ifdef BAN_TEST #ifdef BAN_TEST
// check for a ban // check for a ban
if (clientaddr.sa_family == AF_INET) if (clientaddr.qsa_family == AF_INET)
{ {
unsigned long testAddr; unsigned long testAddr;
testAddr = ((struct sockaddr_in *)&clientaddr)->sin_addr.s_addr; testAddr = ((struct sockaddr_in *)&clientaddr)->sin_addr.s_addr;

View file

@ -152,8 +152,8 @@ int SDLN_Init (void)
return -1; return -1;
} }
broadcastaddr.sa_family = AF_INET; broadcastaddr.qsa_family = AF_INET;
ipaddress = (IPaddress *)&(broadcastaddr.sa_data); ipaddress = (IPaddress *)&(broadcastaddr.qsa_data);
SDLNet_Write32(INADDR_BROADCAST, &ipaddress->host); SDLNet_Write32(INADDR_BROADCAST, &ipaddress->host);
SDLNet_Write16(net_hostport, &ipaddress->port); SDLNet_Write16(net_hostport, &ipaddress->port);
@ -289,8 +289,8 @@ int SDLN_Read (int socketid, byte *buf, int len, struct qsockaddr *addr)
{ {
memcpy(buf, packet->data, packet->len); memcpy(buf, packet->data, packet->len);
addr->sa_family = AF_INET; addr->qsa_family = AF_INET;
ipaddress = (IPaddress *)&(addr->sa_data); ipaddress = (IPaddress *)&(addr->qsa_data);
ipaddress->host = packet->address.host; ipaddress->host = packet->address.host;
ipaddress->port = packet->address.port; ipaddress->port = packet->address.port;
@ -316,7 +316,7 @@ int SDLN_Write (int socketid, byte *buf, int len, struct qsockaddr *addr)
memcpy(packet->data, buf, len); memcpy(packet->data, buf, len);
packet->len = len; packet->len = len;
ipaddress = (IPaddress *)&(addr->sa_data); ipaddress = (IPaddress *)&(addr->qsa_data);
packet->address.host = ipaddress->host; packet->address.host = ipaddress->host;
packet->address.port = ipaddress->port; packet->address.port = ipaddress->port;
@ -347,7 +347,7 @@ char *SDLN_AddrToString (struct qsockaddr *addr)
int port; int port;
IPaddress *ipaddress; IPaddress *ipaddress;
ipaddress = (IPaddress *)&(addr->sa_data); ipaddress = (IPaddress *)&(addr->qsa_data);
ip = SDLNet_Read32(&ipaddress->host); ip = SDLNet_Read32(&ipaddress->host);
port = SDLNet_Read16(&ipaddress->port); port = SDLNet_Read16(&ipaddress->port);
@ -364,8 +364,8 @@ int SDLN_StringToAddr (char *string, struct qsockaddr *addr)
sscanf(string, "%d.%d.%d.%d:%d", &ha1, &ha2, &ha3, &ha4, &hp); sscanf(string, "%d.%d.%d.%d:%d", &ha1, &ha2, &ha3, &ha4, &hp);
hostaddr = (ha1 << 24) | (ha2 << 16) | (ha3 << 8) | ha4; hostaddr = (ha1 << 24) | (ha2 << 16) | (ha3 << 8) | ha4;
addr->sa_family = AF_INET; addr->qsa_family = AF_INET;
ipaddress = (IPaddress *)&(addr->sa_data); ipaddress = (IPaddress *)&(addr->qsa_data);
SDLNet_Write32(hostaddr, &ipaddress->host); SDLNet_Write32(hostaddr, &ipaddress->host);
SDLNet_Write16(hp, &ipaddress->port); SDLNet_Write16(hp, &ipaddress->port);
@ -389,8 +389,8 @@ int SDLN_GetSocketAddr (int socketid, struct qsockaddr *addr)
if (peeraddress == NULL) if (peeraddress == NULL)
return -1; return -1;
addr->sa_family = AF_INET; addr->qsa_family = AF_INET;
ipaddress = (IPaddress *) addr->sa_data; ipaddress = (IPaddress *) addr->qsa_data;
if (peeraddress->host == 0 || if (peeraddress->host == 0 ||
peeraddress->host == SDL_SwapBE32(INADDR_LOOPBACK) /* inet_addr ("127.0.0.1") */) peeraddress->host == SDL_SwapBE32(INADDR_LOOPBACK) /* inet_addr ("127.0.0.1") */)
{ {
@ -411,7 +411,7 @@ int SDLN_GetNameFromAddr (struct qsockaddr *addr, char *name)
char *buf; char *buf;
IPaddress *ipaddress; IPaddress *ipaddress;
ipaddress = (IPaddress *)&(addr->sa_data); ipaddress = (IPaddress *)&(addr->qsa_data);
buf = (char *)SDLNet_ResolveIP(ipaddress); buf = (char *)SDLNet_ResolveIP(ipaddress);
if (buf != NULL) if (buf != NULL)
@ -480,8 +480,8 @@ static int PartialIPAddress (char *in, struct qsockaddr *hostaddr)
tmp = SDLNet_Read32(&myaddr.host); tmp = SDLNet_Read32(&myaddr.host);
tmp = (tmp & mask) | addr; tmp = (tmp & mask) | addr;
hostaddr->sa_family = AF_INET; hostaddr->qsa_family = AF_INET;
ipaddress = (IPaddress *)&(hostaddr->sa_data); ipaddress = (IPaddress *)&(hostaddr->qsa_data);
SDLNet_Write32(tmp, &ipaddress->host); SDLNet_Write32(tmp, &ipaddress->host);
SDLNet_Write16(port, &ipaddress->port); SDLNet_Write16(port, &ipaddress->port);
@ -496,11 +496,11 @@ int SDLN_GetAddrFromName (char *name, struct qsockaddr *addr)
if (name[0] >= '0' && name[0] <= '9') if (name[0] >= '0' && name[0] <= '9')
return PartialIPAddress (name, addr); return PartialIPAddress (name, addr);
ipaddress = (IPaddress *)&(addr->sa_data); ipaddress = (IPaddress *)&(addr->qsa_data);
if (SDLNet_ResolveHost((IPaddress *)(&addr->sa_data), name, net_hostport) == -1) if (SDLNet_ResolveHost((IPaddress *)(&addr->qsa_data), name, net_hostport) == -1)
return -1; return -1;
addr->sa_family = AF_INET; addr->qsa_family = AF_INET;
return 0; return 0;
} }
@ -509,11 +509,11 @@ int SDLN_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2)
IPaddress *ipaddr1; IPaddress *ipaddr1;
IPaddress *ipaddr2; IPaddress *ipaddr2;
if (addr1->sa_family != addr2->sa_family) if (addr1->qsa_family != addr2->qsa_family)
return -1; return -1;
ipaddr1 = (IPaddress *)&(addr1->sa_data); ipaddr1 = (IPaddress *)&(addr1->qsa_data);
ipaddr2 = (IPaddress *)&(addr2->sa_data); ipaddr2 = (IPaddress *)&(addr2->qsa_data);
if (ipaddr1->host != ipaddr2->host) if (ipaddr1->host != ipaddr2->host)
return -1; return -1;
@ -528,7 +528,7 @@ int SDLN_GetSocketPort (struct qsockaddr *addr)
{ {
IPaddress *ipaddress; IPaddress *ipaddress;
ipaddress = (IPaddress *)&(addr->sa_data); ipaddress = (IPaddress *)&(addr->qsa_data);
return SDLNet_Read16(&ipaddress->port); return SDLNet_Read16(&ipaddress->port);
} }
@ -536,7 +536,7 @@ int SDLN_SetSocketPort (struct qsockaddr *addr, int port)
{ {
IPaddress *ipaddress; IPaddress *ipaddress;
ipaddress = (IPaddress *)&(addr->sa_data); ipaddress = (IPaddress *)&(addr->qsa_data);
SDLNet_Write16(port, &ipaddress->port); SDLNet_Write16(port, &ipaddress->port);
return 0; return 0;

View file

@ -221,7 +221,7 @@ static int PartialIPAddress (char *in, struct qsockaddr *hostaddr)
else else
port = net_hostport; port = net_hostport;
hostaddr->sa_family = AF_INET; hostaddr->qsa_family = AF_INET;
((struct sockaddr_in *)hostaddr)->sin_port = htons((unsigned short)port); ((struct sockaddr_in *)hostaddr)->sin_port = htons((unsigned short)port);
((struct sockaddr_in *)hostaddr)->sin_addr.s_addr = ((struct sockaddr_in *)hostaddr)->sin_addr.s_addr =
(myAddr & htonl(mask)) | htonl(addr); (myAddr & htonl(mask)) | htonl(addr);
@ -260,8 +260,8 @@ int UDP_CheckNewConnections (void)
static void get_qsockaddr(struct sockaddr *saddr, struct qsockaddr *qaddr) static void get_qsockaddr(struct sockaddr *saddr, struct qsockaddr *qaddr)
{ {
qaddr->sa_family = saddr->sa_family; qaddr->qsa_family = saddr->sa_family;
memcpy(&(qaddr->sa_data), &(saddr->sa_data), sizeof(qaddr->sa_data)); memcpy(&(qaddr->qsa_data), &(saddr->sa_data), sizeof(qaddr->qsa_data));
} }
int UDP_Read (int socketid, byte *buf, int len, struct qsockaddr *addr) int UDP_Read (int socketid, byte *buf, int len, struct qsockaddr *addr)
@ -348,7 +348,7 @@ int UDP_StringToAddr (char *string, struct qsockaddr *addr)
sscanf(string, "%d.%d.%d.%d:%d", &ha1, &ha2, &ha3, &ha4, &hp); sscanf(string, "%d.%d.%d.%d:%d", &ha1, &ha2, &ha3, &ha4, &hp);
ipaddr = (ha1 << 24) | (ha2 << 16) | (ha3 << 8) | ha4; ipaddr = (ha1 << 24) | (ha2 << 16) | (ha3 << 8) | ha4;
addr->sa_family = AF_INET; addr->qsa_family = AF_INET;
((struct sockaddr_in *)addr)->sin_addr.s_addr = htonl(ipaddr); ((struct sockaddr_in *)addr)->sin_addr.s_addr = htonl(ipaddr);
((struct sockaddr_in *)addr)->sin_port = htons((unsigned short)hp); ((struct sockaddr_in *)addr)->sin_port = htons((unsigned short)hp);
return 0; return 0;
@ -403,7 +403,7 @@ int UDP_GetAddrFromName(char *name, struct qsockaddr *addr)
if (!hostentry) if (!hostentry)
return -1; return -1;
addr->sa_family = AF_INET; addr->qsa_family = AF_INET;
((struct sockaddr_in *)addr)->sin_port = htons((unsigned short)net_hostport); ((struct sockaddr_in *)addr)->sin_port = htons((unsigned short)net_hostport);
((struct sockaddr_in *)addr)->sin_addr.s_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr =
*(in_addr_t *)hostentry->h_addr_list[0]; *(in_addr_t *)hostentry->h_addr_list[0];
@ -415,7 +415,7 @@ int UDP_GetAddrFromName(char *name, struct qsockaddr *addr)
int UDP_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2) int UDP_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2)
{ {
if (addr1->sa_family != addr2->sa_family) if (addr1->qsa_family != addr2->qsa_family)
return -1; return -1;
if (((struct sockaddr_in *)addr1)->sin_addr.s_addr != if (((struct sockaddr_in *)addr1)->sin_addr.s_addr !=

View file

@ -296,7 +296,7 @@ static int PartialIPAddress (char *in, struct qsockaddr *hostaddr)
else else
port = net_hostport; port = net_hostport;
hostaddr->sa_family = AF_INET; hostaddr->qsa_family = AF_INET;
((struct sockaddr_in *)hostaddr)->sin_port = htons((unsigned short)port); ((struct sockaddr_in *)hostaddr)->sin_port = htons((unsigned short)port);
((struct sockaddr_in *)hostaddr)->sin_addr.s_addr = ((struct sockaddr_in *)hostaddr)->sin_addr.s_addr =
(myAddr & htonl(mask)) | htonl(addr); (myAddr & htonl(mask)) | htonl(addr);
@ -423,7 +423,7 @@ int WINS_StringToAddr (char *string, struct qsockaddr *addr)
sscanf(string, "%d.%d.%d.%d:%d", &ha1, &ha2, &ha3, &ha4, &hp); sscanf(string, "%d.%d.%d.%d:%d", &ha1, &ha2, &ha3, &ha4, &hp);
ipaddr = (ha1 << 24) | (ha2 << 16) | (ha3 << 8) | ha4; ipaddr = (ha1 << 24) | (ha2 << 16) | (ha3 << 8) | ha4;
addr->sa_family = AF_INET; addr->qsa_family = AF_INET;
((struct sockaddr_in *)addr)->sin_addr.s_addr = htonl(ipaddr); ((struct sockaddr_in *)addr)->sin_addr.s_addr = htonl(ipaddr);
((struct sockaddr_in *)addr)->sin_port = htons((unsigned short)hp); ((struct sockaddr_in *)addr)->sin_port = htons((unsigned short)hp);
return 0; return 0;
@ -476,7 +476,7 @@ int WINS_GetAddrFromName(char *name, struct qsockaddr *addr)
if (!hostentry) if (!hostentry)
return -1; return -1;
addr->sa_family = AF_INET; addr->qsa_family = AF_INET;
((struct sockaddr_in *)addr)->sin_port = htons((unsigned short)net_hostport); ((struct sockaddr_in *)addr)->sin_port = htons((unsigned short)net_hostport);
((struct sockaddr_in *)addr)->sin_addr.s_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr =
*(u_long *)hostentry->h_addr_list[0]; *(u_long *)hostentry->h_addr_list[0];
@ -488,7 +488,7 @@ int WINS_GetAddrFromName(char *name, struct qsockaddr *addr)
int WINS_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2) int WINS_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2)
{ {
if (addr1->sa_family != addr2->sa_family) if (addr1->qsa_family != addr2->qsa_family)
return -1; return -1;
if (((struct sockaddr_in *)addr1)->sin_addr.s_addr != if (((struct sockaddr_in *)addr1)->sin_addr.s_addr !=

View file

@ -311,7 +311,7 @@ int WIPX_StringToAddr (char *string, struct qsockaddr *addr)
buf[2] = 0; buf[2] = 0;
Q_memset(addr, 0, sizeof(struct qsockaddr)); Q_memset(addr, 0, sizeof(struct qsockaddr));
addr->sa_family = AF_IPX; addr->qsa_family = AF_IPX;
#define DO(src,dest) do { \ #define DO(src,dest) do { \
buf[0] = string[src]; \ buf[0] = string[src]; \
@ -394,7 +394,7 @@ int WIPX_GetAddrFromName(char *name, struct qsockaddr *addr)
int WIPX_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2) int WIPX_AddrCompare (struct qsockaddr *addr1, struct qsockaddr *addr2)
{ {
if (addr1->sa_family != addr2->sa_family) if (addr1->qsa_family != addr2->qsa_family)
return -1; return -1;
if (*((struct sockaddr_ipx *)addr1)->sa_netnum && *((struct sockaddr_ipx *)addr2)->sa_netnum) if (*((struct sockaddr_ipx *)addr1)->sa_netnum && *((struct sockaddr_ipx *)addr2)->sa_netnum)