All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
proto_bfd.c File Reference
#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/protocol.h>
#include <freeradius-devel/modules.h>
#include <freeradius-devel/rad_assert.h>
#include <freeradius-devel/event.h>
#include <freeradius-devel/md5.h>
#include <freeradius-devel/sha1.h>
+ Include dependency graph for proto_bfd.c:

Go to the source code of this file.

Data Structures

struct  bfd_auth_basic_t
 
struct  bfd_auth_md5_t
 
struct  bfd_auth_sha1_t
 
struct  bfd_auth_simple_t
 
union  bfd_auth_t
 
struct  bfd_packet_t
 
struct  bfd_state_t
 

Macros

#define BFD_AUTH_INVALID   (BFD_AUTH_MET_KEYED_SHA1 + 1)
 
#define BFD_MAX_SECRET_LENGTH   20
 
#define FORWARD   len = strlen(buffer); if (len >= (bufsize + 1)) return 0;buffer += len;bufsize -= len
 
#define USEC   (1000000)
 

Typedefs

typedef struct bfd_auth_basic_t bfd_auth_basic_t
 
typedef struct bfd_auth_md5_t bfd_auth_md5_t
 
typedef struct bfd_auth_sha1_t bfd_auth_sha1_t
 
typedef struct bfd_auth_simple_t bfd_auth_simple_t
 
typedef union bfd_auth_t bfd_auth_t
 
typedef enum bfd_auth_type_t bfd_auth_type_t
 
typedef enum bfd_diag_t bfd_diag_t
 
typedef enum bfd_session_state_t bfd_session_state_t
 
typedef struct bfd_state_t bfd_state_t
 

Enumerations

enum  bfd_auth_type_t {
  BFD_AUTH_RESERVED = 0,
  BFD_AUTH_SIMPLE,
  BFD_AUTH_KEYED_MD5,
  BFD_AUTH_MET_KEYED_MD5,
  BFD_AUTH_KEYED_SHA1,
  BFD_AUTH_MET_KEYED_SHA1
}
 
enum  bfd_diag_t {
  BFD_DIAG_NONE = 0,
  BFD_CTRL_EXPIRED,
  BFD_ECHO_FAILED,
  BFD_NEIGHBOR_DOWN,
  BFD_FORWARD_PLANE_RESET,
  BFD_PATH_DOWN,
  BFD_CONCATENATED_PATH_DOWN,
  BFD_ADMIN_DOWN,
  BFD_REVERSE_CONCAT_PATH_DOWN
}
 
enum  bfd_session_state_t {
  BFD_STATE_ADMIN_DOWN = 0,
  BFD_STATE_DOWN,
  BFD_STATE_INIT,
  BFD_STATE_UP
}
 

Functions

struct bfd_packet_t __attribute__ ((packed))
 
static void bfd_auth_md5 (bfd_state_t *session, bfd_packet_t *bfd)
 
static void bfd_auth_sha1 (bfd_state_t *session, bfd_packet_t *bfd)
 
static int bfd_authenticate (bfd_state_t *session, bfd_packet_t *bfd)
 
static void bfd_calc_md5 (bfd_state_t *session, bfd_packet_t *bfd)
 
static void bfd_calc_sha1 (bfd_state_t *session, bfd_packet_t *bfd)
 
static void bfd_control_packet_init (bfd_state_t *session, bfd_packet_t *bfd)
 
static void bfd_detection_timeout (void *ctx, struct timeval *now)
 
void bfd_init (fr_event_list_t *xel)
 
static int bfd_init_sessions (CONF_SECTION *cs, bfd_socket_t *sock, int sockfd)
 
static bfd_state_tbfd_new_session (bfd_socket_t *sock, int sockfd, CONF_SECTION *cs, const fr_ipaddr_t *ipaddr, uint16_t port)
 
static int bfd_parse_ip_port (CONF_SECTION *cs, fr_ipaddr_t *ipaddr, uint16_t *port)
 
static ssize_t bfd_parse_secret (CONF_SECTION *cs, uint8_t secret[BFD_MAX_SECRET_LENGTH])
 
static void bfd_poll_response (bfd_state_t *session)
 
static int bfd_process (bfd_state_t *session, bfd_packet_t *bfd)
 
