Loading...
Searching...
No Matches
control_if.h
Go to the documentation of this file.
#pragma once
#include <osmocom/core/write_queue.h>
#include <osmocom/ctrl/control_cmd.h>
int ctrl_parse_get_num(vector vline, int i, long *num);
typedef int (*ctrl_cmd_lookup)(void *data, vector vline, int *node_type,
void **node_data, int *i);
typedef void (*ctrl_cmd_reply_cb)(struct ctrl_handle *ctrl, struct ctrl_cmd *cmd, void *data);
struct ctrl_handle {
struct osmo_fd listen_fd;
void *data;
ctrl_cmd_lookup lookup;
/* List of control connections */
struct llist_head ccon_list;
/* User defined GET/SET REPLY handler. User can set cmd->defer to 1 in
order to own and keep the cmd pointer and free it after the function
returns. "data" param is the user data pointer supplied during
ctrl_handle allocation */
ctrl_cmd_reply_cb reply_cb;
};
int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd);
int ctrl_cmd_send_trap(struct ctrl_handle *ctrl, const char *name, char *value);
struct ctrl_handle *ctrl_handle_alloc(void *ctx, void *data, ctrl_cmd_lookup lookup);
struct ctrl_handle *ctrl_handle_alloc2(void *ctx, void *data,
ctrl_cmd_lookup lookup,
unsigned int node_count);
struct ctrl_handle *ctrl_interface_setup(void *data, uint16_t port,
ctrl_cmd_lookup lookup);
struct ctrl_handle *ctrl_interface_setup_dynip(void *data,
const char *bind_addr,
uint16_t port,
ctrl_cmd_lookup lookup);
struct ctrl_handle *ctrl_interface_setup_dynip2(void *data,
const char *bind_addr,
uint16_t port,
ctrl_cmd_lookup lookup,
unsigned int node_count);
struct ctrl_connection *osmo_ctrl_conn_alloc(void *ctx, void *data);
int ctrl_cmd_handle(struct ctrl_handle *ctrl, struct ctrl_cmd *cmd, void *data);
struct ctrl_cmd *ctrl_cmd_exec_from_string(struct ctrl_handle *ch, const char *cmdstr);
int ctrl_lookup_register(ctrl_cmd_lookup lookup);
int ctrl_handle_msg(struct ctrl_handle *ctrl, struct ctrl_connection *ccon, struct msgb *msg);
control_cmd.h
ctrl_interface_setup_dynip
struct ctrl_handle * ctrl_interface_setup_dynip(void *data, const char *bind_addr, uint16_t port, ctrl_cmd_lookup lookup)
Setup CTRL interface on a given address.
Definition control_if.c:1025
ctrl_cmd_reply_cb
void(* ctrl_cmd_reply_cb)(struct ctrl_handle *ctrl, struct ctrl_cmd *cmd, void *data)
Definition control_if.h:12
ctrl_lookup_register
int ctrl_lookup_register(ctrl_cmd_lookup lookup)
Install a lookup helper function for control nodes This function is used by e.g.
Definition control_if.c:1040
ctrl_interface_setup_dynip2
struct ctrl_handle * ctrl_interface_setup_dynip2(void *data, const char *bind_addr, uint16_t port, ctrl_cmd_lookup lookup, unsigned int node_count)
Setup CTRL interface on a given address.
Definition control_if.c:990
ctrl_parse_get_num
int ctrl_parse_get_num(vector vline, int i, long *num)
Parse ascii-encoded decimal number at vline[i].
Definition control_if.c:81
osmo_ctrl_conn_alloc
struct ctrl_connection * osmo_ctrl_conn_alloc(void *ctx, void *data)
Allocate CTRL connection.
Definition control_if.c:504
ctrl_cmd_handle
int ctrl_cmd_handle(struct ctrl_handle *ctrl, struct ctrl_cmd *cmd, void *data)
Definition control_if.c:208
ctrl_handle_alloc
struct ctrl_handle * ctrl_handle_alloc(void *ctx, void *data, ctrl_cmd_lookup lookup)
Allocate a CTRL interface handle.
Definition control_if.c:966
ctrl_cmd_lookup
int(* ctrl_cmd_lookup)(void *data, vector vline, int *node_type, void **node_data, int *i)
Definition control_if.h:10
ctrl_handle_alloc2
struct ctrl_handle * ctrl_handle_alloc2(void *ctx, void *data, ctrl_cmd_lookup lookup, unsigned int node_count)
Allocate a CTRL interface handle.
Definition control_if.c:939
ctrl_interface_setup
struct ctrl_handle * ctrl_interface_setup(void *data, uint16_t port, ctrl_cmd_lookup lookup)
Definition control_if.c:878
ctrl_handle_msg
int ctrl_handle_msg(struct ctrl_handle *ctrl, struct ctrl_connection *ccon, struct msgb *msg)
Handle a received CTRL command contained in a Message buffers.
Definition control_if.c:382
ctrl_cmd_send
int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd)
Encode a CTRL command and append it to the given write queue.
Definition control_if.c:118
ctrl_cmd_send_trap
int ctrl_cmd_send_trap(struct ctrl_handle *ctrl, const char *name, char *value)
Send TRAP over given Control Interface.
Definition control_if.c:146
ctrl_cmd_exec_from_string
struct ctrl_cmd * ctrl_cmd_exec_from_string(struct ctrl_handle *ch, const char *cmdstr)
Helper for "local execution" of a CTRL command from a string The function will parse + execute the gi...
Definition control_if.c:1065
node_type
node_type
data
uint8_t data[0]
_vector
ctrl_cmd
Represents a single ctrl command after parsing.
Definition control_cmd.h:67
ctrl_cmd::ccon
struct ctrl_connection * ccon
connection through which the command was received
Definition control_cmd.h:69
ctrl_connection
Represents a single ctrl connection.
Definition control_cmd.h:45
ctrl_handle
Definition control_if.h:14
ctrl_handle::lookup
ctrl_cmd_lookup lookup
Definition control_if.h:18
ctrl_handle::data
void * data
Definition control_if.h:16
ctrl_handle::ccon_list
struct llist_head ccon_list
Definition control_if.h:21
ctrl_handle::reply_cb
ctrl_cmd_reply_cb reply_cb
Definition control_if.h:27
ctrl_handle::listen_fd
struct osmo_fd listen_fd
Definition control_if.h:15
llist_head
msgb
osmo_fd
osmo_wqueue
write_queue.h