totemudpu.c File Reference
`#include <config.h>`
`#include <assert.h>`
`#include <sys/mman.h>`
`#include <sys/types.h>`
`#include <sys/stat.h>`
`#include <sys/socket.h>`
`#include <netdb.h>`
`#include <sys/un.h>`
`#include <sys/ioctl.h>`
`#include <sys/param.h>`
`#include <netinet/in.h>`
`#include <arpa/inet.h>`
`#include <unistd.h>`
`#include <fcntl.h>`
`#include <stdlib.h>`
`#include <stdio.h>`
`#include <errno.h>`
`#include <sched.h>`
`#include <time.h>`
`#include <sys/time.h>`
`#include <sys/poll.h>`
`#include <sys/uio.h>`
`#include <limits.h>`
`#include <qb/qblist.h>`
`#include <qb/qbdefs.h>`
`#include <qb/qbloop.h>`
`#include <corosync/sq.h>`
`#include <corosync/swab.h>`
`#include <corosync/logsys.h>`
`#include "totemudpu.h"`
`#include "util.h"`
Include dependency graph for totemudpu.c:

Go to the source code of this file.

## Data Structures

struct | totemudpu_member
struct | totemudpu_instance
struct | work_item

## Macros

#define | LOGSYS_UTILS_ONLY 1
#define | MSG_NOSIGNAL 0
#define | MCAST_SOCKET_BUFFER_SIZE (TRANSMITS_ALLOWED * UDP_RECEIVE_FRAME_SIZE_MAX)
#define | NETIF_STATE_REPORT_UP 1
#define | NETIF_STATE_REPORT_DOWN 2
#define | BIND_STATE_UNBOUND 0
#define | BIND_STATE_REGULAR 1
#define | BIND_STATE_LOOPBACK 2
#define | log_printf(level, format, args...)
#define | LOGSYS_PERROR(err_num, level, fmt, args...)

## Functions

int | totemudpu_member_list_rebind_ip (void *udpu_context)
int | totemudpu_crypto_set (void *udpu_context, const char *cipher_type, const char *hash_type)
int | totemudpu_finalize (void *udpu_context)
int | totemudpu_nodestatus_get (void *udpu_context, unsigned int nodeid, struct totem_node_status *node_status)
int | totemudpu_ifaces_get (void *net_context, char ***status, unsigned int *iface_count)

int

totemudpu_initialize (qb_loop_t *poll_handle, void **udpu_context, struct totem_config *totem_config, totemsrp_stats_t *stats, void *context, int(*deliver_fn)(void *context, const void *msg, unsigned int msg_len, const struct sockaddr_storage *system_from), int(*iface_change_fn)(void *context, const struct totem_ip_address *iface_address, unsigned int ring_no), void(*mtu_changed)(void *context, int net_mtu), void(*target_set_completed)(void *context))

| Create an instance.
void * | totemudpu_buffer_alloc (void)
void | totemudpu_buffer_release (void *ptr)
int | totemudpu_processor_count_set (void *udpu_context, int processor_count)
int | totemudpu_recv_flush (void *udpu_context)
int | totemudpu_send_flush (void *udpu_context)
int | totemudpu_token_send (void *udpu_context, const void *msg, unsigned int msg_len)
int | totemudpu_mcast_flush_send (void *udpu_context, const void *msg, unsigned int msg_len)
int | totemudpu_mcast_noflush_send (void *udpu_context, const void *msg, unsigned int msg_len)
int | totemudpu_iface_check (void *udpu_context)
void | totemudpu_net_mtu_adjust (void *udpu_context, struct totem_config *totem_config)
int | totemudpu_token_target_set (void *udpu_context, unsigned int nodeid)
int | totemudpu_recv_mcast_empty (void *udpu_context)
int | totemudpu_iface_set (void *net_context, const struct totem_ip_address *local_addr, unsigned short ip_port, unsigned int iface_no)
int | totemudpu_member_add (void *udpu_context, const struct totem_ip_address *local, const struct totem_ip_address *member, int ring_no)
int | totemudpu_member_remove (void *udpu_context, const struct totem_ip_address *token_target, int ring_no)
int | totemudpu_reconfigure (void *udpu_context, struct totem_config *totem_config)

