Changeset 432

Show
Ignore:
Timestamp:
02/06/05 18:18:17 (6 years ago)
Author:
minaguib
Message:

Insignificant code cleanup

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/CaptiveDNS/wifidog/src/dnsserver_thread.c

    r431 r432  
    4343#include "dnsserver_thread.h" 
    4444 
    45 /** Accepts DNS requests, replies to all IN A requests with the internal IP address 
     45/** Accepts DNS requests: For certain hostnames replies with their real IP, for all others replies with the gateway's IP address 
    4646@param arg NULL 
    4747@todo This thread loops infinitely, need a watchdog to verify that it is still running? 
     
    218218                                        outputanswerheader.length = htons(sizeof(answerip)); 
    219219 
    220                                         /* Now we populate answerip with what we tell them 
     220                                        /* Now we populate answerip with what the answer should be 
    221221                                         */ 
    222222                                        authhostname = config_get_config()->auth_servers->authserv_hostname; 
     
    227227                                                authip = wd_gethostbyname(authhostname); 
    228228                                                if (authip) { 
     229                                                        debug(LOG_DEBUG, "Requested IP is for the hostname of the active auth server"); 
    229230                                                        memcpy(&answerip, authip, sizeof(answerip)); 
    230231                                                        free(authip); 
    231232                                                } 
    232233                                                else { 
     234                                                        debug(LOG_NOTICE, "Requested IP is for the hostname of the active auth server but I failed to resolve it"); 
    233235                                                        /* XXX: Failed to resolve auth server hostname - Loop back to us ?*/ 
    234236                                                        inet_aton(config_get_config()->gw_address, &answerip); 
     
    239241                                                 * They're asking for something else - point them to us 
    240242                                                 */ 
     243                                                debug(LOG_DEBUG, "Requested IP is for an arbitrary hostname"); 
    241244                                                inet_aton(config_get_config()->gw_address, &answerip); 
    242245                                        } 
    243246                                         
    244247                                        /* Calculate size of output pieces together */ 
    245                                         outputlength = sizeof(outputheader) + strlen(hostname) + 1 + sizeof(outputqueryfooter) + sizeof(outputanswerheader) + sizeof(answerip); 
     248                                        outputlength = 
     249                                                  sizeof(outputheader) 
     250                                                + strlen(hostname) 
     251                                                + 1 
     252                                                + sizeof(outputqueryfooter) 
     253                                                + sizeof(outputanswerheader) 
     254                                                + sizeof(answerip) 
     255                                                ; 
     256 
    246257                                        outputbuffer = malloc(outputlength); 
    247258                                        if (!outputbuffer) { 
     
    251262                                        else { 
    252263                                                /* 
    253                                                  * XXX: dirty - must match above malloc size pieces for outputbuffer 
     264                                                 * Fill outputbuffer with the concatenated pieces 
     265                                                 * Be careful - anything added here must be accounted for in the above outputlength calculation 
    254266                                                 */ 
    255                                                 memcpy(outputbuffer, &outputheader, sizeof(outputheader)); 
    256                                                 memcpy(outputbuffer + sizeof(outputheader), hostname, strlen(hostname)); 
    257                                                 memcpy(outputbuffer + sizeof(outputheader) + strlen(hostname), "", 1); 
    258                                                 memcpy(outputbuffer + sizeof(outputheader) + strlen(hostname) + 1, &outputqueryfooter, sizeof(outputqueryfooter)); 
    259                                                 memcpy(outputbuffer + sizeof(outputheader) + strlen(hostname) + 1 + sizeof(outputqueryfooter), &outputanswerheader, sizeof(outputanswerheader)); 
    260                                                 memcpy(outputbuffer + sizeof(outputheader) + strlen(hostname) + 1 + sizeof(outputqueryfooter) + sizeof(outputanswerheader), &answerip, sizeof(answerip)); 
     267                                                temp = outputbuffer; 
     268 
     269                                                memcpy(temp, &outputheader, sizeof(outputheader)); 
     270                                                temp += sizeof(outputheader); 
     271 
     272                                                memcpy(temp, hostname, strlen(hostname)); 
     273                                                temp += strlen(hostname); 
     274 
     275                                                memcpy(temp, "", 1); 
     276                                                temp += 1; 
     277 
     278                                                memcpy(temp, &outputqueryfooter, sizeof(outputqueryfooter)); 
     279                                                temp += sizeof(outputqueryfooter); 
     280 
     281                                                memcpy(temp, &outputanswerheader, sizeof(outputanswerheader)); 
     282                                                temp += sizeof(outputanswerheader); 
     283 
     284                                                memcpy(temp, &answerip, sizeof(answerip)); 
     285                                                temp += sizeof(answerip); 
    261286 
    262287                                                /*