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

Low-Level TACACS+ encode functions. More...

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

Go to the source code of this file.

Macros

#define ENCODE_FIELD_STRING16(_field, _da)   _field = htons(tacacs_encode_field(&work_dbuff, vps, _da, 0xffff))
 
#define ENCODE_FIELD_STRING8(_field, _da)   _field = tacacs_encode_field(&work_dbuff, vps, _da, 0xff)
 
#define ENCODE_FIELD_UINT8(_field, _da)
 

Functions

static int _encode_test_ctx (fr_tacacs_ctx_t *proto_ctx)
 
static int encode_test_ctx (void **out, TALLOC_CTX *ctx)
 
int fr_tacacs_code_to_packet (fr_tacacs_packet_t *pkt, uint32_t code)
 
ssize_t fr_tacacs_encode (fr_dbuff_t *dbuff, uint8_t const *original_packet, char const *secret, size_t secret_len, unsigned int code, fr_pair_list_t *vps)
 Encode VPS into a raw TACACS packet. More...
 
static ssize_t fr_tacacs_encode_proto (UNUSED TALLOC_CTX *ctx, fr_pair_list_t *vps, uint8_t *data, size_t data_len, void *proto_ctx)
 
static uint8_t tacacs_encode_body_arg_cnt (fr_pair_list_t *vps, fr_dict_attr_t const *da)
 Encode a TACACS+ 'arg_N' fields. More...
 
static ssize_t tacacs_encode_body_arg_n (fr_dbuff_t *dbuff, uint8_t arg_cnt, uint8_t *arg_len, fr_pair_list_t *vps, fr_dict_attr_t const *da)
 
static ssize_t tacacs_encode_chap (fr_dbuff_t *dbuff, fr_tacacs_packet_t *packet, fr_pair_list_t *vps, fr_dict_attr_t const *da_chap, fr_dict_attr_t const *da_challenge)
 
static ssize_t tacacs_encode_field (fr_dbuff_t *dbuff, fr_pair_list_t *vps, fr_dict_attr_t const *da, size_t max_len)
 

Variables

fr_test_point_proto_encode_t tacacs_tp_encode_proto
 

Detailed Description

Low-Level TACACS+ encode functions.

Id
7b7974ebc5b0a3961e4638d6abdc0ee3f896a955
Id
9cde8cf54fa82c01b2a234820daf100db7a7e35c

Definition in file encode.c.

Macro Definition Documentation

◆ ENCODE_FIELD_STRING16

#define ENCODE_FIELD_STRING16 (   _field,
  _da 
)    _field = htons(tacacs_encode_field(&work_dbuff, vps, _da, 0xffff))

Definition at line 358 of file encode.c.

◆ ENCODE_FIELD_STRING8

#define ENCODE_FIELD_STRING8 (   _field,
  _da 
)    _field = tacacs_encode_field(&work_dbuff, vps, _da, 0xff)

Definition at line 357 of file encode.c.

◆ ENCODE_FIELD_UINT8

#define ENCODE_FIELD_UINT8 (   _field,
  _da 
)
Value:
do { \
vp = fr_pair_find_by_da(vps, NULL, _da); \
_field = (vp) ? vp->vp_uint8 : 0; \
} while (0)
fr_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
Definition: pair.c:693
fr_pair_t * vp

Definition at line 352 of file encode.c.

Function Documentation

◆ _encode_test_ctx()

static int _encode_test_ctx ( fr_tacacs_ctx_t proto_ctx)
static

Definition at line 1051 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 1060 of file encode.c.

+ Here is the call graph for this function:

◆ fr_tacacs_code_to_packet()

int fr_tacacs_code_to_packet ( fr_tacacs_packet_t pkt,
uint32_t  code 
)

Definition at line 36 of file encode.c.

+ Here is the caller graph for this function:

◆ fr_tacacs_encode()

ssize_t fr_tacacs_encode ( fr_dbuff_t dbuff,
uint8_t const *  original_packet,
char const *  secret,
size_t  secret_len,
unsigned int  code,
fr_pair_list_t vps 
)

