blob: 2ae147238bf6eb3258c668db52e84cc0f5167066 [file] [log] [blame]
Holger Hans Peter Freytherd70a7e82011-01-17 14:13:29 +01001/* Run M2UA over SCTP here */
2/* (C) 2011 by Holger Hans Peter Freyther <zecke@selfish.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
13 *
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef sctp_m2ua_h
19#define sctp_m2ua_h
20
21#include "mtp_data.h"
22
23#include <osmocom/m2ua/m2ua_msg.h>
24#include <osmocore/write_queue.h>
25
26#include <netinet/in.h>
27#include <netinet/sctp.h>
28
29struct sctp_m2ua_conn;
30struct mtp_link;
31
32/**
33 * Drive M2UA over a SCTP link. Right now we have no
34 * real concept for failover and such for the link.
35 */
Holger Hans Peter Freytherf7ce2c62011-02-15 15:45:32 +010036struct sctp_m2ua_transport {
Holger Hans Peter Freytherd70a7e82011-01-17 14:13:29 +010037 int started;
38 struct llist_head conns;
39 struct bsc_fd bsc;
Holger Hans Peter Freytherf7ce2c62011-02-15 15:45:32 +010040
41 struct llist_head links;
42};
43
44struct mtp_m2ua_link {
Holger Hans Peter Freyther6c0b2e52011-02-17 02:18:38 +010045 struct mtp_link *base;
Holger Hans Peter Freytherf7ce2c62011-02-15 15:45:32 +010046
Holger Hans Peter Freyther8fd28db2011-02-17 14:55:55 +010047 /*
48 * The state of the link, who is using it and
49 * what will happen to it. For load-sharing we
50 * will need to turn this into a list.
51 */
Holger Hans Peter Freyther4cee7c02011-02-17 18:41:33 +010052 int active;
Holger Hans Peter Freyther8fd28db2011-02-17 14:55:55 +010053 int asp_active;
54 int established;
55 struct sctp_m2ua_conn *conn;
56
Holger Hans Peter Freytherf7ce2c62011-02-15 15:45:32 +010057 int link_index;
58 struct llist_head entry;
59 struct sctp_m2ua_transport *transport;
Holger Hans Peter Freyther71760302011-02-22 20:57:08 +010060
61 char *as;
Holger Hans Peter Freytherd70a7e82011-01-17 14:13:29 +010062};
63
64/*
65 * One ASP that can be active or such.
66 */
67struct sctp_m2ua_conn {
68 struct llist_head entry;
69 uint8_t asp_ident[4];
70 int asp_up;
Holger Hans Peter Freytherd70a7e82011-01-17 14:13:29 +010071
72 struct write_queue queue;
Holger Hans Peter Freytherf7ce2c62011-02-15 15:45:32 +010073 struct sctp_m2ua_transport *trans;
Holger Hans Peter Freytherd70a7e82011-01-17 14:13:29 +010074};
75
Holger Hans Peter Freyther71760302011-02-22 20:57:08 +010076struct sctp_m2ua_transport *sctp_m2ua_transp_create(struct bsc_data *bsc);
77int sctp_m2ua_transport_bind(struct sctp_m2ua_transport *, const char *ip, int port);
Holger Hans Peter Freytherb27c9622011-02-16 23:47:25 +010078struct mtp_m2ua_link *mtp_m2ua_link_create(struct sctp_m2ua_transport *transport,
79 struct mtp_link_set *);
Holger Hans Peter Freytherd70a7e82011-01-17 14:13:29 +010080
Holger Hans Peter Freyther71760302011-02-22 20:57:08 +010081struct mtp_m2ua_link *mtp_m2ua_link_init(struct mtp_link *link);
82
Holger Hans Peter Freytherd70a7e82011-01-17 14:13:29 +010083#endif