The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Macros | Functions | Variables
encode.c File Reference

Functions to encode DNS packets. More...

#include <freeradius-devel/io/test_point.h>
#include <freeradius-devel/util/dbuff.h>
#include <freeradius-devel/util/dns.h>
#include <freeradius-devel/util/proto.h>
#include <freeradius-devel/util/struct.h>
#include <freeradius-devel/util/encode.h>
#include "dns.h"
#include "attrs.h"
+ Include dependency graph for encode.c:

Go to the source code of this file.

Macros

#define DNS_OPT_HDR_LEN   (4)
 

Functions

static ssize_t encode_child (fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *cursor, void *encode_ctx)
 
static ssize_t encode_option_hdr (fr_dbuff_marker_t *m, uint16_t option, size_t data_len)
 Macro-like function for encoding an option header. More...
 
static ssize_t encode_record (fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, fr_pair_list_t *vps, fr_dict_attr_t const *attr, fr_dns_ctx_t *packet_ctx, uint8_t *counter)
 
static ssize_t encode_rfc (fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *cursor, void *encode_ctx)
 Encode an RFC format TLV. More...
 
static int encode_test_ctx (void **out, TALLOC_CTX *ctx)
 
static ssize_t encode_tlv (fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *cursor, void *encode_ctx)
 
static ssize_t encode_value (fr_dbuff_t *dbuff, fr_da_stack_t *da_stack, unsigned int depth, fr_dcursor_t *cursor, void *encode_ctx)
 
ssize_t fr_dns_encode (fr_dbuff_t *dbuff, fr_pair_list_t *vps, fr_dns_ctx_t *packet_ctx)
 Encode a DNS packet. More...
 
static ssize_t fr_dns_encode_proto (UNUSED TALLOC_CTX *ctx, fr_pair_list_t *vps, uint8_t *data, size_t data_len, void *proto_ctx)
 
static ssize_t fr_dns_encode_rr (fr_dbuff_t *dbuff, fr_dcursor_t *cursor, void *encode_ctx)
 Encode a Dns option and any sub-options. More...
 

Variables

fr_test_point_pair_encode_t dns_tp_encode_pair
 
fr_test_point_proto_encode_t dns_tp_encode_proto
 

Detailed Description

Functions to encode DNS packets.

Id
7007cca77cf00bc2916b078683003bd36e32913a
Author
Alan DeKok (aland.nosp@m.@fre.nosp@m.eradi.nosp@m.us.o.nosp@m.rg)

Definition in file encode.c.

Macro Definition Documentation

◆ DNS_OPT_HDR_LEN

#define DNS_OPT_HDR_LEN   (4)

Definition at line 37 of file encode.c.

Function Documentation

◆ encode_child()

static ssize_t encode_child ( fr_dbuff_t dbuff,
fr_da_stack_t da_stack,
unsigned int  depth,
fr_dcursor_t cursor,
void *  encode_ctx 
)
static

Definition at line 225 of file encode.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ encode_option_hdr()

static ssize_t encode_option_hdr ( fr_dbuff_marker_t m,
uint16_t  option,
size_t  data_len 
)
inlinestatic

Macro-like function for encoding an option header.

0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | option-code | option-len | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Parameters
[out]mWhere to write the 4 byte option header.
[in]optionThe option number (host byte order).
[in]data_lenThe length of the option (host byte order).
Returns
  • <0 How much data would have been required as a negative value.
  • 4 The length of data written.

Definition at line 70 of file encode.c.

+ Here is the caller graph for this function:

◆ encode_record()

static ssize_t encode_record ( fr_dbuff_t dbuff,
fr_da_stack_t da_stack,
fr_pair_list_t vps,
fr_dict_attr_t const *  attr,
fr_dns_ctx_t packet_ctx,
uint8_t counter 
)
static

Definition at line 415 of file encode.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ encode_rfc()

static ssize_t encode_rfc ( fr_dbuff_t dbuff,
fr_da_stack_t da_stack,
unsigned int  depth,
fr_dcursor_t cursor,
void *  encode_ctx 
)
static

Encode an RFC format TLV.

This could be a standard attribute, or a TLV data type. If it's a standard attribute, then vp->da->attr == attribute. Otherwise, attribute may be something else.

Definition at line 289 of file encode.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ encode_test_ctx()

static int encode_test_ctx ( void **  out,
TALLOC_CTX *  ctx 
)
static

Definition at line 515 of file encode.c.

◆ encode_tlv()

static ssize_t encode_tlv ( fr_dbuff_t dbuff,
fr_da_stack_t da_stack,
unsigned int  depth,
fr_dcursor_t cursor,
void *  encode_ctx 
)
static

Definition at line 327 of file encode.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ encode_value()

static ssize_t encode_value ( fr_dbuff_t dbuff,
fr_da_stack_t da_stack,
unsigned int  depth,
fr_dcursor_t cursor,
void *  encode_ctx 
)
static

Definition at line 79 of file encode.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dns_encode()

ssize_t fr_dns_encode ( fr_dbuff_t dbuff,
fr_pair_list_t vps,
fr_dns_ctx_t packet_ctx 
)

Encode a DNS packet.

Definition at line 454 of file encode.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dns_encode_proto()

static ssize_t fr_dns_encode_proto ( UNUSED TALLOC_CTX *  ctx,
fr_pair_list_t vps,
uint8_t data,
size_t  data_len,
void *  proto_ctx 
)
static

Definition at line 529 of file encode.c.

+ Here is the call graph for this function:

◆ fr_dns_encode_rr()

static ssize_t fr_dns_encode_rr ( fr_dbuff_t dbuff,
fr_dcursor_t cursor,
void *  encode_ctx 
)
static

Encode a Dns option and any sub-options.

Parameters
[out]dbuffWhere to write encoded DHCP attributes.
[in]cursorwith current VP set to the option to be encoded. Will be advanced to the next option to encode.
[in]encode_ctxcontaining parameters for the encoder.
Returns
  • > 0 length of data written.
  • < 0 error.

Definition at line 382 of file encode.c.

+ Here is the call graph for this function:

Variable Documentation

◆ dns_tp_encode_pair

fr_test_point_pair_encode_t dns_tp_encode_pair
Initial value:
= {
.test_ctx = encode_test_ctx,
}
static ssize_t fr_dns_encode_rr(fr_dbuff_t *dbuff, fr_dcursor_t *cursor, void *encode_ctx)
Encode a Dns option and any sub-options.
Definition: encode.c:382
static int encode_test_ctx(void **out, TALLOC_CTX *ctx)
Definition: encode.c:515

Definition at line 556 of file encode.c.

◆ dns_tp_encode_proto

fr_test_point_proto_encode_t dns_tp_encode_proto
Initial value:
= {
.test_ctx = encode_test_ctx,
}
static ssize_t fr_dns_encode_proto(UNUSED TALLOC_CTX *ctx, fr_pair_list_t *vps, uint8_t *data, size_t data_len, void *proto_ctx)
Definition: encode.c:529

Definition at line 562 of file encode.c.