Low-Level TACACS+ decoding functions.
More...
#include <freeradius-devel/io/test_point.h>
#include <freeradius-devel/protocol/tacacs/tacacs.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/net.h>
#include <freeradius-devel/util/struct.h>
#include "tacacs.h"
#include "attrs.h"
Go to the source code of this file.
|
static int | _encode_test_ctx (fr_tacacs_ctx_t *proto_ctx) |
|
static int | decode_test_ctx (void **out, TALLOC_CTX *ctx) |
|
ssize_t | fr_tacacs_decode (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *vendor, uint8_t const *buffer, size_t buffer_len, const uint8_t *original, char const *const secret, size_t secret_len, int *code) |
| Decode a TACACS+ packet. More...
|
|
static ssize_t | fr_tacacs_decode_proto (TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len, void *proto_ctx) |
|
int | fr_tacacs_packet_to_code (fr_tacacs_packet_t const *pkt) |
|
static int | tacacs_decode_args (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t arg_cnt, uint8_t const *argv, uint8_t const *attrs, NDEBUG_UNUSED uint8_t const *end) |
| Decode a TACACS+ 'arg_N' fields. More...
|
|
static int | tacacs_decode_field (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *da, uint8_t const **field_data, uint16_t field_len, uint8_t const *end) |
| Decode a TACACS+ field. More...
|
|
Low-Level TACACS+ decoding functions.
- Id
- 65119e48ca57ab616f5788f3c64847b1039f66e4
- Copyright
- 2017 The FreeRADIUS server project
-
2017 Network RADIUS SAS (legal.nosp@m.@net.nosp@m.workr.nosp@m.adiu.nosp@m.s.com)
Definition in file decode.c.
◆ ARG_COUNT_CHECK
#define ARG_COUNT_CHECK |
( |
|
_msg, |
|
|
|
_hdr |
|
) |
| |
Value: do { \
fr_assert(p == (
uint8_t const *) &(_hdr)); \
if (data_len > (size_t) (end - p)) { \
fr_strerror_printf("Argument count %u overflows the remaining data (%zu) in the %s packet", _hdr.arg_cnt, end - p, _msg); \
goto fail; \
} \
argv = body; \
body += _hdr.arg_cnt; \
p = attrs; \
for (int i = 0; i < _hdr.arg_cnt; i++) { \
if (_hdr.arg_len[i] > (size_t) (end - p)) { \
fr_strerror_printf("Argument %u length %u overflows packet", i, _hdr.arg_len[i]); \
goto fail; \
} \
p += _hdr.arg_len[i]; \
} \
} while (0)
static int const char char buffer[256]
Definition at line 140 of file decode.c.
◆ BODY
#define BODY |
( |
|
_x | ) |
(((uint8_t const *) pkt) + sizeof(pkt->hdr) + sizeof(pkt->_x)) |
◆ DECODE_FIELD_STRING16
#define DECODE_FIELD_STRING16 |
( |
|
_da, |
|
|
|
_field |
|
) |
| |
Value: do { \
ntohs(_field), end) < 0) goto fail; \
static int tacacs_decode_field(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *da, uint8_t const **field_data, uint16_t field_len, uint8_t const *end)
Decode a TACACS+ field.
static size_t char ** out
Definition at line 171 of file decode.c.
◆ DECODE_FIELD_STRING8
#define DECODE_FIELD_STRING8 |
( |
|
_da, |
|
|
|
_field |
|
) |
| |
Value: do { \
_field, end) < 0) goto fail; \
Definition at line 166 of file decode.c.
◆ DECODE_FIELD_UINT8
#define DECODE_FIELD_UINT8 |
( |
|
_da, |
|
|
|
_field |
|
) |
| |
Value: do { \
vp->vp_uint8 = _field; \
fr_pair_append(
out,
vp); \
} while (0)
fr_pair_t * fr_pair_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Dynamically allocate a new attribute and assign a fr_dict_attr_t.
Definition at line 159 of file decode.c.
◆ PACKET_HEADER_CHECK
#define PACKET_HEADER_CHECK |
( |
|
_msg, |
|
|
|
_hdr |
|
) |
| |
Value: do { \
if (sizeof(_hdr) > (size_t) (end - p)) { \
fr_strerror_printf(
"Header for %s is too small (%zu < %zu)", _msg, end - (
uint8_t const *) pkt, p - (
uint8_t const *) pkt); \
goto fail; \
} \
body = p + sizeof(_hdr); \
data_len = sizeof(_hdr); \
} while (0)
Definition at line 127 of file decode.c.
◆ _encode_test_ctx()
◆ decode_test_ctx()
static int decode_test_ctx |
( |
void ** |
out, |
|
|
TALLOC_CTX * |
ctx |
|
) |
| |
|
static |
◆ fr_tacacs_decode()
Decode a 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 409 of file decode.c.
◆ fr_tacacs_decode_proto()
◆ fr_tacacs_packet_to_code()
◆ tacacs_decode_args()
Decode a TACACS+ 'arg_N' fields.
Definition at line 181 of file decode.c.
◆ tacacs_decode_field()
Decode a TACACS+ field.
Definition at line 371 of file decode.c.
◆ tacacs_tp_decode_proto
Initial value:= {
}
static ssize_t fr_tacacs_decode_proto(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len, void *proto_ctx)
static int decode_test_ctx(void **out, TALLOC_CTX *ctx)
Definition at line 1110 of file decode.c.