static void bfd_request (bfd_state_t *session, REQUEST *request, RADIUS_PACKET *packet)
 
static void bfd_send_packet (void *ctx, UNUSED struct timeval *now)
 
static int bfd_session_cmp (const void *one, const void *two)
 
static void bfd_session_free (void *ctx)
 
static void bfd_set_desired_min_tx_interval (bfd_state_t *session, uint32_t value)
 
static void bfd_set_timeout (bfd_state_t *session, struct timeval *when)
 
static void bfd_sign (bfd_state_t *session, bfd_packet_t *bfd)
 
static int bfd_socket_decode (UNUSED rad_listen_t *listener, UNUSED REQUEST *request)
 
static int bfd_socket_encode (UNUSED rad_listen_t *listener, UNUSED REQUEST *request)
 
static void bfd_socket_free (rad_listen_t *this)
 
static int bfd_socket_open (CONF_SECTION *cs, rad_listen_t *this)
 
static int bfd_socket_parse (CONF_SECTION *cs, rad_listen_t *this)
 
static int bfd_socket_print (const rad_listen_t *this, char *buffer, size_t bufsize)
 
static int bfd_socket_recv (rad_listen_t *listener)
 
static int bfd_socket_send (UNUSED rad_listen_t *listener, UNUSED REQUEST *request)
 
static int bfd_start_control (bfd_state_t *session)
 
static int bfd_start_packets (bfd_state_t *session)
 
static int bfd_start_poll (bfd_state_t *session)
 
static int bfd_stop_control (bfd_state_t *session)
 
static int bfd_stop_poll (bfd_state_t *session)
 
static void bfd_trigger (bfd_state_t *session)
 
static int bfd_verify_md5 (bfd_state_t *session, bfd_packet_t *bfd)
 
static int bfd_verify_sequence (bfd_state_t *session, uint32_t sequence_no, int keyed)
 
static int bfd_verify_sha1 (bfd_state_t *session, bfd_packet_t *bfd)
 

Variables

bfd_auth_t auth
 
unsigned int auth_present
 
static const FR_NAME_NUMBER auth_types []
 
 bfd_socket_t
 
static const char * bfd_state []
 
unsigned int control_plane_independent
 
unsigned int demand
 
uint32_t desired_min_tx_interval
 
uint8_t detect_multi
 
unsigned int diag
 
static fr_event_list_tel = NULL
 
unsigned int final
 
uint8_t length
 
uint32_t min_echo_rx_interval
 
unsigned int multipoint
 
uint32_t my_disc
 
unsigned int poll
 
fr_protocol_t proto_bfd
 
uint32_t required_min_rx_interval
 
unsigned int state
 
unsigned int version
 
uint32_t your_disc
 

Data Structure Documentation

struct bfd_auth_basic_t

Definition at line 132 of file proto_bfd.c.

Data Fields
uint8_t auth_len
uint8_t auth_type
uint8_t key_id
struct bfd_auth_md5_t

Definition at line 146 of file proto_bfd.c.

Data Fields
uint8_t auth_len
uint8_t auth_type
uint8_t digest[MD5_DIGEST_LENGTH]
uint8_t key_id
uint8_t reserved
uint32_t sequence_no
struct bfd_auth_sha1_t

Definition at line 155 of file proto_bfd.c.

Data Fields
uint8_t auth_len
uint8_t auth_type
uint8_t digest[SHA1_DIGEST_LENGTH]
uint8_t key_id
uint8_t reserved
uint32_t sequence_no
struct bfd_auth_simple_t

Definition at line 139 of file proto_bfd.c.

Data Fields
uint8_t auth_len
uint8_t auth_type
uint8_t key_id
uint8_t password[16]
union bfd_auth_t

Definition at line 164 of file proto_bfd.c.

+ Collaboration diagram for bfd_auth_t:
Data Fields
bfd_auth_basic_t basic
bfd_auth_md5_t md5
bfd_auth_simple_t password
bfd_auth_sha1_t sha1
struct bfd_packet_t

Definition at line 175 of file proto_bfd.c.

