Changeset 902 in MondoRescue for branches/stable/mindi-busybox/networking/dnsd.c
- Timestamp:
- Oct 25, 2006, 12:41:23 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/networking/dnsd.c
r821 r902 29 29 #define LOCK_FILE "/var/run/dnsd.lock" 30 30 #define LOG_FILE "/var/log/dnsd.log" 31 32 #define is_daemon() (flags&16) 33 #define is_verbose() (flags&32) 34 //#define DEBUG 35 31 36 32 37 enum { … … 224 229 { 225 230 int i; 226 struct dns_entry *d =dnsentry;227 228 do {231 struct dns_entry *d = dnsentry; 232 233 if(d) do { 229 234 #ifdef DEBUG 230 char *p,*q; 231 q = (char *)&(qs[1]); 232 p = &(d->name[1]); 233 fprintf(stderr, "\ntest: %d <%s> <%s> %d", strlen(p), p, q, strlen(q)); 234 #endif 235 if (type == REQ_A) { /* search by host name */ 235 if(qs && d) { 236 char *p,*q; 237 q = (char *)&(qs[1]); 238 p = &(d->name[1]); 239 fprintf(stderr, "\n%s: %d/%d p:%s q:%s %d", 240 __FUNCTION__, strlen(p), (int)(d->name[0]), 241 p, q, strlen(q)); 242 } 243 #endif 244 if (type == REQ_A) { /* search by host name */ 236 245 for(i = 1; i <= (int)(d->name[0]); i++) 237 246 if(tolower(qs[i]) != d->name[i]) 238 continue; 247 break; 248 if(i > (int)(d->name[0])) { 239 249 #ifdef DEBUG 240 fprintf(stderr, " OK");241 #endif 242 strcpy((char *)as, d->ip);250 fprintf(stderr, " OK"); 251 #endif 252 strcpy((char *)as, d->ip); 243 253 #ifdef DEBUG 244 fprintf(stderr, " %s ", as); 245 #endif 246 return 0; 247 } 248 else if (type == REQ_PTR) { /* search by IP-address */ 254 fprintf(stderr, " as:%s\n", as); 255 #endif 256 return 0; 257 } 258 } else 259 if (type == REQ_PTR) { /* search by IP-address */ 249 260 if (!strncmp((char*)&d->rip[1], (char*)&qs[1], strlen(d->rip)-1)) { 250 261 strcpy((char *)as, d->name); … … 282 293 283 294 from = (void *)&head[1]; // start of query string 284 next = answb = from + strlen((char *) &head[1]) + 1 + sizeof(struct dns_prop); // where to append answer block295 next = answb = from + strlen((char *)from) + 1 + sizeof(struct dns_prop); // where to append answer block 285 296 286 297 outr.rlen = 0; // may change later … … 306 317 307 318 // We have a standard query 308 309 log_message(LOG_FILE, (char *)head); 310 lookup_result = table_lookup(type, answstr, (uint8_t*)(&head[1])); 319 log_message(LOG_FILE, (char *)from); 320 lookup_result = table_lookup(type, answstr, (uint8_t*)from); 311 321 if (lookup_result != 0) { 312 322 outr.flags = 3 | 0x0400; //name do not exist and auth … … 342 352 next += outr.rlen; 343 353 344 empty_packet: 345 354 empty_packet: 346 355 flags = ntohs(head->flags); 347 356 // clear rcode and RA, set responsebit and our new flags … … 365 374 } 366 375 367 #define is_daemon() (flags&16)368 #define is_verbose() (flags&32)369 //#define DEBUG 1370 376 371 377 int dnsd_main(int argc, char **argv) … … 438 444 (void *)&fromlen); 439 445 if(is_verbose()) 440 fprintf(stderr, "\n--- Got UDP ");441 log_message(LOG_FILE, "\n--- Got UDP 446 fprintf(stderr, "\n--- Got UDP size=%d ", r); 447 log_message(LOG_FILE, "\n--- Got UDP "); 442 448 443 449 if (r < 12 || r > 512) {
Note:
See TracChangeset
for help on using the changeset viewer.