The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Typedefs | Enumerations
proto.h File Reference

Encoder/decoder library interface. More...

#include <freeradius-devel/server/dl_module.h>
#include <freeradius-devel/util/value.h>
+ Include dependency graph for proto.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  fr_proto_lib_t
 The public structure exported by protocol encoding/decoding libraries. More...
 
struct  fr_proto_stack_frame_t
 A protocol transcoder stack frame. More...
 
struct  fr_proto_stack_t
 Protocol transcoder stack. More...
 

Macros

#define FR_PROTO_STACK_MAX   10
 

Typedefs

typedef ssize_t(* fr_proto_decode_t) (void *proto_ctx, uint8_t const *data, size_t data_len)
 Decode a packet header. More...
 
typedef ssize_t(* fr_proto_encode_t) (void *proto_ctx, uint8_t *buffer, size_t buffer_len)
 Encode a packet header. More...
 
typedef int(* fr_proto_get_option_t) (fr_value_box_t *out, void const *proto_ctx, fr_proto_opt_group_t opt_group, int opt)
 Retrieve a protocol option. More...
 
typedef void(* fr_proto_invert_t) (void *proto_ctx)
 Invert the src and address fields of a proto_ctx. More...
 
typedef int(* fr_proto_set_option_t) (void *proto_ctx, fr_proto_opt_group_t opt_group, int opt, fr_value_box_t *in)
 Set a protocol option. More...
 

Enumerations

enum  fr_proto_opt_app_t { PROTO_OPT_PAIRS = 0 }
 Application options. More...
 
enum  fr_proto_opt_group_t {
  PROTO_OPT_GROUP_CUSTOM = 0x01 ,
  PROTO_OPT_GROUP_L2 = 0x02 ,
  PROTO_OPT_GROUP_L3 = 0x04 ,
  PROTO_OPT_GROUP_L4 = 0x08 ,
  PROTO_OPT_GROUP_APPLICATION = 0x10
}
 Option contexts. More...
 
enum  fr_proto_opt_l2_t {
  PROTO_OPT_L2_PAYLOAD_LEN = 0 ,
  PROTO_OPT_L2_SRC_ADDRESS ,
  PROTO_OPT_L2_DST_ADDRESS ,
  PROTO_OPT_L2_NEXT_PROTOCOL
}
 Layer 2 options such as Media addresses. More...
 
enum  fr_proto_opt_l3_t {
  PROTO_OPT_L3_PAYLOAD_LEN = 0 ,
  PROTO_OPT_L3_SRC_ADDRESS ,
  PROTO_OPT_L3_DST_ADDRESS ,
  PROTO_OPT_L3_NEXT_PROTOCOL
}
 Layer 3 options, such as IP address. More...
 
enum  fr_proto_opt_l4_t {
  PROTO_OPT_L4_PAYLOAD_LEN = 0 ,
  PROTO_OPT_L4_SRC_PORT ,
  PROTO_OPT_L4_DST_PORT
}
 Layer 4 options, such as port number. More...
 

Detailed Description

Encoder/decoder library interface.

Id
75da1a0a62c951adc7381bef65040c1a355c910b

Definition in file proto.h.


Data Structure Documentation

◆ fr_proto_lib_t

struct fr_proto_lib_t

The public structure exported by protocol encoding/decoding libraries.

Definition at line 157 of file proto.h.

+ Collaboration diagram for fr_proto_lib_t:
Data Fields
fr_proto_decode_t decode Function to decode a protocol/header.
DL_MODULE_COMMON Common fields to all loadable modules.
fr_proto_encode_t encode Function to encode a protocol/header.
fr_proto_get_option_t get_option Get data from the proto_ctx.
fr_proto_invert_t invert
int opt_group Option groups implemented by proto lib.
size_t proto_ctx_size Size required for the packet ctx structure.
fr_proto_set_option_t set_option Set data in the proto_ctx.

◆ fr_proto_stack_frame_t

struct fr_proto_stack_frame_t

A protocol transcoder stack frame.

Definition at line 174 of file proto.h.

+ Collaboration diagram for fr_proto_stack_frame_t:
Data Fields
fr_proto_lib_t const * proto Protocol library.
void * proto_ctx Packet ctx produced by the decoder, or populated for consumption by the encoder.

◆ fr_proto_stack_t

struct fr_proto_stack_t

Protocol transcoder stack.

Describes a series of encoders/decoders data must pass through

Definition at line 185 of file proto.h.

+ Collaboration diagram for fr_proto_stack_t:
Data Fields
int depth
fr_proto_stack_frame_t frame[FR_PROTO_STACK_MAX+1]

Macro Definition Documentation

◆ FR_PROTO_STACK_MAX

#define FR_PROTO_STACK_MAX   10

Definition at line 29 of file proto.h.