+ Collaboration diagram for bfd_packet_t:
Data Fields
bfd_auth_t auth
unsigned int auth_present: 1
unsigned int control_plane_independent: 1
unsigned int demand: 1
uint32_t desired_min_tx_interval
uint8_t detect_multi
unsigned int diag: 5
unsigned int final: 1
uint8_t length
uint32_t min_echo_rx_interval
unsigned int multipoint: 1
uint32_t my_disc
unsigned int poll: 1
uint32_t required_min_rx_interval
unsigned int state: 2
unsigned int version: 3
uint32_t your_disc
struct bfd_state_t

Definition at line 64 of file proto_bfd.c.

+ Collaboration diagram for bfd_state_t:
Data Fields
int auth_seq_known
bfd_auth_type_t auth_type
bool demand_mode
uint32_t desired_min_tx_interval
int detect_multi
uint32_t detection_time
int detection_timeouts
int doing_poll
fr_event_list_t * el
fr_event_t * ev_packet
fr_event_t * ev_timeout
struct timeval last_recv
struct timeval last_sent
bfd_diag_t local_diag
uint32_t local_disc
fr_ipaddr_t local_ipaddr
uint16_t local_port
uint32_t my_min_echo_rx_interval
uint32_t next_min_tx_interval
struct timeval next_recv
int number
int passive
uint32_t recv_auth_seq
bool remote_demand_mode
uint32_t remote_disc
fr_ipaddr_t remote_ipaddr
uint32_t remote_min_echo_rx_interval
uint32_t remote_min_rx_interval
uint16_t remote_port
bfd_session_state_t remote_session_state
struct sockaddr_storage remote_sockaddr
uint32_t required_min_rx_interval
socklen_t salen
uint8_t secret[BFD_MAX_SECRET_LENGTH]
size_t secret_len
const char * server
bfd_session_state_t session_state
int sockfd
uint32_t xmit_auth_seq

Macro Definition Documentation

#define BFD_AUTH_INVALID   (BFD_AUTH_MET_KEYED_SHA1 + 1)

Definition at line 62 of file proto_bfd.c.

#define BFD_MAX_SECRET_LENGTH   20

Definition at line 32 of file proto_bfd.c.

#define FORWARD   len = strlen(buffer); if (len >= (bufsize + 1)) return 0;buffer += len;bufsize -= len
#define USEC   (1000000)

Definition at line 31 of file proto_bfd.c.

Typedef Documentation

typedef union bfd_auth_t bfd_auth_t
typedef enum bfd_diag_t bfd_diag_t
typedef struct bfd_state_t bfd_state_t

Enumeration Type Documentation

Enumerator
BFD_AUTH_RESERVED 
BFD_AUTH_SIMPLE 
BFD_AUTH_KEYED_MD5 
BFD_AUTH_MET_KEYED_MD5 
BFD_AUTH_KEYED_SHA1 
BFD_AUTH_MET_KEYED_SHA1 

Definition at line 53 of file proto_bfd.c.

enum bfd_diag_t
Enumerator
BFD_DIAG_NONE 
BFD_CTRL_EXPIRED 
BFD_ECHO_FAILED 
BFD_NEIGHBOR_DOWN 
BFD_FORWARD_PLANE_RESET 
BFD_PATH_DOWN 
BFD_CONCATENATED_PATH_DOWN 
BFD_ADMIN_DOWN 
BFD_REVERSE_CONCAT_PATH_DOWN 

Definition at line 41 of file proto_bfd.c.

Enumerator
BFD_STATE_ADMIN_DOWN 
BFD_STATE_DOWN 
BFD_STATE_INIT 
BFD_STATE_UP 

Definition at line 34 of file proto_bfd.c.

Function Documentation

struct bfd_packet_t __attribute__ ( (packed)  )

Definition at line 206 of file proto_bfd.c.

static void bfd_auth_md5 ( bfd_state_t session,
bfd_packet_t bfd 
)
static

Definition at line 641 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void bfd_auth_sha1 ( bfd_state_t session,
bfd_packet_t bfd 
)
static

Definition at line 710 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int bfd_authenticate ( bfd_state_t session,
bfd_packet_t bfd 
)
static

Definition at line 764 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void bfd_calc_md5 ( bfd_state_t session,
bfd_packet_t bfd 
)
static

Definition at line 625 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void bfd_calc_sha1 ( bfd_state_t session,
bfd_packet_t bfd 
)
static

Definition at line 694 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void bfd_control_packet_init ( bfd_state_t session,
bfd_packet_t bfd 
)
static

