Changeset 904 in MondoRescue for trunk/mindi-busybox/networking/dnsd.c


Ignore:
Timestamp:
Oct 25, 2006, 1:51:57 AM (17 years ago)
Author:
Bruno Cornec
Message:

merge -r890:902 $SVN_M/branches/stable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mindi-busybox/networking/dnsd.c

    r821 r904  
    2929#define LOCK_FILE       "/var/run/dnsd.lock"
    3030#define LOG_FILE        "/var/log/dnsd.log"
     31
     32#define is_daemon()  (flags&16)
     33#define is_verbose() (flags&32)
     34//#define DEBUG
     35
    3136
    3237enum {
     
    224229{
    225230    int i;
    226     struct dns_entry *d=dnsentry;
    227 
    228     do {
     231    struct dns_entry *d = dnsentry;
     232
     233    if(d) do {
    229234#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 */
    236245            for(i = 1; i <= (int)(d->name[0]); i++)
    237246                if(tolower(qs[i]) != d->name[i])
    238                     continue;
     247                    break;
     248            if(i > (int)(d->name[0])) {
    239249#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);
    243253#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 */
    249260            if (!strncmp((char*)&d->rip[1], (char*)&qs[1], strlen(d->rip)-1)) {
    250261                strcpy((char *)as, d->name);
     
    282293
    283294    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 block
     295    next = answb = from + strlen((char *)from) + 1 + sizeof(struct dns_prop);   // where to append answer block
    285296
    286297    outr.rlen = 0;          // may change later
     
    306317
    307318    // 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);
    311321    if (lookup_result != 0) {
    312322        outr.flags = 3 | 0x0400;    //name do not exist and auth
     
    342352    next += outr.rlen;
    343353
    344       empty_packet:
    345 
     354empty_packet:
    346355    flags = ntohs(head->flags);
    347356    // clear rcode and RA, set responsebit and our new flags
     
    365374}
    366375
    367 #define is_daemon()  (flags&16)
    368 #define is_verbose() (flags&32)
    369 //#define DEBUG 1
    370376
    371377int dnsd_main(int argc, char **argv)
     
    438444                     (void *)&fromlen);
    439445            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 ");
    442448
    443449            if (r < 12 || r > 512) {
Note: See TracChangeset for help on using the changeset viewer.