libosmo-netif 1.7.0.10-3a9e Osmocom network interface library

prim.h
1/* (C) 2021 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
2 * Author: Pau Espin Pedrol <pespin@sysmocom.de>
3 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/lienses/>.
17 *
18 */
19#pragma once
20
21#include <stdint.h>
22
23#include <osmocom/core/prim.h>
24#include <osmocom/core/select.h>
25#include <osmocom/core/linuxlist.h>
26
27 struct osmo_prim_srv_link;
28 struct osmo_prim_srv;
29
30 typedef int (*osmo_prim_srv_conn_cb)(struct osmo_prim_srv *prim_srv);
32 typedef int (*osmo_prim_srv_rx_cb)(struct osmo_prim_srv *prim_srv, struct osmo_prim_hdr *oph);
33
41 typedef int (*osmo_prim_srv_rx_sapi_version)(struct osmo_prim_srv *prim_srv, uint32_t sapi, uint16_t rem_version);
42
43 struct osmo_prim_hdr *osmo_prim_msgb_alloc(unsigned int sap, unsigned int primitive,
44 enum osmo_prim_operation operation, size_t alloc_len);
45
46 struct osmo_prim_srv_link *osmo_prim_srv_link_alloc(void *ctx);
47 void osmo_prim_srv_link_free(struct osmo_prim_srv_link *prim_link);
48 void osmo_prim_srv_link_set_name(struct osmo_prim_srv_link *prim_link, const char *name);
49 int osmo_prim_srv_link_set_addr(struct osmo_prim_srv_link *prim_link, const char *path);
50 const char *osmo_prim_srv_link_get_addr(struct osmo_prim_srv_link *prim_link);
51 void osmo_prim_srv_link_set_priv(struct osmo_prim_srv_link *prim_link, void *priv);
52 void *osmo_prim_srv_link_get_priv(const struct osmo_prim_srv_link *prim_link);
53 void osmo_prim_srv_link_set_log_category(struct osmo_prim_srv_link *prim_link, int log_cat);
54 void osmo_prim_srv_link_set_opened_conn_cb(struct osmo_prim_srv_link *prim_link, osmo_prim_srv_conn_cb opened_conn_cb);
55 void osmo_prim_srv_link_set_closed_conn_cb(struct osmo_prim_srv_link *prim_link, osmo_prim_srv_conn_cb closed_conn_cb);
56 void osmo_prim_srv_link_set_rx_sapi_version_cb(struct osmo_prim_srv_link *prim_link, osmo_prim_srv_rx_sapi_version rx_sapi_version_cb);
57 void osmo_prim_srv_link_set_rx_cb(struct osmo_prim_srv_link *prim_link, osmo_prim_srv_rx_cb rx_cb);
58 void osmo_prim_srv_link_set_rx_msgb_alloc_len(struct osmo_prim_srv_link *prim_link, size_t alloc_len);
59 int osmo_prim_srv_link_open(struct osmo_prim_srv_link *prim_link);
60
61 int osmo_prim_srv_send(struct osmo_prim_srv *prim_srv, struct msgb *msg);
62 struct osmo_prim_srv_link *osmo_prim_srv_get_link(struct osmo_prim_srv *prims_srv);
63 void osmo_prim_srv_set_name(struct osmo_prim_srv *prim_srv, const char *name);
64 void osmo_prim_srv_set_priv(struct osmo_prim_srv *prim_srv, void *priv);
65 void *osmo_prim_srv_get_priv(const struct osmo_prim_srv *prim_srv);
66 void osmo_prim_srv_close(struct osmo_prim_srv *prim_srv);