blob: 6e49742d14557ad3635cb8c181225bd708a7fcbb [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file control_if.h */
2
Harald Welte5ddd4352014-08-21 15:42:44 +02003#pragma once
Alexander Huemer4376bcc2011-09-06 00:09:48 +02004
5#include <osmocom/core/write_queue.h>
Harald Welte1238cc62014-08-20 19:50:04 +02006#include <osmocom/ctrl/control_cmd.h>
7
Harald Welte528134b2014-08-21 15:13:08 +02008int ctrl_parse_get_num(vector vline, int i, long *num);
9
10typedef int (*ctrl_cmd_lookup)(void *data, vector vline, int *node_type,
11 void **node_data, int *i);
Holger Hans Peter Freytherea62a382014-03-23 16:25:16 +010012
Daniel Willmann782974b2011-07-22 17:55:42 +020013struct ctrl_handle {
14 struct osmo_fd listen_fd;
Harald Weltec78e74e2014-08-21 14:34:32 +020015 void *data;
Daniel Willmann782974b2011-07-22 17:55:42 +020016
Harald Welte528134b2014-08-21 15:13:08 +020017 ctrl_cmd_lookup lookup;
Holger Hans Peter Freytherea62a382014-03-23 16:25:16 +010018
Daniel Willmann782974b2011-07-22 17:55:42 +020019 /* List of control connections */
20 struct llist_head ccon_list;
21};
22
Holger Hans Peter Freytherea62a382014-03-23 16:25:16 +010023
Alexander Huemer4376bcc2011-09-06 00:09:48 +020024int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd);
Maxbc067eb2016-08-04 11:07:08 +020025int ctrl_cmd_send_trap(struct ctrl_handle *ctrl, const char *name, char *value);
Harald Welte79c137c2017-04-16 19:08:49 +020026struct ctrl_handle *ctrl_handle_alloc(void *ctx, void *data, ctrl_cmd_lookup lookup);
Harald Welteae2fcb22014-08-21 15:20:00 +020027struct ctrl_handle *ctrl_interface_setup(void *data, uint16_t port,
28 ctrl_cmd_lookup lookup);
Neels Hofmeyr49343092016-02-24 00:09:40 +010029struct ctrl_handle *ctrl_interface_setup_dynip(void *data,
30 const char *bind_addr,
31 uint16_t port,
32 ctrl_cmd_lookup lookup);
Maxfa9e05e2017-02-20 11:53:11 +010033struct ctrl_connection *osmo_ctrl_conn_alloc(void *ctx, void *data);
Harald Welte528134b2014-08-21 15:13:08 +020034int ctrl_cmd_handle(struct ctrl_handle *ctrl, struct ctrl_cmd *cmd, void *data);
Harald Weltef85861d2017-04-16 19:17:10 +020035struct ctrl_cmd *ctrl_cmd_exec_from_string(struct ctrl_handle *ch, const char *cmdstr);
Harald Welted6b1f852017-04-16 16:57:40 +020036
37int ctrl_lookup_register(ctrl_cmd_lookup lookup);