aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/include/openbsc
diff options
context:
space:
mode:
authorIvan Kluchnikov <kluchnikovi@gmail.com>2015-10-15 17:06:47 +0300
committerIvan Kluchnikov <kluchnikovi@gmail.com>2017-02-07 18:59:53 +0300
commitdfeabbbff646cff9cd658a3dd2f012f72c8de33c (patch)
treede877be765cb9ccf88b4a404c2c8dc276082e6be /openbsc/include/openbsc
parent137130368922942ed27760881b253da8fcc9b654 (diff)
reg-proxy: add application which allows translate SUP to SIP and SIP to SUP
Diffstat (limited to 'openbsc/include/openbsc')
-rw-r--r--openbsc/include/openbsc/reg_proxy.h15
-rw-r--r--openbsc/include/openbsc/sip.h12
-rw-r--r--openbsc/include/openbsc/sip_client.h34
-rw-r--r--openbsc/include/openbsc/sup.h16
-rw-r--r--openbsc/include/openbsc/sup_server.h29
-rw-r--r--openbsc/include/openbsc/tcp_client.h51
6 files changed, 157 insertions, 0 deletions
diff --git a/openbsc/include/openbsc/reg_proxy.h b/openbsc/include/openbsc/reg_proxy.h
new file mode 100644
index 000000000..03c0195ed
--- /dev/null
+++ b/openbsc/include/openbsc/reg_proxy.h
@@ -0,0 +1,15 @@
+#ifndef _REG_PROXY_H
+#define _REG_PROXY_H
+
+#include <openbsc/sup_server.h>
+#include <openbsc/sip_client.h>
+#include <osip2/osip.h>
+void *tall_reg_ctx;
+
+struct reg_proxy {
+ struct gsm_sup_server *sup_server;
+ struct sip_client *sip_client;
+ osip_t *osip;
+};
+
+#endif /* _REG_PROXY_H */
diff --git a/openbsc/include/openbsc/sip.h b/openbsc/include/openbsc/sip.h
new file mode 100644
index 000000000..8a7a56264
--- /dev/null
+++ b/openbsc/include/openbsc/sip.h
@@ -0,0 +1,12 @@
+#ifndef _SIP_H
+#define _SIP_H
+
+#include <openbsc/sip_client.h>
+#include <openbsc/reg_proxy.h>
+#include <osip2/osip.h>
+
+int tx_sip_register(struct sip_client *sip_client, osip_t *osip, char *imsi);
+
+int sip_client_init(struct reg_proxy *reg, const char *src_ip, u_int16_t src_port,
+ const char *dst_ip, u_int16_t dst_port);
+#endif /* _SIP_H */
diff --git a/openbsc/include/openbsc/sip_client.h b/openbsc/include/openbsc/sip_client.h
new file mode 100644
index 000000000..23eaa7f75
--- /dev/null
+++ b/openbsc/include/openbsc/sip_client.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include <osmocom/core/timer.h>
+
+#define SIP_RECONNECT_INTERVAL 10
+
+struct msgb;
+struct ipa_client_conn;
+struct sip_client;
+
+/* Expects message in msg->l2h */
+typedef int (*sip_read_cb_t)(struct sip_client *sip_client, struct msgb *msg);
+
+struct sip_client {
+ struct tcp_client_conn *link;
+ sip_read_cb_t read_cb;
+ void *data;
+
+ struct osmo_timer_list connect_timer;
+ int is_connected;
+
+ char *src_ip;
+ char *dst_ip;
+ u_int16_t src_port;
+ u_int16_t dst_port;
+};
+
+struct sip_client *sip_client_create(const char *src_ip, u_int16_t src_port,
+ const char *dst_ip, u_int16_t dst_port,
+ sip_read_cb_t read_cb, void *data);
+
+void sip_client_destroy(struct sip_client *sip_client);
+int sip_client_send(struct sip_client *sip_client, struct msgb *msg);
+struct msgb *sip_msgb_alloc(void);
diff --git a/openbsc/include/openbsc/sup.h b/openbsc/include/openbsc/sup.h
new file mode 100644
index 000000000..29518f301
--- /dev/null
+++ b/openbsc/include/openbsc/sup.h
@@ -0,0 +1,16 @@
+#ifndef _SUP_H
+#define _SUP_H
+
+#include <openbsc/reg_proxy.h>
+
+#define LOGGSUPP(level, sup, fmt, args...) \
+ LOGP(DGPRS, level, "SUP(%s) " fmt, \
+ (sup)->imsi, \
+ ## args)
+
+int sup_server_init(struct reg_proxy *reg);
+
+int handle_location_update_result(struct gsm_sup_server *sup_server,
+ char *imsi, char *msisdn);
+
+#endif /* _SUP_H */
diff --git a/openbsc/include/openbsc/sup_server.h b/openbsc/include/openbsc/sup_server.h
new file mode 100644
index 000000000..5261e630f
--- /dev/null
+++ b/openbsc/include/openbsc/sup_server.h
@@ -0,0 +1,29 @@
+#ifndef _SUP_SERVER_H
+#define _SUP_SERVER_H
+
+#include <osmocom/abis/ipa.h>
+
+//struct msgb;
+struct ipa_server_conn;
+struct gsm_sup_server;
+
+/* Expects message in msg->l2h */
+typedef int (*sup_read_cb_t)(struct gsm_sup_server *sup_server, struct msgb *msg);
+
+struct gsm_sup_server {
+ struct ipa_server_link *link;
+ sup_read_cb_t read_cb;
+ void *data;
+ struct osmo_fd fd;
+ struct ipa_server_conn *server_conn;
+ void *app;
+};
+
+struct gsm_sup_server *sup_server_create(const char *ip_addr,
+ unsigned int tcp_port,
+ sup_read_cb_t read_cb,
+ void *app);
+
+int sup_server_send(struct gsm_sup_server *sup_server, struct msgb *msg);
+
+#endif /* _SUP_SERVER_H */
diff --git a/openbsc/include/openbsc/tcp_client.h b/openbsc/include/openbsc/tcp_client.h
new file mode 100644
index 000000000..f815a3c8a
--- /dev/null
+++ b/openbsc/include/openbsc/tcp_client.h
@@ -0,0 +1,51 @@
+#ifndef _TCP_CLIENT_H_
+#define _TCP_CLIENT_H_
+
+#include <stdint.h>
+#include <osmocom/core/linuxlist.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/select.h>
+
+
+struct msgb;
+
+enum tcp_client_conn_state {
+ TCP_CLIENT_LINK_STATE_NONE = 0,
+ TCP_CLIENT_LINK_STATE_CONNECTING = 1,
+ TCP_CLIENT_LINK_STATE_CONNECTED = 2,
+ TCP_CLIENT_LINK_STATE_MAX
+};
+
+struct tcp_client_conn {
+ struct osmo_fd *ofd;
+ struct llist_head tx_queue;
+ struct osmo_timer_list timer;
+ enum tcp_client_conn_state state;
+ const char *src_addr;
+ uint16_t src_port;
+ const char *dst_addr;
+ uint16_t dst_port;
+ void (*updown_cb)(struct tcp_client_conn *link, int up);
+ int (*read_cb)(struct tcp_client_conn *link, struct msgb *msg);
+ int (*write_cb)(struct tcp_client_conn *link);
+ void *data;
+ struct msgb *pending_msg;
+};
+
+struct tcp_client_conn *
+tcp_client_conn_create(void *ctx, int priv_nr,
+ const char *dst_addr, uint16_t dst_port,
+ const char *src_addr, uint16_t src_port,
+ void (*updown)(struct tcp_client_conn *link, int),
+ int (*read_cb)(struct tcp_client_conn *link, struct msgb *msgb),
+ int (*write_cb)(struct tcp_client_conn *link),
+ void *data);
+void tcp_client_conn_destroy(struct tcp_client_conn *link);
+
+int tcp_client_conn_open(struct tcp_client_conn *link);
+void tcp_client_conn_close(struct tcp_client_conn *link);
+
+void tcp_client_conn_send(struct tcp_client_conn *link, struct msgb *msg);
+size_t tcp_client_conn_clear_queue(struct tcp_client_conn *link);
+
+#endif