Changeset 33957 in vbox
- Timestamp:
- Nov 11, 2010 9:13:09 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/libalias/alias_dns.c
r33953 r33957 52 52 AssertCompileSize(union dnsmsg_header, 12); 53 53 54 struct dnsmsg_answer 55 { 56 uint16_t name; 54 struct dns_meta_data 55 { 57 56 uint16_t type; 58 57 uint16_t class; 58 }; 59 60 struct dnsmsg_answer 61 { 62 uint16_t name; 63 struct dns_meta_data meta; 59 64 uint16_t ttl[2]; 60 65 uint16_t rdata_len; … … 74 79 return -1; 75 80 76 fprintf(stderr,"NAT:%s: ah(dport: %hd, sport: %hd) oaddr:%R[IP4] aaddr:%R[IP4]\n",81 Log(("NAT:%s: ah(dport: %hd, sport: %hd) oaddr:%R[IP4] aaddr:%R[IP4]\n", 77 82 __FUNCTION__, ntohs(*ah->dport), ntohs(*ah->sport), 78 &ah->oaddr, &ah->aaddr) ;83 &ah->oaddr, &ah->aaddr)); 79 84 80 85 if ( (ntohs(*ah->dport) == DNS_CONTROL_PORT_NUMBER … … 86 91 } 87 92 88 static void doanswer(struct libalias *la, union dnsmsg_header *hdr, uint16_t qtype, uint16_t qclass, char *qname, struct ip *pip, struct hostent *h)93 static void doanswer(struct libalias *la, union dnsmsg_header *hdr, struct dns_meta_data *pReqMeta, char *qname, struct ip *pip, struct hostent *h) 89 94 { 90 95 int i; … … 106 111 uint16_t packet_len = 0; 107 112 uint16_t addr_off = (uint16_t)~0; 113 struct dns_meta_data *meta; 108 114 109 115 #if 0 … … 115 121 + sizeof(union dnsmsg_header) 116 122 + strlen(qname) 117 + 2 * sizeof(uint16_t); /* ip + udp + header + query */123 + sizeof(struct dns_meta_data); /* ip + udp + header + query */ 118 124 query = (char *)&hdr[1]; 119 125 120 126 strcpy(query, qname); 121 127 query += strlen(qname) + 1; 122 123 *(uint16_t *)query = qtype; 124 ((uint16_t *)query)[1] = qclass; 125 answers = (char *)&((uint16_t *)query)[2]; 128 /* class & type informations lay right after symbolic inforamtion. */ 129 meta = (struct dns_meta_data *)query; 130 meta->type = pReqMeta->type; 131 meta->class = pReqMeta->class; 132 133 /* answers zone lays after query in response packet */ 134 answers = (char *)&meta[1]; 126 135 127 136 off = (char *)&hdr[1] - (char *)hdr; … … 134 143 struct dnsmsg_answer *ans = (struct dnsmsg_answer *)answers; 135 144 ans->name = htons(off); 136 ans-> type = htons(5); /* CNAME */137 ans-> class = htons(1);145 ans->meta.type = htons(5); /* CNAME */ 146 ans->meta.class = htons(1); 138 147 *(uint32_t *)ans->ttl = htonl(3600); /* 1h */ 139 148 c = (addr_off == (uint16_t)~0 ? h->h_name : *cstr); … … 157 166 158 167 ans->name = htons(off); 159 ans-> type = htons(1);160 ans-> class = htons(1);168 ans->meta.type = htons(1); 169 ans->meta.class = htons(1); 161 170 *(uint32_t *)ans->ttl = htonl(3600); /* 1h */ 162 171 ans->rdata_len = htons(4); /* IPv4 */ … … 187 196 char cname[255]; 188 197 int cname_len = 0; 198 struct dns_meta_data *meta; 189 199 190 200 struct udphdr *udp = NULL; … … 201 211 if ((ntohs(hdr->X.qdcount) != 1)) 202 212 { 203 LogRel(("NAT:alias_dns: multiple quieries isn't supported\n")); 213 static bool fMultiWarn; 214 if (!fMultiWarn) 215 { 216 LogRel(("NAT:alias_dns: multiple quieries isn't supported\n")); 217 fMultiWarn = true; 218 } 204 219 return 1; 205 220 } … … 207 222 for (i = 0; i < ntohs(hdr->X.qdcount); ++i) 208 223 { 209 qw_qtype = (uint16_t *)(qw_qname + strlen(qw_qname) + 1); 210 qw_qclass = &qw_qtype[1]; 211 fprintf(stderr, "qname:%s qtype:%hd qclass:%hd\n", 212 qw_qname, ntohs(*qw_qtype), ntohs(*qw_qclass)); 224 meta = (struct dns_meta_data *)(qw_qname + strlen(qw_qname) + 1); 225 Log(("qname:%s qtype:%hd qclass:%hd\n", 226 qw_qname, ntohs(meta->type), ntohs(meta->class))); 213 227 214 228 QStr2CStr(qw_qname, cname, sizeof(cname)); … … 227 241 h = gethostbyname(cname); 228 242 fprintf(stderr, "cname:%s\n", cname); 229 doanswer(la, hdr, *qw_qtype, *qw_qclass, qw_qname, pip, h);243 doanswer(la, hdr, meta, qw_qname, pip, h); 230 244 } 231 245
Note:
See TracChangeset
for help on using the changeset viewer.