Encode VPS into a raw TACACS packet.

4.1. The Authentication START Packet Body

1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 +-------------—+-------------—+-------------—+-------------—+ | action | priv_lvl | authen_type | authen_service | +-------------—+-------------—+-------------—+-------------—+ | user_len | port_len | rem_addr_len | data_len | +-------------—+-------------—+-------------—+-------------—+ | user ... +-------------—+-------------—+-------------—+-------------—+ | port ... +-------------—+-------------—+-------------—+-------------—+ | rem_addr ... +-------------—+-------------—+-------------—+-------------—+ | data... +-------------—+-------------—+-------------—+-------------—+

6.1. The Account REQUEST Packet Body

1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 +-------------—+-------------—+-------------—+-------------—+ | flags | authen_method | priv_lvl | authen_type | +-------------—+-------------—+-------------—+-------------—+ | authen_service | user_len | port_len | rem_addr_len | +-------------—+-------------—+-------------—+-------------—+ | arg_cnt | arg_1_len | arg_2_len | ... | +-------------—+-------------—+-------------—+-------------—+ | arg_N_len | user ... +-------------—+-------------—+-------------—+-------------—+ | port ... +-------------—+-------------—+-------------—+-------------—+ | rem_addr ... +-------------—+-------------—+-------------—+-------------—+ | arg_1 ... +-------------—+-------------—+-------------—+-------------—+ | arg_2 ... +-------------—+-------------—+-------------—+-------------—+ | ... +-------------—+-------------—+-------------—+-------------—+ | arg_N ... +-------------—+-------------—+-------------—+-------------—+

6.2. The Accounting REPLY Packet Body

1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 +-------------—+-------------—+-------------—+-------------—+ | server_msg len | data_len | +-------------—+-------------—+-------------—+-------------—+ | status | server_msg ... +-------------—+-------------—+-------------—+-------------—+ | data ... +-------------—+

Definition at line 363 of file encode.c.

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

◆ fr_tacacs_encode_proto()

static ssize_t fr_tacacs_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 1043 of file encode.c.

+ Here is the call graph for this function:

◆ tacacs_encode_body_arg_cnt()

static uint8_t tacacs_encode_body_arg_cnt ( fr_pair_list_t vps,
fr_dict_attr_t const *  da 
)
static

Encode a TACACS+ 'arg_N' fields.

Definition at line 133 of file encode.c.

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

◆ tacacs_encode_body_arg_n()

static ssize_t tacacs_encode_body_arg_n ( fr_dbuff_t dbuff,
uint8_t  arg_cnt,
uint8_t arg_len,
fr_pair_list_t vps,
fr_dict_attr_t const *  da 
)
static

Definition at line 182 of file encode.c.

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

◆ tacacs_encode_chap()

static ssize_t tacacs_encode_chap ( fr_dbuff_t dbuff,
fr_tacacs_packet_t packet,
fr_pair_list_t vps,
fr_dict_attr_t const *  da_chap,
fr_dict_attr_t const *  da_challenge 
)
static

Definition at line 310 of file encode.c.

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

◆ tacacs_encode_field()

static ssize_t tacacs_encode_field ( fr_dbuff_t dbuff,
fr_pair_list_t vps,
fr_dict_attr_t const *  da,
size_t  max_len 
)
static

Definition at line 291 of file encode.c.

+ Here is the call graph for this function:

Variable Documentation

◆ tacacs_tp_encode_proto

fr_test_point_proto_encode_t tacacs_tp_encode_proto
Initial value:
= {
.test_ctx = encode_test_ctx,
}
static ssize_t fr_tacacs_encode_proto(UNUSED TALLOC_CTX *ctx, fr_pair_list_t *vps, uint8_t *data, size_t data_len, void *proto_ctx)
Definition: encode.c:1043
static int encode_test_ctx(void **out, TALLOC_CTX *ctx)
Definition: encode.c:1060

Definition at line 1081 of file encode.c.