From: Vlad S. <ser...@us...> - 2005-06-27 00:01:31
|
Update of /cvsroot/naviserver/modules/nsdns In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1088 Modified Files: ChangeLog dns.c Log Message: now works on Sun Index: dns.c =================================================================== RCS file: /cvsroot/naviserver/modules/nsdns/dns.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** dns.c 24 Jun 2005 00:52:01 -0000 1.11 --- dns.c 27 Jun 2005 00:01:23 -0000 1.12 *************** *** 769,772 **** --- 769,774 ---- { int offset; + unsigned long ul; + unsigned short us; char name[256] = ""; dnsRecord *y; *************** *** 786,790 **** goto err; } ! y->type = ntohs(*((unsigned short*)pkt->buf.ptr)); pkt->buf.ptr += 2; // The class type --- 788,793 ---- goto err; } ! memcpy(&us,pkt->buf.ptr,sizeof(us)); ! y->type = ntohs(us); pkt->buf.ptr += 2; // The class type *************** *** 793,797 **** goto err; } ! y->class = ntohs(*((unsigned short*)pkt->buf.ptr)); pkt->buf.ptr += 2; // Query block stops here --- 796,801 ---- goto err; } ! memcpy(&us,pkt->buf.ptr,sizeof(us)); ! y->class = ntohs(us); pkt->buf.ptr += 2; // Query block stops here *************** *** 802,806 **** goto err; } ! y->ttl = ntohl(*((unsigned long*)pkt->buf.ptr)); pkt->buf.ptr += 4; // Fetch the resource data. --- 806,811 ---- goto err; } ! memcpy(&ul,pkt->buf.ptr,sizeof(ul)); ! y->ttl = ntohl(ul); pkt->buf.ptr += 4; // Fetch the resource data. *************** *** 809,813 **** goto err; } ! if(!(y->len = ntohs(*((unsigned short*)pkt->buf.ptr)))) { strcpy(name,"empty data len"); goto err; --- 814,819 ---- goto err; } ! memcpy(&us,pkt->buf.ptr,sizeof(us)); ! if(!(y->len = ntohs(us))) { strcpy(name,"empty data len"); goto err; *************** *** 825,829 **** case DNS_TYPE_MX: y->data.soa = ns_calloc(1,sizeof(dnsSOA)); ! y->data.mx->preference = ntohs(*((unsigned short*)pkt->buf.ptr)); pkt->buf.ptr += 2; if(dnsParseName(pkt,&pkt->buf.ptr,name,255,0,0) < 0) goto err; --- 831,836 ---- case DNS_TYPE_MX: y->data.soa = ns_calloc(1,sizeof(dnsSOA)); ! memcpy(&us,pkt->buf.ptr,sizeof(us)); ! y->data.mx->preference = ntohs(us); pkt->buf.ptr += 2; if(dnsParseName(pkt,&pkt->buf.ptr,name,255,0,0) < 0) goto err; *************** *** 839,845 **** case DNS_TYPE_NAPTR: y->data.naptr = ns_calloc(1,sizeof(dnsNAPTR)); ! y->data.naptr->order = ntohs(*((unsigned short*)pkt->buf.ptr)); pkt->buf.ptr += 2; ! y->data.mx->preference = ntohs(*((unsigned short*)pkt->buf.ptr)); pkt->buf.ptr += 2; /* flags */ --- 846,854 ---- case DNS_TYPE_NAPTR: y->data.naptr = ns_calloc(1,sizeof(dnsNAPTR)); ! memcpy(&us,pkt->buf.ptr,sizeof(us)); ! y->data.naptr->order = ntohs(us); pkt->buf.ptr += 2; ! memcpy(&us,pkt->buf.ptr,sizeof(us)); ! y->data.mx->preference = ntohs(us); pkt->buf.ptr += 2; /* flags */ *************** *** 874,886 **** goto err; } ! y->data.soa->serial = ntohl(*((unsigned long*)pkt->buf.ptr)); pkt->buf.ptr += 4; ! y->data.soa->refresh = ntohl(*((unsigned long*)pkt->buf.ptr)); pkt->buf.ptr += 4; ! y->data.soa->retry = ntohl(*((unsigned long*)pkt->buf.ptr)); pkt->buf.ptr += 4; ! y->data.soa->expire = ntohl(*((unsigned long*)pkt->buf.ptr)); pkt->buf.ptr += 4; ! y->data.soa->ttl = ntohl(*((unsigned long*)pkt->buf.ptr)); pkt->buf.ptr += 4; } --- 883,900 ---- goto err; } ! memcpy(&ul,pkt->buf.ptr,sizeof(ul)); ! y->data.soa->serial = ntohl(ul); pkt->buf.ptr += 4; ! memcpy(&ul,pkt->buf.ptr,sizeof(ul)); ! y->data.soa->refresh = ntohl(ul); pkt->buf.ptr += 4; ! memcpy(&ul,pkt->buf.ptr,sizeof(ul)); ! y->data.soa->retry = ntohl(ul); pkt->buf.ptr += 4; ! memcpy(&ul,pkt->buf.ptr,sizeof(ul)); ! y->data.soa->expire = ntohl(ul); pkt->buf.ptr += 4; ! memcpy(&ul,pkt->buf.ptr,sizeof(ul)); ! y->data.soa->ttl = ntohl(ul); pkt->buf.ptr += 4; } *************** *** 989,993 **** dnsEncodeShort(dnsPacket *pkt,int num) { ! *((unsigned short*)pkt->buf.ptr) = htons((unsigned short)num); pkt->buf.ptr += 2; } --- 1003,1008 ---- dnsEncodeShort(dnsPacket *pkt,int num) { ! unsigned short us = htons((unsigned short)num); ! memcpy(pkt->buf.ptr,&us,sizeof(us)); pkt->buf.ptr += 2; } *************** *** 996,1000 **** dnsEncodeLong(dnsPacket *pkt,unsigned long num) { ! *((unsigned long*)pkt->buf.ptr) = htonl((unsigned long)num); pkt->buf.ptr += 4; } --- 1011,1016 ---- dnsEncodeLong(dnsPacket *pkt,unsigned long num) { ! unsigned long ul = htonl((unsigned long)num); ! memcpy(pkt->buf.ptr,&ul,sizeof(ul)); pkt->buf.ptr += 4; } *************** *** 1011,1016 **** { int len = str ? strlen(str) : 0; ! *((unsigned short*)pkt->buf.ptr) = len; ! pkt->buf.ptr++; if(len) { memcpy(pkt->buf.ptr,str,(unsigned)len); --- 1027,1031 ---- { int len = str ? strlen(str) : 0; ! *pkt->buf.ptr++ = len; if(len) { memcpy(pkt->buf.ptr,str,(unsigned)len); *************** *** 1030,1035 **** dnsEncodeEnd(dnsPacket *pkt) { ! unsigned short len = pkt->buf.ptr - pkt->buf.rec; ! *((unsigned short*)pkt->buf.rec) = htons(len - 2); } --- 1045,1050 ---- dnsEncodeEnd(dnsPacket *pkt) { ! unsigned short us = htons(pkt->buf.ptr - pkt->buf.rec - 2); ! memcpy(pkt->buf.rec,&us,sizeof(us)); } Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/modules/nsdns/ChangeLog,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ChangeLog 23 Jun 2005 02:06:02 -0000 1.5 --- ChangeLog 27 Jun 2005 00:01:22 -0000 1.6 *************** *** 1,2 **** --- 1,6 ---- + 2005-06-26 Vlad Seryakov vl...@cr... + + * updated packet parsing to work on Sparc + 2005-06-22 Vlad Seryakov vl...@cr... |