Skip to content
Snippets Groups Projects
Commit fb3d506a authored by Lubos Slovak's avatar Lubos Slovak
Browse files

Fixes to RDATA.

- wire_size() was not counting the stored length octet in case of
  TEXT or BINARY.
- typo in to_wire()

refs #119
parent 305c7f91
Branches
Tags
No related merge requests found
......@@ -159,8 +159,17 @@ uint dnslib_rdata_wire_size( const dnslib_rdata_t *rdata,
case DNSLIB_RDATA_WF_AAAA:
size += 16;
break;
default:
case DNSLIB_RDATA_WF_BINARY:
case DNSLIB_RDATA_WF_APL: // saved as binary
case DNSLIB_RDATA_WF_IPSECGATEWAY: // saved as binary
size += rdata->items[i].raw_data[0];
break;
case DNSLIB_RDATA_WF_TEXT:
case DNSLIB_RDATA_WF_BINARYWITHLENGTH:
size += rdata->items[i].raw_data[0] + 1;
break;
default:
assert(0);
}
}
return size;
......@@ -215,7 +224,7 @@ int dnslib_rdata_to_wire( const dnslib_rdata_t *rdata, const uint8_t *format,
case DNSLIB_RDATA_WF_IPSECGATEWAY: // saved as binary
// size stored in the first byte, first byte must not be copied
size = rdata->items[i].raw_data[0];
++to;
++from;
break;
default:
assert(0);
......
......@@ -157,8 +157,8 @@ uint dnslib_rdata_wire_size( const dnslib_rdata_t *rdata,
* \return 0 on success.
* \return <> 0 otherwise.
*
* \todo Do we really need all those different kinds of RDATA items? It makes
* converting more complicated.
* \todo Shouldn't we keep the size of the data always in the item? It would
* make the converting quicker.
*/
int dnslib_rdata_to_wire( const dnslib_rdata_t *rdata, const uint8_t *format,
uint8_t *buffer, uint buf_size );
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment