libosmo-netif 1.6.0.16-c51c Osmocom network interface library

Loading...
Searching...
No Matches
ipa.h
1#ifndef _OSMO_NETIF_IPA_H_
2#define _OSMO_NETIF_IPA_H_
3
4#include <osmocom/gsm/protocol/ipaccess.h>
5#include <osmocom/gsm/ipa.h>
6
7/* This is like 'struct ipaccess_head' in libosmocore, but 'ipa_head' is
8 * actually the more apropriate name, so rather than making more code
9 * use the wrong name, let's keep the duplicate header definitions below */
10 struct ipa_head {
11 uint16_t len; /* network byte order */
12 uint8_t proto;
13 uint8_t data[0];
14} __attribute__ ((packed));
15
16 struct ipa_head_ext {
17 uint8_t proto;
18 uint8_t data[0];
19} __attribute__ ((packed));
20
21 struct osmo_ipa_msgb_cb {
22 uint8_t proto;
23 uint8_t proto_ext;
24} __attribute__ ((packed));
25
26
27/* We don't just cast to 'struct osmo_ipa_msgb_cb *', because that would
28 * break the strict aliasing rule. Casting to a reference to a union with
29 * a compatible struct member seems to be allowed, though, see:
30 * N1570 Committee Draft — April 12, 2011 ISO/IEC 9899:201x,
31 * Section 6.5, §7 */
32#define OSMO_IPA_MSGB_CB(__msg) (&((( \
33 union { \
34 unsigned long cb; \
35 struct osmo_ipa_msgb_cb _cb; \
36 } \
37 *)&((__msg)->cb[0]))->_cb))
38
39#define osmo_ipa_msgb_cb_proto(__x) OSMO_IPA_MSGB_CB(__x)->proto
40#define osmo_ipa_msgb_cb_proto_ext(__x) OSMO_IPA_MSGB_CB(__x)->proto_ext
41
42struct msgb *osmo_ipa_msg_alloc(int headroom);
43struct msgb *osmo_ipa_ext_msg_alloc(size_t headroom);
44
45void osmo_ipa_msg_push_header(struct msgb *msg, uint8_t proto);
46
47int osmo_ipa_process_msg(struct msgb *msg);
48
49struct osmo_fd;
50struct tlv_parsed;
51
52int osmo_ipa_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd, int server);
53int osmo_ipa_parse_unitid(const char *str, struct ipaccess_unit *unit_data);
54
55int ipaccess_send_pong(int fd);
56int ipaccess_send_id_ack(int fd);
57int ipaccess_send_id_req(int fd);
58
59struct osmo_ipa_unit;
60
61struct msgb *ipa_cli_id_resp(struct osmo_ipa_unit *dev, uint8_t *data, int len);
62struct msgb *ipa_cli_id_ack(void);
63
64int osmo_ipa_parse_msg_id_resp(struct msgb *msg, struct ipaccess_unit *unit_data);
65
66int osmo_ipa_segmentation_cb(struct msgb *msg);
67
68void osmo_ipa_msg_push_headers(struct msgb *msg, enum ipaccess_proto p, enum ipaccess_proto_ext pe);
69
70/***********************************************************************
71 * IPA Keep-Alive FSM
72 ***********************************************************************/
73struct osmo_ipa_ka_fsm_inst;
74typedef int (*osmo_ipa_ka_fsm_timeout_cb_t)(struct osmo_ipa_ka_fsm_inst *ka_fi, void *data);
75
76typedef int (*osmo_ipa_ka_fsm_send_cb_t)(struct osmo_ipa_ka_fsm_inst *ka_fi, struct msgb *msg, void *data);
77
78struct osmo_ipa_ka_fsm_inst *osmo_ipa_ka_fsm_alloc(void *ctx, const char *id);
79void osmo_ipa_ka_fsm_free(struct osmo_ipa_ka_fsm_inst *ka_fi);
80
81int osmo_ipa_ka_fsm_set_id(struct osmo_ipa_ka_fsm_inst *ka_fi, const char *id);
82int osmo_ipa_ka_fsm_set_ping_interval(struct osmo_ipa_ka_fsm_inst *ka_fi, unsigned int interval);
83int osmo_ipa_ka_fsm_set_pong_timeout(struct osmo_ipa_ka_fsm_inst *ka_fi, unsigned int timeout);
84void osmo_ipa_ka_fsm_set_data(struct osmo_ipa_ka_fsm_inst *ka_fi, void *cb_data);
85void *osmo_ipa_ka_fsm_get_data(const struct osmo_ipa_ka_fsm_inst *ka_fi);
86
87void osmo_ipa_ka_fsm_set_send_cb(struct osmo_ipa_ka_fsm_inst *ka_fi, osmo_ipa_ka_fsm_send_cb_t send_cb);
88void osmo_ipa_ka_fsm_set_timeout_cb(struct osmo_ipa_ka_fsm_inst *ka_fi, osmo_ipa_ka_fsm_timeout_cb_t timeout_cb);
89
90void osmo_ipa_ka_fsm_start(struct osmo_ipa_ka_fsm_inst *ka_fi);
91void osmo_ipa_ka_fsm_pong_received(struct osmo_ipa_ka_fsm_inst *ka_fi);
92void osmo_ipa_ka_fsm_stop(struct osmo_ipa_ka_fsm_inst *ka_fi);
93
94#endif
ipa_head_ext
Definition ipa.h:16
ipa_head
Definition ipa.h:10
osmo_ipa_msgb_cb
Definition ipa.h:21