diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-08-24 09:02:49 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-08-24 09:02:49 +0000 |
commit | 6c77a012bc057de0f0bbcb437463ec86a9ca088d (patch) | |
tree | fea13af5ad9bfb4192f4d47db142252b182738a1 /src/include/gnunet_dnsparser_lib.h | |
parent | 748a9dd6a96000a30e813d41f1c4cb86ef04089d (diff) | |
download | gnunet-6c77a012bc057de0f0bbcb437463ec86a9ca088d.tar.gz gnunet-6c77a012bc057de0f0bbcb437463ec86a9ca088d.zip |
-exposing dnsparser record packing API
Diffstat (limited to 'src/include/gnunet_dnsparser_lib.h')
-rw-r--r-- | src/include/gnunet_dnsparser_lib.h | 110 |
1 files changed, 105 insertions, 5 deletions
diff --git a/src/include/gnunet_dnsparser_lib.h b/src/include/gnunet_dnsparser_lib.h index 5b55de045..8e00aa248 100644 --- a/src/include/gnunet_dnsparser_lib.h +++ b/src/include/gnunet_dnsparser_lib.h | |||
@@ -429,15 +429,18 @@ GNUNET_DNSPARSER_free_packet (struct GNUNET_DNSPARSER_Packet *p); | |||
429 | 429 | ||
430 | 430 | ||
431 | /** | 431 | /** |
432 | * Given a DNS packet, generate the corresponding UDP payload. | 432 | * Given a DNS packet @a p, generate the corresponding UDP payload. |
433 | * Note that we do not attempt to pack the strings with pointers | ||
434 | * as this would complicate the code and this is about being | ||
435 | * simple and secure, not fast, fancy and broken like bind. | ||
433 | * | 436 | * |
434 | * @param p packet to pack | 437 | * @param p packet to pack |
435 | * @param max maximum allowed size for the resulting UDP payload | 438 | * @param max maximum allowed size for the resulting UDP payload |
436 | * @param buf set to a buffer with the packed message | 439 | * @param buf set to a buffer with the packed message |
437 | * @param buf_length set to the length of buf | 440 | * @param buf_length set to the length of @a buf |
438 | * @return GNUNET_SYSERR if 'p' is invalid | 441 | * @return #GNUNET_SYSERR if @a p is invalid |
439 | * GNUNET_NO if 'p' was truncated (but there is still a result in 'buf') | 442 | * #GNUNET_NO if @a p was truncated (but there is still a result in @a buf) |
440 | * GNUNET_OK if 'p' was packed completely into '*buf' | 443 | * #GNUNET_OK if @a p was packed completely into @a buf |
441 | */ | 444 | */ |
442 | int | 445 | int |
443 | GNUNET_DNSPARSER_pack (const struct GNUNET_DNSPARSER_Packet *p, | 446 | GNUNET_DNSPARSER_pack (const struct GNUNET_DNSPARSER_Packet *p, |
@@ -445,5 +448,102 @@ GNUNET_DNSPARSER_pack (const struct GNUNET_DNSPARSER_Packet *p, | |||
445 | char **buf, | 448 | char **buf, |
446 | size_t *buf_length); | 449 | size_t *buf_length); |
447 | 450 | ||
451 | /* ***************** low-level packing API ******************** */ | ||
452 | |||
453 | /** | ||
454 | * Add a DNS name to the UDP packet at the given location, converting | ||
455 | * the name to IDNA notation as necessary. | ||
456 | * | ||
457 | * @param dst where to write the name (UDP packet) | ||
458 | * @param dst_len number of bytes in @a dst | ||
459 | * @param off pointer to offset where to write the name (increment by bytes used) | ||
460 | * must not be changed if there is an error | ||
461 | * @param name name to write | ||
462 | * @return #GNUNET_SYSERR if @a name is invalid | ||
463 | * #GNUNET_NO if @a name did not fit | ||
464 | * #GNUNET_OK if @a name was added to @a dst | ||
465 | */ | ||
466 | int | ||
467 | GNUNET_DNSPARSER_builder_add_name (char *dst, | ||
468 | size_t dst_len, | ||
469 | size_t *off, | ||
470 | const char *name); | ||
471 | |||
472 | |||
473 | /** | ||
474 | * Add a DNS query to the UDP packet at the given location. | ||
475 | * | ||
476 | * @param dst where to write the query | ||
477 | * @param dst_len number of bytes in @a dst | ||
478 | * @param off pointer to offset where to write the query (increment by bytes used) | ||
479 | * must not be changed if there is an error | ||
480 | * @param query query to write | ||
481 | * @return #GNUNET_SYSERR if @a query is invalid | ||
482 | * #GNUNET_NO if @a query did not fit | ||
483 | * #GNUNET_OK if @a query was added to @a dst | ||
484 | */ | ||
485 | int | ||
486 | GNUNET_DNSPARSER_builder_add_query (char *dst, | ||
487 | size_t dst_len, | ||
488 | size_t *off, | ||
489 | const struct GNUNET_DNSPARSER_Query *query); | ||
490 | |||
491 | |||
492 | /** | ||
493 | * Add an MX record to the UDP packet at the given location. | ||
494 | * | ||
495 | * @param dst where to write the mx record | ||
496 | * @param dst_len number of bytes in @a dst | ||
497 | * @param off pointer to offset where to write the mx information (increment by bytes used); | ||
498 | * can also change if there was an error | ||
499 | * @param mx mx information to write | ||
500 | * @return #GNUNET_SYSERR if @a mx is invalid | ||
501 | * #GNUNET_NO if @a mx did not fit | ||
502 | * #GNUNET_OK if @a mx was added to @a dst | ||
503 | */ | ||
504 | int | ||
505 | GNUNET_DNSPARSER_builder_add_mx (char *dst, | ||
506 | size_t dst_len, | ||
507 | size_t *off, | ||
508 | const struct GNUNET_DNSPARSER_MxRecord *mx); | ||
509 | |||
510 | |||
511 | /** | ||
512 | * Add an SOA record to the UDP packet at the given location. | ||
513 | * | ||
514 | * @param dst where to write the SOA record | ||
515 | * @param dst_len number of bytes in @a dst | ||
516 | * @param off pointer to offset where to write the SOA information (increment by bytes used) | ||
517 | * can also change if there was an error | ||
518 | * @param soa SOA information to write | ||
519 | * @return #GNUNET_SYSERR if @a soa is invalid | ||
520 | * #GNUNET_NO if @a soa did not fit | ||
521 | * #GNUNET_OK if @a soa was added to @a dst | ||
522 | */ | ||
523 | int | ||
524 | GNUNET_DNSPARSER_builder_add_soa (char *dst, | ||
525 | size_t dst_len, | ||
526 | size_t *off, | ||
527 | const struct GNUNET_DNSPARSER_SoaRecord *soa); | ||
528 | |||
529 | |||
530 | /** | ||
531 | * Add an SRV record to the UDP packet at the given location. | ||
532 | * | ||
533 | * @param dst where to write the SRV record | ||
534 | * @param dst_len number of bytes in @a dst | ||
535 | * @param off pointer to offset where to write the SRV information (increment by bytes used) | ||
536 | * can also change if there was an error | ||
537 | * @param srv SRV information to write | ||
538 | * @return #GNUNET_SYSERR if @a srv is invalid | ||
539 | * #GNUNET_NO if @a srv did not fit | ||
540 | * #GNUNET_OK if @a srv was added to @a dst | ||
541 | */ | ||
542 | int | ||
543 | GNUNET_DNSPARSER_builder_add_srv (char *dst, | ||
544 | size_t dst_len, | ||
545 | size_t *off, | ||
546 | const struct GNUNET_DNSPARSER_SrvRecord *srv); | ||
547 | |||
448 | 548 | ||
449 | #endif | 549 | #endif |