Harald Welte | 3e5ab69 | 2018-06-04 04:26:20 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <osmocom/core/select.h> |
| 4 | #include <osmocom/core/utils.h> |
Harald Welte | 1a36f33 | 2018-06-04 17:36:33 +0200 | [diff] [blame^] | 5 | #include <osmocom/vty/command.h> |
Harald Welte | 3e5ab69 | 2018-06-04 04:26:20 +0200 | [diff] [blame] | 6 | |
| 7 | #include <stdbool.h> |
| 8 | #include <linux/if.h> |
| 9 | |
Harald Welte | 1a36f33 | 2018-06-04 17:36:33 +0200 | [diff] [blame^] | 10 | #include "value_node.h" |
| 11 | |
Harald Welte | 3e5ab69 | 2018-06-04 04:26:20 +0200 | [diff] [blame] | 12 | /* information gathered from sysinfo(2) */ |
| 13 | struct osysmon_state_sysinfo { |
| 14 | unsigned long uptime_secs; |
| 15 | unsigned long loads[3]; |
| 16 | unsigned long freeram; |
| 17 | }; |
| 18 | |
| 19 | /* one network interface */ |
| 20 | struct osysmon_state_iface { |
| 21 | char name[IFNAMSIZ+1]; |
| 22 | uint32_t flags; /* enum net_device_flags IFF_* */ |
| 23 | uint8_t hwasddr[6]; |
| 24 | uint32_t ipaddr; |
| 25 | }; |
| 26 | |
| 27 | /* information gathered from RTNL via libmnl */ |
| 28 | struct osysmon_state_rtnl { |
| 29 | struct osysmon_state_iface iface[8]; |
| 30 | unsigned int num_iface; |
| 31 | struct { |
| 32 | char *ifname; |
| 33 | uint32_t ipaddr; |
| 34 | } default_route; |
| 35 | }; |
| 36 | |
Harald Welte | 1a36f33 | 2018-06-04 17:36:33 +0200 | [diff] [blame^] | 37 | #if 0 |
Harald Welte | 3e5ab69 | 2018-06-04 04:26:20 +0200 | [diff] [blame] | 38 | struct osysmon_state_gbproxy { |
| 39 | char ns_state[32]; |
| 40 | char bssgp_state[32]; |
| 41 | }; |
| 42 | |
| 43 | struct osysmon_state_bts { |
| 44 | bool rf_locked; |
| 45 | }; |
| 46 | |
| 47 | struct osysmon_state_bsc { |
| 48 | struct osysmon_state_bts bts[8]; |
| 49 | unsigned int num_bts; |
| 50 | char a_state[32]; |
| 51 | }; |
Harald Welte | 1a36f33 | 2018-06-04 17:36:33 +0200 | [diff] [blame^] | 52 | #endif |
Harald Welte | 3e5ab69 | 2018-06-04 04:26:20 +0200 | [diff] [blame] | 53 | |
| 54 | struct osysmon_state { |
| 55 | struct osysmon_state_sysinfo sysinfo; |
| 56 | struct osysmon_state_rtnl rtnl; |
Harald Welte | 1a36f33 | 2018-06-04 17:36:33 +0200 | [diff] [blame^] | 57 | |
| 58 | /* list of 'struct ctrl client' */ |
| 59 | struct llist_head ctrl_clients; |
Harald Welte | 3e5ab69 | 2018-06-04 04:26:20 +0200 | [diff] [blame] | 60 | }; |
Harald Welte | 1a36f33 | 2018-06-04 17:36:33 +0200 | [diff] [blame^] | 61 | |
| 62 | extern struct osysmon_state *g_oss; |
| 63 | |
| 64 | |
| 65 | |
| 66 | enum osysmon_vty_node { |
| 67 | CTRL_CLIENT_NODE = _LAST_OSMOVTY_NODE + 1, |
| 68 | CTRL_CLIENT_GETVAR_NODE, |
| 69 | }; |
| 70 | |
| 71 | |
| 72 | int osysmon_ctrl_go_parent(struct vty *vty); |
| 73 | int osysmon_ctrl_init(); |
| 74 | int osysmon_ctrl_poll(struct value_node *parent); |