Changeset 08a6382 in mainline for uspace/srv/net/dnsres/dns_msg.c


Ignore:
Timestamp:
2012-08-12T20:17:31Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e5e73af
Parents:
f85ed4b
Message:

Fixes to get DNS query acceptable by looking at analyzer output. Fix assertion failure in UDP.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/dnsres/dns_msg.c

    rf85ed4b r08a6382  
    3535
    3636#include <bitops.h>
     37#include <byteorder.h>
    3738#include <errno.h>
    3839#include <stdint.h>
     
    8788                                buf[pi] = (uint8_t)lsize;
    8889
     90                        lsize = 0;
     91                        pi = di;
     92                        ++di;
     93
    8994                        if (c == '\0')
    9095                                break;
    91 
    92                         pi = di;
     96                } else {
     97                        if (buf != NULL && di < buf_size)
     98                                buf[di] = c;
    9399                        ++di;
    94                 } else {
    95100                        ++lsize;
    96                         if (buf != NULL && di < buf_size)
    97                                 buf[di++] = c;
    98101                }
    99102        }
     
    126129                return rc;
    127130
     131        printf("name_size=%zu\n", name_size);
     132
    128133        *act_size = name_size + sizeof(uint16_t) + sizeof(uint16_t);
     134        printf("act_size=%zu\n", *act_size);
    129135        if (buf == NULL)
    130136                return EOK;
     
    138144        di += sizeof(uint16_t);
    139145
    140         *act_size = di;
    141146        return EOK;
    142147}
     
    151156        int rc;
    152157
    153         hdr.id = msg->id;
    154 
    155         hdr.opbits =
     158        hdr.id = host2uint16_t_be(msg->id);
     159
     160        hdr.opbits = host2uint16_t_be(
    156161            (msg->qr << OPB_QR) |
    157162            (msg->opcode << OPB_OPCODE_l) |
     
    160165            (msg->rd ? BIT_V(uint16_t, OPB_RD) : 0) |
    161166            (msg->ra ? BIT_V(uint16_t, OPB_RA) : 0) |
    162             msg->rcode;
    163 
    164         hdr.qd_count = list_count(&msg->question);
     167            msg->rcode
     168        );
     169
     170        hdr.qd_count = host2uint16_t_be(list_count(&msg->question));
    165171        hdr.an_count = 0;
    166172        hdr.ns_count = 0;
     
    168174
    169175        size = sizeof(dns_header_t);
     176        printf("dns header size=%zu\n", size);
    170177
    171178        list_foreach(msg->question, link) {
     
    175182                        return rc;
    176183
     184                printf("q_size=%zu\n", q_size);
    177185                size += q_size;
    178186        }
     
    193201        }
    194202
     203        printf("-> size=%zu, di=%zu\n", size, di);
    195204        *rdata = data;
    196205        *rsize = size;
Note: See TracChangeset for help on using the changeset viewer.