Definition at line 785 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void bfd_detection_timeout ( void *  ctx,
struct timeval *  now 
)
static

Definition at line 1090 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void bfd_init ( fr_event_list_t xel)

Definition at line 240 of file proto_bfd.c.

static int bfd_init_sessions ( CONF_SECTION cs,
bfd_socket_t sock,
int  sockfd 
)
static

Definition at line 1576 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bfd_state_t* bfd_new_session ( bfd_socket_t sock,
int  sockfd,
CONF_SECTION cs,
const fr_ipaddr_t ipaddr,
uint16_t  port 
)
static

Definition at line 464 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int bfd_parse_ip_port ( CONF_SECTION cs,
fr_ipaddr_t ipaddr,
uint16_t *  port 
)
static

Definition at line 1540 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ssize_t bfd_parse_secret ( CONF_SECTION cs,
uint8_t  secret[BFD_MAX_SECRET_LENGTH] 
)
static

Definition at line 424 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void bfd_poll_response ( bfd_state_t session)
static

Definition at line 1135 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int bfd_process ( bfd_state_t session,
bfd_packet_t bfd 
)
static

Definition at line 1157 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void bfd_request ( bfd_state_t session,
REQUEST request,
RADIUS_PACKET packet 
)
static

Definition at line 376 of file proto_bfd.c.

+ Here is the caller graph for this function:

static void bfd_send_packet ( void *  ctx,
UNUSED struct timeval *  now 
)
static

Definition at line 860 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int bfd_session_cmp ( const void *  one,
const void *  two 
)
static

Definition at line 1636 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void bfd_session_free ( void *  ctx)
static

Definition at line 407 of file proto_bfd.c.

+ Here is the caller graph for this function:

static void bfd_set_desired_min_tx_interval ( bfd_state_t session,
uint32_t  value 
)
static

Definition at line 1064 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void bfd_set_timeout ( bfd_state_t session,
struct timeval *  when 
)
static

Definition at line 939 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void bfd_sign ( bfd_state_t session,
bfd_packet_t bfd 
)
static

Definition at line 833 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int bfd_socket_decode ( UNUSED rad_listen_t listener,
UNUSED REQUEST request 
)
static

Definition at line 1630 of file proto_bfd.c.

static int bfd_socket_encode ( UNUSED rad_listen_t listener,
UNUSED REQUEST request 
)
static

Definition at line 1623 of file proto_bfd.c.

static void bfd_socket_free ( rad_listen_t this)
static

Definition at line 1644 of file proto_bfd.c.

+ Here is the call graph for this function:

static int bfd_socket_open ( CONF_SECTION cs,
rad_listen_t this 
)
static

Definition at line 1739 of file proto_bfd.c.

+ Here is the call graph for this function:

static int bfd_socket_parse ( CONF_SECTION cs,
rad_listen_t this 
)
static

Definition at line 1665 of file proto_bfd.c.

+ Here is the call graph for this function:

static int bfd_socket_print ( const rad_listen_t this,
char *  buffer,
size_t  bufsize 
)
static

Definition at line 1781 of file proto_bfd.c.

+ Here is the call graph for this function:

static int bfd_socket_recv ( rad_listen_t listener)
static

Definition at line 1415 of file proto_bfd.c.

+ Here is the call graph for this function:

static int bfd_socket_send ( UNUSED rad_listen_t listener,
UNUSED REQUEST request 
)
static

Definition at line 1616 of file proto_bfd.c.

static int bfd_start_control ( bfd_state_t session)
static

Definition at line 978 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int bfd_start_packets ( bfd_state_t session)
static

Definition at line 886 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int bfd_start_poll ( bfd_state_t session)
static

Definition at line 1010 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int bfd_stop_control ( bfd_state_t session)
static

Definition at line 1002 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int bfd_stop_poll ( bfd_state_t session)
static

Definition at line 1031 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void bfd_trigger ( bfd_state_t session)
static

Definition at line 392 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int bfd_verify_md5 ( bfd_state_t session,
bfd_packet_t bfd 
)
static

Definition at line 655 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int bfd_verify_sequence ( bfd_state_t session,
uint32_t  sequence_no,
int  keyed 
)
static

Definition at line 598 of file proto_bfd.c.

+ Here is the caller graph for this function:

