Holger Hans Peter Freyther | d70a7e8 | 2011-01-17 14:13:29 +0100 | [diff] [blame] | 1 | /* 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 | |
| 29 | struct sctp_m2ua_conn; |
| 30 | struct 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 Freyther | f7ce2c6 | 2011-02-15 15:45:32 +0100 | [diff] [blame] | 36 | struct sctp_m2ua_transport { |
Holger Hans Peter Freyther | d70a7e8 | 2011-01-17 14:13:29 +0100 | [diff] [blame] | 37 | int started; |
| 38 | struct llist_head conns; |
| 39 | struct bsc_fd bsc; |
Holger Hans Peter Freyther | f7ce2c6 | 2011-02-15 15:45:32 +0100 | [diff] [blame] | 40 | |
| 41 | struct llist_head links; |
| 42 | }; |
| 43 | |
| 44 | struct mtp_m2ua_link { |
Holger Hans Peter Freyther | 6c0b2e5 | 2011-02-17 02:18:38 +0100 | [diff] [blame] | 45 | struct mtp_link *base; |
Holger Hans Peter Freyther | f7ce2c6 | 2011-02-15 15:45:32 +0100 | [diff] [blame] | 46 | |
Holger Hans Peter Freyther | 8fd28db | 2011-02-17 14:55:55 +0100 | [diff] [blame] | 47 | /* |
| 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 Freyther | 4cee7c0 | 2011-02-17 18:41:33 +0100 | [diff] [blame] | 52 | int active; |
Holger Hans Peter Freyther | 8fd28db | 2011-02-17 14:55:55 +0100 | [diff] [blame] | 53 | int asp_active; |
| 54 | int established; |
| 55 | struct sctp_m2ua_conn *conn; |
| 56 | |
Holger Hans Peter Freyther | f7ce2c6 | 2011-02-15 15:45:32 +0100 | [diff] [blame] | 57 | int link_index; |
| 58 | struct llist_head entry; |
| 59 | struct sctp_m2ua_transport *transport; |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 60 | |
| 61 | char *as; |
Holger Hans Peter Freyther | d70a7e8 | 2011-01-17 14:13:29 +0100 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | /* |
| 65 | * One ASP that can be active or such. |
| 66 | */ |
| 67 | struct sctp_m2ua_conn { |
| 68 | struct llist_head entry; |
| 69 | uint8_t asp_ident[4]; |
| 70 | int asp_up; |
Holger Hans Peter Freyther | d70a7e8 | 2011-01-17 14:13:29 +0100 | [diff] [blame] | 71 | |
| 72 | struct write_queue queue; |
Holger Hans Peter Freyther | f7ce2c6 | 2011-02-15 15:45:32 +0100 | [diff] [blame] | 73 | struct sctp_m2ua_transport *trans; |
Holger Hans Peter Freyther | d70a7e8 | 2011-01-17 14:13:29 +0100 | [diff] [blame] | 74 | }; |
| 75 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 76 | struct sctp_m2ua_transport *sctp_m2ua_transp_create(struct bsc_data *bsc); |
| 77 | int sctp_m2ua_transport_bind(struct sctp_m2ua_transport *, const char *ip, int port); |
Holger Hans Peter Freyther | b27c962 | 2011-02-16 23:47:25 +0100 | [diff] [blame] | 78 | struct mtp_m2ua_link *mtp_m2ua_link_create(struct sctp_m2ua_transport *transport, |
| 79 | struct mtp_link_set *); |
Holger Hans Peter Freyther | d70a7e8 | 2011-01-17 14:13:29 +0100 | [diff] [blame] | 80 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 81 | struct mtp_m2ua_link *mtp_m2ua_link_init(struct mtp_link *link); |
| 82 | |
Holger Hans Peter Freyther | d70a7e8 | 2011-01-17 14:13:29 +0100 | [diff] [blame] | 83 | #endif |