Holger Hans Peter Freyther | 97f66e2 | 2010-07-28 03:32:52 +0800 | [diff] [blame] | 1 | /* Everything related to the BSC connection */ |
| 2 | /* |
| 3 | * (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org> |
| 4 | * (C) 2010 by On-Waves |
| 5 | * All Rights Reserved |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along |
| 18 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #ifndef BSC_DATA_H |
| 24 | #define BSC_DATA_H |
| 25 | |
Holger Hans Peter Freyther | cbf7d18 | 2010-07-31 05:25:35 +0800 | [diff] [blame] | 26 | #include <osmocore/linuxlist.h> |
| 27 | #include <osmocore/select.h> |
| 28 | #include <osmocore/timer.h> |
| 29 | #include <osmocore/write_queue.h> |
Holger Hans Peter Freyther | 97f66e2 | 2010-07-28 03:32:52 +0800 | [diff] [blame] | 30 | |
Holger Hans Peter Freyther | cf381e2 | 2010-08-04 18:39:26 +0800 | [diff] [blame] | 31 | #include <osmocom/sccp/sccp.h> |
Holger Hans Peter Freyther | 97f66e2 | 2010-07-28 03:32:52 +0800 | [diff] [blame] | 32 | |
Holger Hans Peter Freyther | 97f66e2 | 2010-07-28 03:32:52 +0800 | [diff] [blame] | 33 | |
| 34 | #include <netinet/in.h> |
| 35 | #include <arpa/inet.h> |
| 36 | |
| 37 | struct bsc_data; |
| 38 | struct snmp_mtp_session; |
| 39 | |
| 40 | /** |
| 41 | * A link to the underlying MTP2 library or such |
| 42 | */ |
| 43 | struct link_data { |
| 44 | union { |
| 45 | struct { |
| 46 | struct thread_notifier *notifier; |
| 47 | struct llist_head mtp_queue; |
| 48 | struct timer_list mtp_timeout; |
| 49 | } c7; |
| 50 | struct { |
| 51 | struct write_queue write_queue; |
| 52 | struct sockaddr_in remote; |
| 53 | struct snmp_mtp_session *session; |
| 54 | int reset_timeout; |
| 55 | } udp; |
| 56 | }; |
| 57 | |
| 58 | int pcap_fd; |
| 59 | struct bsc_data *bsc; |
| 60 | struct mtp_link *the_link; |
| 61 | |
| 62 | struct timer_list link_activate; |
| 63 | int forced_down; |
| 64 | |
| 65 | int (*start)(struct link_data *); |
| 66 | int (*write)(struct link_data *, struct msgb *msg); |
| 67 | int (*shutdown)(struct link_data *); |
| 68 | int (*reset)(struct link_data *data); |
| 69 | int (*clear_queue)(struct link_data *data); |
| 70 | }; |
| 71 | |
| 72 | |
| 73 | struct bsc_data { |
| 74 | /* MSC */ |
| 75 | char *msc_address; |
| 76 | struct write_queue msc_connection; |
| 77 | struct timer_list reconnect_timer; |
| 78 | int first_contact; |
| 79 | int msc_time; |
| 80 | struct timer_list msc_timeout; |
| 81 | int msc_ip_dscp; |
| 82 | |
| 83 | int ping_time; |
| 84 | int pong_time; |
| 85 | struct timer_list ping_timeout; |
| 86 | struct timer_list pong_timeout; |
| 87 | |
Holger Hans Peter Freyther | 0c95c6a | 2010-08-07 02:37:43 +0800 | [diff] [blame] | 88 | int msc_link_down; |
Holger Hans Peter Freyther | 97f66e2 | 2010-07-28 03:32:52 +0800 | [diff] [blame] | 89 | struct llist_head sccp_connections; |
| 90 | struct timer_list reset_timeout; |
| 91 | int reset_count; |
| 92 | |
| 93 | struct timer_list start_timer; |
| 94 | |
| 95 | int setup; |
| 96 | |
| 97 | struct link_data link; |
| 98 | |
| 99 | const char *token; |
| 100 | |
| 101 | /* mgcp messgaes */ |
| 102 | struct write_queue mgcp_agent; |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame^] | 103 | |
| 104 | int dpc; |
| 105 | int opc; |
| 106 | int src_port; |
| 107 | int udp_port; |
| 108 | char *udp_ip; |
| 109 | int once; |
Holger Hans Peter Freyther | 97f66e2 | 2010-07-28 03:32:52 +0800 | [diff] [blame] | 110 | }; |
| 111 | |
| 112 | /* bsc related functions */ |
| 113 | void release_bsc_resources(struct bsc_data *bsc); |
| 114 | void bsc_link_down(struct link_data *data); |
| 115 | void bsc_link_up(struct link_data *data); |
| 116 | |
| 117 | /* msc related functions */ |
| 118 | int msc_init(struct bsc_data *bsc); |
Holger Hans Peter Freyther | 97f66e2 | 2010-07-28 03:32:52 +0800 | [diff] [blame] | 119 | void msc_send_rlc(struct bsc_data *bsc, struct sccp_source_reference *src, struct sccp_source_reference *dest); |
| 120 | void msc_send_reset(struct bsc_data *bsc); |
| 121 | void msc_send_msg(struct bsc_data *bsc, int rc, struct sccp_parse_result *, struct msgb *msg); |
| 122 | void msc_clear_queue(struct bsc_data *data); |
Holger Hans Peter Freyther | 43d9eec | 2010-08-07 01:54:19 +0800 | [diff] [blame] | 123 | void msc_close_connection(struct bsc_data *data); |
Holger Hans Peter Freyther | 97f66e2 | 2010-07-28 03:32:52 +0800 | [diff] [blame] | 124 | |
| 125 | /* connection tracking and action */ |
| 126 | void update_con_state(int rc, struct sccp_parse_result *result, struct msgb *msg, int from_msc, int sls); |
| 127 | unsigned int sls_for_src_ref(struct sccp_source_reference *ref); |
| 128 | |
| 129 | /* c7 init */ |
| 130 | int link_c7_init(struct link_data *data); |
| 131 | |
| 132 | /* udp init */ |
| 133 | int link_udp_init(struct link_data *data, int src_port, const char *dest_ip, int port); |
| 134 | |
| 135 | /* MGCP */ |
Holger Hans Peter Freyther | 5aa1701 | 2010-07-31 04:37:26 +0800 | [diff] [blame] | 136 | void mgcp_forward(struct bsc_data *bsc, const uint8_t *data, unsigned int length); |
Holger Hans Peter Freyther | 97f66e2 | 2010-07-28 03:32:52 +0800 | [diff] [blame] | 137 | |
| 138 | #endif |