static int bfd_verify_sha1 ( bfd_state_t session,
bfd_packet_t bfd 
)
static

Definition at line 724 of file proto_bfd.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

bfd_auth_t auth

Definition at line 209 of file proto_bfd.c.

unsigned int auth_present

Definition at line 196 of file proto_bfd.c.

const FR_NAME_NUMBER auth_types[]
static
Initial value:
= {
{ "none", BFD_AUTH_RESERVED },
{ "simple", BFD_AUTH_SIMPLE },
{ "keyed-md5", BFD_AUTH_KEYED_MD5 },
{ "met-keyed-md5", BFD_AUTH_MET_KEYED_MD5 },
{ "keyed-sha1", BFD_AUTH_KEYED_SHA1 },
{ "met-keyed-sha1", BFD_AUTH_MET_KEYED_SHA1 },
{ NULL, 0 }
}

Definition at line 1653 of file proto_bfd.c.

bfd_socket_t

Definition at line 228 of file proto_bfd.c.

const char* bfd_state[]
static
Initial value:
= {
"admin-down",
"down",
"init",
"up"
}

Definition at line 368 of file proto_bfd.c.

unsigned int control_plane_independent

Definition at line 197 of file proto_bfd.c.

unsigned int demand

Definition at line 195 of file proto_bfd.c.

uint32_t desired_min_tx_interval

Definition at line 206 of file proto_bfd.c.

uint8_t detect_multi

Definition at line 202 of file proto_bfd.c.

unsigned int diag

Definition at line 191 of file proto_bfd.c.

fr_event_list_t* el = NULL
static

Definition at line 236 of file proto_bfd.c.

unsigned int final

Definition at line 198 of file proto_bfd.c.

uint8_t length

Definition at line 203 of file proto_bfd.c.

uint32_t min_echo_rx_interval

Definition at line 208 of file proto_bfd.c.

unsigned int multipoint

Definition at line 194 of file proto_bfd.c.

uint32_t my_disc

Definition at line 204 of file proto_bfd.c.

unsigned int poll

Definition at line 199 of file proto_bfd.c.

fr_protocol_t proto_bfd
Initial value:
= {
.magic = RLM_MODULE_INIT,
.name = "bfd",
.inst_size = sizeof(bfd_socket_t),
.transports = TRANSPORT_UDP,
.tls = false,
.parse = bfd_socket_parse,
.open = bfd_socket_open,
.free = bfd_socket_free,
.recv = bfd_socket_recv,
.send = bfd_socket_send,
.print = bfd_socket_print,
.encode = bfd_socket_encode,
}
static int bfd_socket_decode(UNUSED rad_listen_t *listener, UNUSED REQUEST *request)
Definition: proto_bfd.c:1630
static int bfd_socket_open(CONF_SECTION *cs, rad_listen_t *this)
Definition: proto_bfd.c:1739
static int bfd_socket_parse(CONF_SECTION *cs, rad_listen_t *this)
Definition: proto_bfd.c:1665
void common_packet_debug(REQUEST *request, RADIUS_PACKET *packet, bool received)
Definition: listen.c:1153
#define RLM_MODULE_INIT
Definition: modules.h:86
static int bfd_socket_encode(UNUSED rad_listen_t *listener, UNUSED REQUEST *request)
Definition: proto_bfd.c:1623
#define TRANSPORT_UDP
Definition: protocol.h:62
static void bfd_socket_free(rad_listen_t *this)
Definition: proto_bfd.c:1644
bfd_socket_t
Definition: proto_bfd.c:228
static int bfd_socket_send(UNUSED rad_listen_t *listener, UNUSED REQUEST *request)
Definition: proto_bfd.c:1616
static int bfd_socket_print(const rad_listen_t *this, char *buffer, size_t bufsize)
Definition: proto_bfd.c:1781
static int bfd_socket_recv(rad_listen_t *listener)
Definition: proto_bfd.c:1415

Definition at line 1809 of file proto_bfd.c.

uint32_t required_min_rx_interval

Definition at line 207 of file proto_bfd.c.

unsigned int state

Definition at line 200 of file proto_bfd.c.

unsigned int version

Definition at line 192 of file proto_bfd.c.

uint32_t your_disc

Definition at line 205 of file proto_bfd.c.