Typedef Documentation

◆ fr_proto_decode_t

typedef ssize_t(* fr_proto_decode_t) (void *proto_ctx, uint8_t const *data, size_t data_len)

Decode a packet header.

This function is the opposite of fr_proto_encode_t.

The "decode" function is ONLY for decoding data. It should be aware of the protocol (e.g. RADIUS), but it MUST NOT know anything about the underlying network transport (e.g. UDP), and it MUST NOT know anything about how the data will be used.

Parameters
[out]proto_ctxpopulated with information learned from the packet header.
[in]datathe raw packet data.
[in]data_lenthe length of the raw data.
Returns
  • >0 the number of bytes consumed.
  • <=0 the offset (as a negative integer), of where a parsing error occurred.

Definition at line 98 of file proto.h.

◆ fr_proto_encode_t

typedef ssize_t(* fr_proto_encode_t) (void *proto_ctx, uint8_t *buffer, size_t buffer_len)

Encode a packet header.

This function is the opposite of fr_proto_decode_t.

The "encode" function is ONLY for encoding data. It should be aware of the protocol (e.g. RADIUS), but it MUST NOT know anything about the underlying network transport (e.g. UDP), and it MUST NOT know anything about how the data will be used (e.g. reject delay on Access-Reject)

Parameters
[in]proto_ctxas created by fr_proto_decode_t.
[out]bufferthe buffer where the raw packet will be written.
[in]buffer_lenthe length of the buffer.
Returns
  • <0 on error. May indicate the number of bytes (as a negative) offset, that would have been needed to encode the total packet data.
  • >=0 length of the encoded data in the buffer, will be <=buffer_len

Definition at line 118 of file proto.h.

◆ fr_proto_get_option_t

typedef int(* fr_proto_get_option_t) (fr_value_box_t *out, void const *proto_ctx, fr_proto_opt_group_t opt_group, int opt)

Retrieve a protocol option.

Parameters
[in]outboxed value containing the option.
[in]proto_ctxto retrieve data from.
[in]opt_groupOption group to use.
[in]optto retrieve.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 138 of file proto.h.

◆ fr_proto_invert_t

typedef void(* fr_proto_invert_t) (void *proto_ctx)

Invert the src and address fields of a proto_ctx.

This is used to create a response to a decoded packet.

Parameters
[in]proto_ctxto manipulate.

Definition at line 126 of file proto.h.

◆ fr_proto_set_option_t

typedef int(* fr_proto_set_option_t) (void *proto_ctx, fr_proto_opt_group_t opt_group, int opt, fr_value_box_t *in)

Set a protocol option.

Parameters
[in]proto_ctxto set option in.
[in]opt_groupOption group to use.
[in]optto set.
[in]invalue to set.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 151 of file proto.h.

Enumeration Type Documentation

◆ fr_proto_opt_app_t

Application options.

Enumerator
PROTO_OPT_PAIRS 

Attribute Value Pairs belonging to the application.

Definition at line 77 of file proto.h.

◆ fr_proto_opt_group_t

Option contexts.

Exported by the protocol library. Indicates which option contexts the library implements.

Enumerator
PROTO_OPT_GROUP_CUSTOM 

Custom options exported by the library.

See library header file for more information.

PROTO_OPT_GROUP_L2 

Generic layer 2 options.

PROTO_OPT_GROUP_L3 

Generic layer 3 options.

PROTO_OPT_GROUP_L4 

Generic layer 4 options.

PROTO_OPT_GROUP_APPLICATION 

Generic application options.

Definition at line 36 of file proto.h.

◆ fr_proto_opt_l2_t

Layer 2 options such as Media addresses.

Enumerator
PROTO_OPT_L2_PAYLOAD_LEN 
PROTO_OPT_L2_SRC_ADDRESS 

Source address.

PROTO_OPT_L2_DST_ADDRESS 

Destination address.

PROTO_OPT_L2_NEXT_PROTOCOL 

Next protocol (if available).

Definition at line 48 of file proto.h.

◆ fr_proto_opt_l3_t

Layer 3 options, such as IP address.

Enumerator
PROTO_OPT_L3_PAYLOAD_LEN 

The size of payload data.

PROTO_OPT_L3_SRC_ADDRESS 

Source address.

PROTO_OPT_L3_DST_ADDRESS 

Destination address.

PROTO_OPT_L3_NEXT_PROTOCOL 

Next protocol (if available).

Definition at line 58 of file proto.h.

◆ fr_proto_opt_l4_t

Layer 4 options, such as port number.

Enumerator
PROTO_OPT_L4_PAYLOAD_LEN 

The size of payload data.

PROTO_OPT_L4_SRC_PORT 

Source port.

PROTO_OPT_L4_DST_PORT 

Destination port.

Definition at line 68 of file proto.h.