[Shadowirc-commits] CVS: shadowirc/src ApplBase.c,1.79,1.80 TCP.h,1.6,1.7 IRCInput.c,1.27,1.28 plugi
Status: Alpha
Brought to you by:
dshadow
From: Sean M. <smc...@us...> - 2003-06-23 08:23:19
|
Update of /cvsroot/shadowirc/shadowirc/src In directory sc8-pr-cvs1:/tmp/cvs-serv16732 Modified Files: ApplBase.c TCP.h IRCInput.c plugins.h Log Message: start widening structures to accept IPv6 addresses. Index: ApplBase.c =================================================================== RCS file: /cvsroot/shadowirc/shadowirc/src/ApplBase.c,v retrieving revision 1.79 retrieving revision 1.80 diff -u -d -r1.79 -r1.80 --- ApplBase.c 27 Apr 2003 05:30:21 -0000 1.79 +++ ApplBase.c 23 Jun 2003 08:23:15 -0000 1.80 @@ -51,6 +51,7 @@ #include "InetConfig.h" #include "MenuCommands.h" #include "Events.h" +#include "utils.h" #include "ApplBase.h" static void doTCPEvent(CEPtr message); @@ -439,12 +440,16 @@ connectionEventRecord connEvt; int x = -8; + connEvt.sas = safe_malloc(sizeof(struct sockaddr_storage)); + while(GetConnectionEvent(&connEvt)) { doTCPEvent(&connEvt); if(!++x) break; } + + free(connEvt.sas); } static void InitTimers() @@ -603,7 +608,7 @@ switch(c->event) { case C_Found: - memcpy(&conn->ip, &c->addr, sizeof(conn->ip)); + memcpy(&conn->ip, &((struct sockaddr_in *)c->sas)->sin_addr, sizeof(conn->ip)); DisplayLookupResult(conn); /* * The socket connect() can fail, even when non-blocking @@ -616,7 +621,7 @@ break; case C_Established: - memcpy(&conn->ip, &c->addr, sizeof(conn->ip)); + memcpy(&conn->ip, &((struct sockaddr_in *)c->sas)->sin_addr, sizeof(conn->ip)); break; } Index: TCP.h =================================================================== RCS file: /cvsroot/shadowirc/shadowirc/src/TCP.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- TCP.h 21 Jun 2003 09:18:59 -0000 1.6 +++ TCP.h 23 Jun 2003 08:23:15 -0000 1.7 @@ -57,10 +57,10 @@ /* * XXX landonf: The "const" long "value" is used to pass back a pointer * to a pascal string (hostname). It also was used to pass back the IP address. - * addr will hold the IP address instead + * sas will hold the IP address instead */ CONST long value; - struct in_addr addr; + struct sockaddr_storage *sas; } connectionEventRecord, *CEPtr; #undef CONST Index: IRCInput.c =================================================================== RCS file: /cvsroot/shadowirc/shadowirc/src/IRCInput.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- IRCInput.c 2 Nov 2002 15:34:32 -0000 1.27 +++ IRCInput.c 23 Jun 2003 08:23:15 -0000 1.28 @@ -1,6 +1,6 @@ /* ShadowIRC - A Mac OS IRC Client - Copyright (C) 1996-2002 John Bafford + Copyright (C) 1996-2003 John Bafford ds...@sh... http://www.shadowirc.com @@ -928,10 +928,10 @@ void dnsEvent(CEPtr c, connectionPtr conn) { - Str255 s2; LongString ls; - struct in_addr ip; - Str255 name; + struct sockaddr_storage sas; + Str255 s2, name; + char hbuf[NI_MAXHOST]; pDNSLookupData p; DNSLookupDataPtr dldp; @@ -939,7 +939,7 @@ { case C_Found: p.successful=1; - memcpy(&ip, &c->addr, sizeof(ip)); + memcpy(&sas, c->sas, sizeof(struct sockaddr_storage)); pstrcpy(*(StringHandle)(c->value), name); DisposeHandle((Handle)c->value); *(long*)&c->value = 0; //const-cast @@ -952,15 +952,16 @@ if(conn->pluginRef) // then it's a plugin //conn->refCon && (dldp->magic!='SIRC')) //saving data { p.refCon=(long)conn->refCon; - memcpy(&p.ip, &ip, sizeof(p.ip)); + p.sas = safe_malloc(sizeof(struct sockaddr_storage)); + memcpy(p.sas, &sas, sizeof(struct sockaddr_storage)); p.nameToIP=c->event<3; p.search=conn->name; if(p.successful) { if(p.nameToIP) { - inet_ntoa_str(ip, s2); - p.reply=s2; + getnameinfo((struct sockaddr *)&sas, sas.ss_len, hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST); + CopyCStringToPascal(hbuf, p.reply); } else p.reply=name; @@ -972,6 +973,8 @@ } if(conn->pluginRef) runIndPlugin(conn->pluginRef, pDNSLookupMessage, &p); + + free(p.sas); } else { @@ -988,8 +991,10 @@ { if(conn->connType==connDNSIP) { - inet_ntoa_str(ip, s2); - LSConcatLSAndStr(&ls,s2,&ls); + char pstr[NI_MAXHOST]; + getnameinfo((struct sockaddr *)&sas, sas.ss_len, hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST); + CopyCStringToPascal(hbuf, pstr); + LSConcatLSAndStr(&ls,pstr,&ls); } else LSConcatLSAndStr(&ls,name,&ls); Index: plugins.h =================================================================== RCS file: /cvsroot/shadowirc/shadowirc/src/plugins.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- plugins.h 2 May 2003 19:07:26 -0000 1.24 +++ plugins.h 23 Jun 2003 08:23:15 -0000 1.25 @@ -875,7 +875,7 @@ */ typedef struct pDNSLookupData { long refCon; //The number you passed to DNSLookup() - struct in_addr ip; + struct sockaddr_storage *sas; StringPtr search; StringPtr reply; char nameToIP; |