## Macro Definition Documentation

## BIND_STATE_LOOPBACK

#define BIND_STATE_LOOPBACK 2

Definition at line 83 of file totemudpu.c.

## BIND_STATE_REGULAR

#define BIND_STATE_REGULAR 1

Definition at line 82 of file totemudpu.c.

## BIND_STATE_UNBOUND

#define BIND_STATE_UNBOUND 0

Definition at line 81 of file totemudpu.c.

## log_printf

#define log_printf | ( |  | level,
|  |  | format,
|  |  | args...
| ) |  |

Value:
do { \
instance->totemudpu_log_printf ( \
level, instance->totemudpu_subsys_id, \
__FUNCTION__, __FILE__, __LINE__, \
(const char *)format, ##args); \
} while (0);
nodeid
unsigned int nodeid
Definition coroapi.h:0

Definition at line 227 of file totemudpu.c.

## LOGSYS_PERROR

#define LOGSYS_PERROR | ( |  | err_num,
|  |  | level,
|  |  | fmt,
|  |  | args...
| ) |  |

Value:
do { \
char _error_str[LOGSYS_MAX_PERROR_MSG_LEN]; \
const char *_error_ptr = qb_strerror_r(err_num, _error_str, sizeof(_error_str)); \
instance->totemudpu_log_printf ( \
level, instance->totemudpu_subsys_id, \
__FUNCTION__, __FILE__, __LINE__, \
fmt ": %s (%d)", ##args, _error_ptr, err_num); \
} while(0)
LOGSYS_MAX_PERROR_MSG_LEN
#define LOGSYS_MAX_PERROR_MSG_LEN
Definition logsys.h:87

Definition at line 234 of file totemudpu.c.

## LOGSYS_UTILS_ONLY

#define LOGSYS_UTILS_ONLY 1

Definition at line 67 of file totemudpu.c.

## MCAST_SOCKET_BUFFER_SIZE

#define MCAST_SOCKET_BUFFER_SIZE (TRANSMITS_ALLOWED * UDP_RECEIVE_FRAME_SIZE_MAX)

Definition at line 77 of file totemudpu.c.

## MSG_NOSIGNAL

#define MSG_NOSIGNAL 0

Definition at line 74 of file totemudpu.c.

## NETIF_STATE_REPORT_DOWN

#define NETIF_STATE_REPORT_DOWN 2

Definition at line 79 of file totemudpu.c.

## NETIF_STATE_REPORT_UP

#define NETIF_STATE_REPORT_UP 1

Definition at line 78 of file totemudpu.c.

## Function Documentation

## totemudpu_buffer_alloc()

void * totemudpu_buffer_alloc | ( | void |  | ) |

Definition at line 1049 of file totemudpu.c.

References FRAME_SIZE_MAX, and nodeid.

## totemudpu_buffer_release()

void totemudpu_buffer_release | ( | void * | ptr | ) |

Definition at line 1054 of file totemudpu.c.

References nodeid.

## totemudpu_crypto_set()

int totemudpu_crypto_set | ( | void * | udpu_context,
|  | const char * | cipher_type,
|  | const char * | hash_type
| ) |  |

Definition at line 244 of file totemudpu.c.

## totemudpu_finalize()

int totemudpu_finalize | ( | void * | udpu_context | ) |

Definition at line 423 of file totemudpu.c.

References totemudpu_instance::local_loop_sock, nodeid, totemudpu_instance::token_socket, totemudpu_instance::totemudpu_poll_handle, and totemudpu_instance::udpu_context.

## totemudpu_iface_check()

int totemudpu_iface_check | ( | void * | udpu_context | ) |

extern

Definition at line 1133 of file totemudpu.c.

References nodeid, and totemudpu_instance::udpu_context.

## totemudpu_iface_set()

int totemudpu_iface_set | ( | void * | net_context,
|  | const struct totem_ip_address * | local_addr,
|  | unsigned short | ip_port,
|  | unsigned int | iface_no
| ) |  |

Definition at line 1301 of file totemudpu.c.

## totemudpu_ifaces_get()

int totemudpu_ifaces_get | ( | void * | net_context,
|  | char *** | status,
|  | unsigned int * | iface_count
| ) |  |

Definition at line 825 of file totemudpu.c.

References INTERFACE_MAX, and nodeid.

## totemudpu_initialize()

int totemudpu_initialize | ( | qb_loop_t * | poll_handle,
|  | void ** | udpu_context,
|  | struct totem_config * | totem_config,
|  | totemsrp_stats_t * | stats,
|  | void * | context,
|  | int(*)(void *context, const void *msg, unsigned int msg_len, const struct sockaddr_storage *system_from) | deliver_fn,
|  | int(*)(void *context, const struct totem_ip_address *iface_address, unsigned int ring_no) | iface_change_fn,
|  | void(*)(void *context, int net_mtu) | mtu_changed,
|  | void(*)(void *context) | target_set_completed
| ) |  |

Create an instance.

Definition at line 953 of file totemudpu.c.

References totem_interface::bindnet, totemudpu_instance::context, totem_config::interfaces, totemudpu_instance::iov_buffer, totemudpu_instance::local_loop_sock, totem_logging_configuration::log_level_debug, totem_logging_configuration::log_level_error, totem_logging_configuration::log_level_notice, totem_logging_configuration::log_level_warning, totem_logging_configuration::log_printf, totem_logging_configuration::log_subsys_id, totem_config::node_id, nodeid, totem_ip_address::nodeid, totemudpu_instance::stats, totemudpu_instance::timer_netif_check_timeout, totemudpu_instance::totem_config, totemudpu_instance::totem_interface, totem_config::totem_logging_configuration, totemudpu_instance::totemudpu_deliver_fn, totemudpu_instance::totemudpu_iface_change_fn, totemudpu_instance::totemudpu_log_level_debug, totemudpu_instance::totemudpu_log_level_error, totemudpu_instance::totemudpu_log_level_notice, totemudpu_instance::totemudpu_log_level_security, totemudpu_instance::totemudpu_log_level_warning, totemudpu_instance::totemudpu_log_printf, totemudpu_instance::totemudpu_poll_handle, totemudpu_instance::totemudpu_subsys_id, totemudpu_instance::totemudpu_target_set_completed, UDP_RECEIVE_FRAME_SIZE_MAX, and totemudpu_instance::udpu_context.

## totemudpu_mcast_flush_send()

int totemudpu_mcast_flush_send | ( | void * | udpu_context,
|  | const void * | msg,
|  | unsigned int | msg_len
| ) |  |

Definition at line 1107 of file totemudpu.c.

References nodeid, and totemudpu_instance::udpu_context.

## totemudpu_mcast_noflush_send()

int totemudpu_mcast_noflush_send | ( | void * | udpu_context,
|  | const void * | msg,
|  | unsigned int | msg_len
| ) |  |

Definition at line 1120 of file totemudpu.c.

References nodeid, and totemudpu_instance::udpu_context.

## totemudpu_member_add()

int totemudpu_member_add | ( | void * | udpu_context,
|  | const struct totem_ip_address * | local,
|  | const struct totem_ip_address * | member,
|  | int | ring_no
| ) |  |

Definition at line 1310 of file totemudpu.c.

References log_printf, LOGSYS_LEVEL_NOTICE, totemudpu_member::member, totemudpu_instance::member_list, nodeid, totemip_print(), and totemudpu_instance::udpu_context.

## totemudpu_member_list_rebind_ip()

int totemudpu_member_list_rebind_ip | ( | void * | udpu_context | ) |

Definition at line 1386 of file totemudpu.c.

References totemudpu_member::fd, totemudpu_member::member, totemudpu_instance::member_list, nodeid, and totemudpu_instance::udpu_context.

## totemudpu_member_remove()

int totemudpu_member_remove | ( | void * | udpu_context,
|  | const struct totem_ip_address * | token_target,
|  | int | ring_no
| ) |  |

Definition at line 1338 of file totemudpu.c.

References totemudpu_member::fd, log_printf, LOGSYS_LEVEL_DEBUG, LOGSYS_LEVEL_NOTICE, totemudpu_member::member, totemudpu_instance::member_list, nodeid, totemudpu_instance::token_target, totemip_compare(), totemip_print(), totemudpu_instance::totemudpu_poll_handle, and totemudpu_instance::udpu_context.

## totemudpu_net_mtu_adjust()

void totemudpu_net_mtu_adjust | ( | void * | udpu_context,
|  | struct totem_config * | totem_config
| ) |  |

extern

Definition at line 1143 of file totemudpu.c.

References totem_interface::bindnet, totem_ip_address::family, totem_config::interfaces, totem_config::net_mtu, and totemip_udpip_header_size().

## totemudpu_nodestatus_get()

int totemudpu_nodestatus_get | ( | void * | udpu_context,
|  | unsigned int | nodeid,
|  | struct totem_node_status * | node_status
| ) |  |

Definition at line 797 of file totemudpu.c.

References BIND_STATE_REGULAR, totemudpu_member::list, totemudpu_member::member, totemudpu_instance::member_list, totem_config::net_mtu, totemudpu_instance::netif_bind_state, nodeid, totem_ip_address::nodeid, totemudpu_instance::totem_config, totemip_print(), and totemudpu_instance::udpu_context.

## totemudpu_processor_count_set()

int totemudpu_processor_count_set | ( | void * | udpu_context,
|  | int | processor_count
| ) |  |

Definition at line 1059 of file totemudpu.c.

References totem_config::downcheck_timeout, totemudpu_instance::my_memb_entries, nodeid, totemudpu_instance::timer_netif_check_timeout, totemudpu_instance::totem_config, totemudpu_instance::totemudpu_poll_handle, and totemudpu_instance::udpu_context.

## totemudpu_reconfigure()

int totemudpu_reconfigure | ( | void * | udpu_context,
|  | struct totem_config * | totem_config
| ) |  |

Definition at line 1447 of file totemudpu.c.

## totemudpu_recv_flush()

int totemudpu_recv_flush | ( | void * | udpu_context | ) |

Definition at line 1081 of file totemudpu.c.

References nodeid.

## totemudpu_recv_mcast_empty()

int totemudpu_recv_mcast_empty | ( | void * | udpu_context | ) |

extern

Definition at line 1175 of file totemudpu.c.

References BIND_STATE_REGULAR, totemudpu_instance::local_loop_sock, MSG_NOSIGNAL, totemudpu_instance::netif_bind_state, nodeid, system_from, totemudpu_instance::token_socket, totemudpu_instance::totemudpu_iov_recv, and totemudpu_instance::udpu_context.

## totemudpu_send_flush()

int totemudpu_send_flush | ( | void * | udpu_context | ) |

Definition at line 1088 of file totemudpu.c.

References nodeid.

## totemudpu_token_send()

int totemudpu_token_send | ( | void * | udpu_context,
|  | const void * | msg,
|  | unsigned int | msg_len
| ) |  |

Definition at line 1095 of file totemudpu.c.

References nodeid, totemudpu_instance::token_target, and totemudpu_instance::udpu_context.

## totemudpu_token_target_set()

int totemudpu_token_target_set | ( | void * | udpu_context,
|  | unsigned int | nodeid
| ) |  |

Definition at line 1149 of file totemudpu.c.

References totemudpu_instance::context, totemudpu_member::list, totemudpu_member::member, totemudpu_instance::member_list, nodeid, totem_ip_address::nodeid, totemudpu_instance::token_target, totemudpu_instance::totemudpu_target_set_completed, and totemudpu_instance::udpu_context.