diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Makefile.am | 2 | ||||
-rw-r--r-- | include/bsc_data.h | 49 | ||||
-rw-r--r-- | include/mtp_data.h | 33 | ||||
-rw-r--r-- | include/sctp_m2ua.h | 60 |
4 files changed, 103 insertions, 41 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index a0a54b9..6771b84 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,5 +1,5 @@ noinst_HEADERS = mtp_level3.h mtp_data.h ipaccess.h thread.h mtp_pcap.h \ mgcp_ss7.h bss_patch.h bssap_sccp.h bsc_data.h udp_input.h \ - snmp_mtp.h cellmgr_debug.h bsc_sccp.h bsc_ussd.h + snmp_mtp.h cellmgr_debug.h bsc_sccp.h bsc_ussd.h sctp_m2ua.h SUBDIRS = mgcp diff --git a/include/bsc_data.h b/include/bsc_data.h index fa04c3a..932b229 100644 --- a/include/bsc_data.h +++ b/include/bsc_data.h @@ -22,6 +22,8 @@ #ifndef BSC_DATA_H #define BSC_DATA_H +#include "mtp_data.h" + #include <osmocore/linuxlist.h> #include <osmocore/select.h> #include <osmocore/timer.h> @@ -38,40 +40,17 @@ struct bsc_data; struct snmp_mtp_session; -/** - * A link to the underlying MTP2 library or such - */ -struct link_data { - struct llist_head entry; - - union { - struct { - struct thread_notifier *notifier; - struct llist_head mtp_queue; - struct timer_list mtp_timeout; - } c7; - struct { - struct write_queue write_queue; - struct sockaddr_in remote; - struct snmp_mtp_session *session; - int link_index; - int reset_timeout; - } udp; - }; +struct mtp_udp_link { + /* subclass */ + struct mtp_link base; - int pcap_fd; + /* UDP specific stuff */ struct bsc_data *bsc; - struct mtp_link_set *the_link; - - int available; - - struct timer_list link_activate; - - int (*start)(struct link_data *); - int (*write)(struct link_data *, struct msgb *msg); - int (*shutdown)(struct link_data *); - int (*reset)(struct link_data *data); - int (*clear_queue)(struct link_data *data); + struct write_queue write_queue; + struct sockaddr_in remote; + struct snmp_mtp_session *session; + int link_index; + int reset_timeout; }; @@ -131,8 +110,8 @@ struct bsc_data { /* bsc related functions */ void release_bsc_resources(struct bsc_data *bsc); -void mtp_link_down(struct link_data *data); -void mtp_link_up(struct link_data *data); +void mtp_link_down(struct mtp_link *data); +void mtp_link_up(struct mtp_link *data); void mtp_linkset_down(struct mtp_link_set *); void mtp_linkset_up(struct mtp_link_set *); @@ -150,7 +129,7 @@ void update_con_state(struct mtp_link_set *link, int rc, struct sccp_parse_resul unsigned int sls_for_src_ref(struct sccp_source_reference *ref); /* udp init */ -int link_udp_init(struct link_data *data, int src_port, const char *dest_ip, int port); +int link_udp_init(struct mtp_udp_link *data, int src_port, const char *dest_ip, int port); int link_init(struct bsc_data *bsc); int link_shutdown_all(struct mtp_link_set *); int link_reset_all(struct mtp_link_set *); diff --git a/include/mtp_data.h b/include/mtp_data.h index 349bf7a..fd886a1 100644 --- a/include/mtp_data.h +++ b/include/mtp_data.h @@ -25,7 +25,7 @@ #include <osmocore/utils.h> struct bsc_data; -struct link_data; +struct mtp_link; /* MTP Level3 timers */ @@ -65,12 +65,35 @@ struct mtp_link_set { struct timer_list delay_timer; struct llist_head links; - struct link_data *slc[16]; + struct mtp_link *slc[16]; /* custom data */ struct bsc_data *bsc; }; +/** + * One physical link to somewhere. This is the base + * with the interface used by the mtp_link_set. There + * will be specific implementations for M2UA, UDP and + * other transport means. + */ +struct mtp_link { + struct llist_head entry; + + int pcap_fd; + struct mtp_link_set *the_link; + + int available; + + struct timer_list link_activate; + + int (*start)(struct mtp_link *); + int (*write)(struct mtp_link *, struct msgb *msg); + int (*shutdown)(struct mtp_link *); + int (*reset)(struct mtp_link *data); + int (*clear_queue)(struct mtp_link *data); +}; + struct mtp_link_set *mtp_link_set_alloc(void); void mtp_link_set_stop(struct mtp_link_set *link); @@ -80,16 +103,16 @@ int mtp_link_set_submit_sccp_data(struct mtp_link_set *link, int sls, const uint int mtp_link_set_submit_isup_data(struct mtp_link_set *link, int sls, const uint8_t *data, unsigned int length); void mtp_link_set_init_slc(struct mtp_link_set *set); -void mtp_link_set_add_link(struct mtp_link_set *set, struct link_data *link); +void mtp_link_set_add_link(struct mtp_link_set *set, struct mtp_link *link); /* one time init function */ void mtp_link_set_init(void); /* to be implemented for MSU sending */ -void mtp_link_set_submit(struct link_data *link, struct msgb *msg); +void mtp_link_set_submit(struct mtp_link *link, struct msgb *msg); void mtp_link_set_forward_sccp(struct mtp_link_set *link, struct msgb *msg, int sls); -void mtp_link_restart(struct link_data *link); +void mtp_link_restart(struct mtp_link *link); void mtp_link_set_sccp_down(struct mtp_link_set *link); #endif diff --git a/include/sctp_m2ua.h b/include/sctp_m2ua.h new file mode 100644 index 0000000..2627d7d --- /dev/null +++ b/include/sctp_m2ua.h @@ -0,0 +1,60 @@ +/* Run M2UA over SCTP here */ +/* (C) 2011 by Holger Hans Peter Freyther <zecke@selfish.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef sctp_m2ua_h +#define sctp_m2ua_h + +#include "mtp_data.h" + +#include <osmocom/m2ua/m2ua_msg.h> +#include <osmocore/write_queue.h> + +#include <netinet/in.h> +#include <netinet/sctp.h> + +struct sctp_m2ua_conn; +struct mtp_link; + +/** + * Drive M2UA over a SCTP link. Right now we have no + * real concept for failover and such for the link. + */ +struct mtp_m2ua_link { + struct mtp_link base; + + int started; + struct llist_head conns; + struct bsc_fd bsc; +}; + +/* + * One ASP that can be active or such. + */ +struct sctp_m2ua_conn { + struct llist_head entry; + uint8_t asp_ident[4]; + int asp_up; + int asp_active; + int established; + + struct write_queue queue; + struct mtp_m2ua_link *trans; +}; + +struct mtp_m2ua_link *sctp_m2ua_transp_create(const char *ip, int port); + +#endif |