Changeset ef904895 in mainline
- Timestamp:
- 2013-05-03T08:50:31Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8fdb18e
- Parents:
- a0d97f83
- Location:
- uspace/srv/net/dnsrsrv
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/dnsrsrv/dns_msg.c
ra0d97f83 ref904895 37 37 #include <byteorder.h> 38 38 #include <errno.h> 39 #include <io/log.h> 39 40 #include <macros.h> 40 41 #include <stdint.h> … … 76 77 } 77 78 78 #include <stdio.h>79 79 static int dns_name_encode(char *name, uint8_t *buf, size_t buf_size, 80 80 size_t *act_size) … … 89 89 off = 0; 90 90 91 printf("dns_name_encode(name='%s', buf=%p, buf_size=%zu, act_size=%p\n",92 name, buf, buf_size, act_size);93 91 lsize = 0; 94 92 while (true) { 95 printf("off=%zu\n", off);96 93 c = str_decode(name, &off, STR_NO_LIMIT); 97 printf("c=%d\n", (int)c);98 94 if (c >= 127) { 99 95 /* Non-ASCII character */ 100 printf("non-ascii character\n");96 log_msg(LOG_DEFAULT, LVL_DEBUG, "Non-ascii character"); 101 97 return EINVAL; 102 98 } … … 105 101 /* Empty string, starting with period or two consecutive periods. */ 106 102 if (lsize == 0) { 107 printf("empty token\n");103 log_msg(LOG_DEFAULT, LVL_DEBUG, "Empty token"); 108 104 return EINVAL; 109 105 } … … 111 107 if (lsize > DNS_LABEL_MAX_SIZE) { 112 108 /* Label too long */ 113 printf("label too long\n");109 log_msg(LOG_DEFAULT, LVL_DEBUG, "Label too long"); 114 110 return EINVAL; 115 111 } … … 177 173 178 174 if (!first) { 179 printf(".");180 175 rc = dns_dstr_ext(&name, "."); 181 176 if (rc != EOK) { … … 186 181 187 182 if ((lsize & 0xc0) == 0xc0) { 188 printf("Pointer\n");189 183 /* Pointer */ 190 184 if (bsize < 1) { 191 printf("Pointer- bsize < 1\n");185 log_msg(LOG_DEFAULT, LVL_DEBUG, "Pointer- bsize < 1"); 192 186 rc = EINVAL; 193 187 goto error; … … 199 193 200 194 if (ptr >= (size_t)(bp - buf)) { 201 printf("Pointer- forward ref %u, pos=%u\n", 195 log_msg(LOG_DEFAULT, LVL_DEBUG, 196 "Pointer- forward ref %u, pos=%u", 202 197 ptr, bp - buf); 203 198 /* Forward reference */ … … 217 212 *eoff = eptr; 218 213 219 printf("ptr=%u, eptr=%u\n", ptr, eptr);220 214 bp = buf + ptr; 221 215 bsize = eptr - ptr; … … 229 223 230 224 for (i = 0; i < lsize; i++) { 231 printf("%c", *bp);232 233 225 if (*bp < 32 || *bp >= 127) { 234 226 rc = EINVAL; … … 251 243 } 252 244 253 printf("\n");254 255 245 *rname = name; 256 246 if (*eoff == 0) … … 291 281 buf[3]; 292 282 293 printf("dns_uint32_t_decode: %x, %x, %x, %x -> %x\n",294 buf[0], buf[1], buf[2], buf[3], w);295 283 return w; 296 284 } … … 307 295 return rc; 308 296 309 printf("name_size=%zu\n", name_size);310 311 297 *act_size = name_size + sizeof(uint16_t) + sizeof(uint16_t); 312 printf("act_size=%zu\n", *act_size);313 298 if (buf == NULL) 314 299 return EOK; … … 336 321 return ENOMEM; 337 322 338 printf("decode name..\n");339 323 rc = dns_name_decode(buf, buf_size, boff, &question->qname, &name_eoff); 340 324 if (rc != EOK) { 341 printf("error decoding name..\n");325 log_msg(LOG_DEFAULT, LVL_DEBUG, "Error decoding name"); 342 326 free(question); 343 327 return ENOMEM; 344 328 } 345 329 346 printf("ok decoding name..\n");347 330 if (name_eoff + 2 * sizeof(uint16_t) > buf_size) { 348 printf("name_eoff + 2 * 2 = %d > buf_size = %d\n",349 name_eoff + 2 * sizeof(uint16_t), buf_size);350 331 free(question); 351 332 return EINVAL; … … 375 356 return ENOMEM; 376 357 377 printf("decode name..\n");378 358 rc = dns_name_decode(buf, buf_size, boff, &rr->name, &name_eoff); 379 359 if (rc != EOK) { 380 printf("error decoding name..\n");360 log_msg(LOG_DEFAULT, LVL_DEBUG, "Error decoding name"); 381 361 free(rr); 382 362 return ENOMEM; 383 363 } 384 364 385 printf("ok decoding name.. '%s'\n", rr->name);386 365 if (name_eoff + 2 * sizeof(uint16_t) > buf_size) { 387 printf("name_eoff + 2 * 2 = %d > buf_size = %d\n",388 name_eoff + 2 * sizeof(uint16_t), buf_size);389 366 free(rr->name); 390 367 free(rr); … … 403 380 rr->rtype = dns_uint16_t_decode(bp, bsz); 404 381 bp += sizeof(uint16_t); bsz -= sizeof(uint16_t); 405 printf("rtype=%u\n", rr->rtype);406 382 407 383 rr->rclass = dns_uint16_t_decode(bp, bsz); 408 384 bp += sizeof(uint16_t); bsz -= sizeof(uint16_t); 409 printf("rclass=%u\n", rr->rclass);410 385 411 386 rr->ttl = dns_uint32_t_decode(bp, bsz); 412 387 bp += sizeof(uint32_t); bsz -= sizeof(uint32_t); 413 printf("ttl=%u\n", rr->ttl);414 388 415 389 rdlength = dns_uint16_t_decode(bp, bsz); 416 390 bp += sizeof(uint16_t); bsz -= sizeof(uint16_t); 417 printf("rdlength=%u\n", rdlength);418 391 419 392 if (rdlength > bsz) { … … 467 440 468 441 size = sizeof(dns_header_t); 469 printf("dns header size=%zu\n", size);470 442 471 443 list_foreach(msg->question, link) { … … 475 447 return rc; 476 448 477 printf("q_size=%zu\n", q_size);478 449 size += q_size; 479 450 } … … 498 469 } 499 470 500 printf("-> size=%zu, di=%zu\n", size, di);501 471 *rdata = data; 502 472 *rsize = size; … … 540 510 541 511 qd_count = uint16_t_be2host(hdr->qd_count); 542 printf("qd_count = %d\n", (int)qd_count);543 512 544 513 for (i = 0; i < qd_count; i++) { 545 printf("decode question..\n");546 514 rc = dns_question_decode(data, size, doff, &question, &field_eoff); 547 515 if (rc != EOK) { 548 printf("error decoding question\n");516 log_msg(LOG_DEFAULT, LVL_DEBUG, "error decoding question"); 549 517 goto error; 550 518 } 551 printf("ok decoding question\n");552 519 553 520 list_append(&question->msg, &msg->question); … … 556 523 557 524 an_count = uint16_t_be2host(hdr->an_count); 558 printf("an_count = %d\n", an_count);559 525 560 526 for (i = 0; i < an_count; i++) { 561 printf("decode answer..\n");562 527 rc = dns_rr_decode(data, size, doff, &rr, &field_eoff); 563 528 if (rc != EOK) { 564 printf("error decoding answer\n");529 log_msg(LOG_DEFAULT, LVL_DEBUG, "Error decoding answer"); 565 530 goto error; 566 531 } 567 printf("ok decoding answer\n");568 532 569 533 list_append(&rr->msg, &msg->answer); 570 534 doff = field_eoff; 571 535 } 572 573 printf("ns_count = %d\n", uint16_t_be2host(hdr->ns_count));574 printf("ar_count = %d\n", uint16_t_be2host(hdr->ar_count));575 536 576 537 *rmsg = msg; -
uspace/srv/net/dnsrsrv/query.c
ra0d97f83 ref904895 86 86 dns_rr_t *rr = list_get_instance(link, dns_rr_t, msg); 87 87 88 log_msg(LOG_DEFAULT, LVL_DEBUG, " - '%s' %u/%u, dsize %u \n",88 log_msg(LOG_DEFAULT, LVL_DEBUG, " - '%s' %u/%u, dsize %u", 89 89 rr->name, rr->rtype, rr->rclass, rr->rdata_size); 90 90 … … 100 100 info->name = str_dup(rr->name); 101 101 info->addr.ipv4 = dns_uint32_t_decode(rr->rdata, rr->rdata_size); 102 log_msg(LOG_DEFAULT, LVL_DEBUG, "info->addr = %x \n",102 log_msg(LOG_DEFAULT, LVL_DEBUG, "info->addr = %x", 103 103 info->addr.ipv4); 104 104 … … 112 112 dns_message_destroy(msg); 113 113 dns_message_destroy(amsg); 114 log_msg(LOG_DEFAULT, LVL_DEBUG, "No A/IN found, fail \n");114 log_msg(LOG_DEFAULT, LVL_DEBUG, "No A/IN found, fail"); 115 115 116 116 return EIO; -
uspace/srv/net/dnsrsrv/transport.c
ra0d97f83 ref904895 108 108 return EOK; 109 109 error: 110 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed initializing network socket. \n");110 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed initializing network socket."); 111 111 if (fd >= 0) 112 112 closesocket(fd); … … 246 246 (struct sockaddr *)&src_addr, &src_addr_size); 247 247 if (rc < 0) { 248 log_msg(LOG_DEFAULT, LVL_ERROR, "recvfrom returns error - %d \n", rc);248 log_msg(LOG_DEFAULT, LVL_ERROR, "recvfrom returns error - %d", rc); 249 249 goto error; 250 250 }
Note:
See TracChangeset
for help on using the changeset viewer.