2010-07-10 07:54:33 +00:00
|
|
|
#ifndef _OSMO_TCAP_H
|
|
|
|
#define _OSMO_TCAP_H
|
2010-07-18 15:17:17 +00:00
|
|
|
/* (C) 2010 by Harald Welte <laforge@gnumonks.org>
|
|
|
|
* (C) 2010 by On-Waves
|
|
|
|
*
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2010-07-10 07:54:33 +00:00
|
|
|
|
2010-07-14 18:47:34 +00:00
|
|
|
#include <stdint.h>
|
2010-07-17 18:25:03 +00:00
|
|
|
|
2010-07-14 18:47:34 +00:00
|
|
|
#include <osmocore/linuxlist.h>
|
|
|
|
#include <osmocore/timer.h>
|
|
|
|
#include <osmocore/msgb.h>
|
2010-07-17 18:25:03 +00:00
|
|
|
#include <osmocore/select.h>
|
2010-07-14 18:47:34 +00:00
|
|
|
|
|
|
|
#include <osmocom/tcap/TCMessage.h>
|
|
|
|
#include <osmocom/tcap/OPERATION.h>
|
|
|
|
#include <osmocom/tcap/Reject.h>
|
|
|
|
#include <osmocom/tcap/ComponentPortion.h>
|
|
|
|
#include <osmocom/tcap/ABRT-apdu.h>
|
2010-07-10 07:54:33 +00:00
|
|
|
|
2010-07-17 23:46:34 +00:00
|
|
|
#if HAVE_VISIBILITY
|
|
|
|
#define LIB_EXPORTED __attribute__((__visibility__("default")))
|
|
|
|
#else
|
|
|
|
#define LIB_EXPORTED
|
|
|
|
#endif
|
2010-07-17 11:05:56 +00:00
|
|
|
|
2010-07-10 07:54:33 +00:00
|
|
|
enum tcap_transaction_state {
|
|
|
|
TCAP_TS_INVALID,
|
|
|
|
TCAP_TS_IDLE,
|
|
|
|
TCAP_TS_INIT_RECV,
|
|
|
|
TCAP_TS_INIT_SENT,
|
|
|
|
TCAP_TS_ACTIVE,
|
|
|
|
};
|
|
|
|
|
2010-07-14 18:47:34 +00:00
|
|
|
/* Transaction, part of the dialogue (as there's 1:1 mapping */
|
2010-07-10 07:54:33 +00:00
|
|
|
struct tcap_transaction {
|
|
|
|
enum tcap_transaction_state state;
|
|
|
|
|
2010-07-14 18:47:34 +00:00
|
|
|
uint32_t tid_local; /* local transaction ID */
|
|
|
|
uint32_t tid_remote; /* remote transaction ID */
|
2010-07-10 07:54:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct tcap_dialogue {
|
|
|
|
/* global list of dialogues */
|
|
|
|
struct llist_head list;
|
|
|
|
|
2010-07-10 16:11:28 +00:00
|
|
|
/* Dialogue ID: Local significance; maps to Transaction IDs */
|
2010-07-10 07:54:33 +00:00
|
|
|
uint32_t dialogue_id;
|
|
|
|
|
2010-07-17 14:48:01 +00:00
|
|
|
unsigned int app_ctx_mode:1;
|
|
|
|
|
2010-07-10 07:54:33 +00:00
|
|
|
/* private list of ISMs / Invocations in this dialogue */
|
|
|
|
struct llist_head ism_list;
|
|
|
|
|
2010-07-17 11:05:56 +00:00
|
|
|
/* list of pending components for this dialogue */
|
2010-07-19 13:09:23 +00:00
|
|
|
struct ComponentPortion *pend_comp;
|
2010-07-17 11:05:56 +00:00
|
|
|
|
2010-07-11 23:26:45 +00:00
|
|
|
/* There is a 1:1 mapping of transactions to dialogues */
|
|
|
|
struct tcap_transaction trans;
|
|
|
|
|
2010-07-14 21:59:31 +00:00
|
|
|
/* reference to the SUA+SCTP / SCCP transport layer */
|
2010-07-17 18:25:03 +00:00
|
|
|
struct tcap_transport_entity *transp_ent;
|
2010-07-10 07:54:33 +00:00
|
|
|
};
|
|
|
|
|
2010-07-16 13:28:13 +00:00
|
|
|
#define dialg_by_trans(tt) container_of(tt, struct tcap_dialogue, trans)
|
|
|
|
|
2010-07-10 07:54:33 +00:00
|
|
|
enum tcap_invocation_state {
|
|
|
|
TCAP_IS_INVALID,
|
|
|
|
TCAP_IS_IDLE,
|
|
|
|
TCAP_IS_OP_SENT_CL1,
|
|
|
|
TCAP_IS_OP_SENT_CL2,
|
|
|
|
TCAP_IS_OP_SENT_CL3,
|
|
|
|
TCAP_IS_OP_SENT_CL4,
|
|
|
|
TCAP_IS_WAIT_REJECT,
|
|
|
|
};
|
|
|
|
|
2010-07-10 16:11:28 +00:00
|
|
|
#define TCAP_INV_LINKED_NONE -1234
|
2010-07-14 18:47:34 +00:00
|
|
|
|
2010-07-10 07:54:33 +00:00
|
|
|
struct tcap_invocation {
|
|
|
|
struct llist_head list;
|
|
|
|
|
|
|
|
/* reference to the dialogue we're part of */
|
|
|
|
struct tcap_dialogue *dialogue;
|
|
|
|
|
2010-07-14 18:47:34 +00:00
|
|
|
int8_t invoke_id; /* Invoke ID */
|
|
|
|
int8_t _linked_id; /* storage for linked_id */
|
|
|
|
int8_t *linked_id; /* Linked Invoke ID */
|
2010-07-10 07:54:33 +00:00
|
|
|
|
2010-07-14 18:47:34 +00:00
|
|
|
uint8_t op_class; /* Operation Class */
|
|
|
|
enum tcap_invocation_state state;
|
2010-07-10 07:54:33 +00:00
|
|
|
|
|
|
|
/* Invocation timer */
|
2010-07-10 16:11:28 +00:00
|
|
|
uint32_t inv_timeout; /* Seconds */
|
2010-07-16 13:28:13 +00:00
|
|
|
uint32_t rej_timeout; /* Seconds */
|
2010-07-14 18:47:34 +00:00
|
|
|
struct timer_list inv_timer; /* Invoke Timer */
|
|
|
|
struct timer_list rej_timer; /* Reject Timer */
|
2010-07-10 07:54:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-07-13 09:29:19 +00:00
|
|
|
/* CSL CHA ISM (Invocation State Machine) */
|
|
|
|
|
|
|
|
struct tcap_invocation *tcap_ism_lookup(struct tcap_dialogue *td, int8_t invoke_id);
|
|
|
|
struct tcap_invocation *tcap_ism_alloc(struct tcap_dialogue *td, int8_t invoke_id);
|
|
|
|
void tcap_ism_free(struct tcap_invocation *ti);
|
|
|
|
|
|
|
|
/* Operation sent (CCO -> ISM) */
|
|
|
|
int tcap_ism_op_sent(struct tcap_invocation *ti, uint8_t op_class);
|
|
|
|
|
|
|
|
/* RR-L received (CCO -> ISM) */
|
2010-07-19 14:29:51 +00:00
|
|
|
int tcap_ism_rr_l_recv(struct tcap_invocation *ti, struct ReturnResult *res,
|
|
|
|
int is_last_comp);
|
2010-07-13 09:29:19 +00:00
|
|
|
|
|
|
|
/* RE received (CCO -> ISM) */
|
2010-07-19 14:29:51 +00:00
|
|
|
int tcap_ism_re_recv(struct tcap_invocation *ti, struct ReturnError *err,
|
|
|
|
int is_last_comp);
|
2010-07-13 09:29:19 +00:00
|
|
|
|
|
|
|
/* RR-NL received (CCO -> ISM) */
|
2010-07-19 14:29:51 +00:00
|
|
|
int tcap_ism_rr_nl_recv(struct tcap_invocation *ti, struct ReturnResult *res,
|
|
|
|
int is_last_comp);
|
2010-07-13 09:29:19 +00:00
|
|
|
|
|
|
|
/* Terminate (CCO -> ISM) */
|
|
|
|
int tcap_ism_terminate(struct tcap_invocation *ti);
|
|
|
|
|
|
|
|
|
|
|
|
/* CSL CHA CCO (Component Coordinator) */
|
|
|
|
|
|
|
|
/* TC-INVOKE.req (TCU -> CHA) */
|
|
|
|
int tcap_cha_tc_invoke_req(struct tcap_dialogue *td, uint8_t op_class, int8_t inv_id,
|
|
|
|
int8_t *linked_id, struct OPERATION *op,
|
|
|
|
uint8_t *param, uint32_t param_len, uint32_t timeout);
|
|
|
|
|
2010-07-19 17:21:16 +00:00
|
|
|
/* TC-U-ERROR request (TCL -> CHA) */
|
|
|
|
int tcap_cha_tc_u_error_req(struct tcap_dialogue *td, int8_t inv_id,
|
|
|
|
ErrorCode_t *err, uint8_t *param,
|
|
|
|
uint32_t param_len);
|
|
|
|
|
2010-07-13 09:29:19 +00:00
|
|
|
/* Dialogue Terminated (CHA <- DHA) */
|
|
|
|
int tcap_cha_dialg_term(struct tcap_dialogue *td);
|
|
|
|
|
|
|
|
/* TC-RESULT-NL / TC-RESULT-L req (TCL -> CHA) */
|
|
|
|
int tcap_cha_tc_result_l_req(struct tcap_dialogue *td, int8_t inv_id, int last,
|
|
|
|
struct OPERATION *op, uint8_t *param, uint32_t param_len);
|
|
|
|
|
|
|
|
/* TC-U-REJECT.req (TCU -> CHA) */
|
2010-07-19 17:46:11 +00:00
|
|
|
int tcap_cha_tc_u_rej_req(struct tcap_dialogue *td, int8_t *invoke_id,
|
|
|
|
enum problem_PR problem, long problem_code);
|
2010-07-13 09:29:19 +00:00
|
|
|
|
|
|
|
/* Components (CHA <- DHA) */
|
2010-07-16 13:28:13 +00:00
|
|
|
int tcap_cha_proc_components(struct tcap_dialogue *td, struct ComponentPortion *comp_por);
|
2010-07-13 09:29:19 +00:00
|
|
|
|
|
|
|
/* Generate REJ component (CCO <- ISM) */
|
|
|
|
int tcap_cco_gen_rej(struct tcap_invocation *ti);
|
|
|
|
|
|
|
|
|
|
|
|
/* CSL DHA (Dialogue Handling)*/
|
|
|
|
|
|
|
|
/* TC-UNI.req from TCU */
|
2010-07-14 18:47:34 +00:00
|
|
|
int tcap_csl_tc_uni_req(struct tcap_dialogue *td, OBJECT_IDENTIFIER_t *app_ctx, struct user_information *user_info);
|
2010-07-13 09:29:19 +00:00
|
|
|
|
|
|
|
/* TC-BEGIN.req from TCU */
|
|
|
|
int tcap_csl_tc_begin_req(struct tcap_dialogue *td, OBJECT_IDENTIFIER_t *app_ctx, struct user_information *user_info);
|
|
|
|
|
|
|
|
/* TR-UNI.ind from TSL */
|
|
|
|
int tcap_csl_tr_uni_ind(struct tcap_transaction *tt, struct TCMessage *tcmsg, struct msgb *msg);
|
|
|
|
|
|
|
|
/* TR-BEGIN.ind from TSL(TSM) -> CSL(DHA) */
|
|
|
|
int tcap_csl_tr_begin_ind(struct tcap_transaction *tt, struct TCMessage *tcmsg, struct msgb *msg);
|
|
|
|
|
|
|
|
/* TC-CONTINUE.req from TCU */
|
|
|
|
int tcap_csl_tc_cont_req(struct tcap_dialogue *td, OBJECT_IDENTIFIER_t *app_ctx, struct user_information *user_info);
|
|
|
|
|
|
|
|
/* TC-END.req from TCU */
|
|
|
|
int tcap_csl_tc_end_req(struct tcap_dialogue *td, OBJECT_IDENTIFIER_t *app_ctx, struct user_information *user_info, int prearranged);
|
|
|
|
|
|
|
|
/* TC-U-APORT.req from TCU */
|
|
|
|
int tcap_csl_tc_u_abort_req(struct tcap_dialogue *td, uint32_t *abrt_reason, OBJECT_IDENTIFIER_t *app_ctx, struct user_information *user_info);
|
|
|
|
|
|
|
|
/* TR-END.ind from TSL */
|
|
|
|
int tcap_csl_tr_end_ind(struct tcap_transaction *tt, struct TCMessage *tcmsg, struct msgb *msg);
|
|
|
|
|
|
|
|
/* TR-NOTICE.ind from TSL */
|
|
|
|
int tcap_csl_tr_notice_ind(struct tcap_transaction *tt);
|
|
|
|
|
|
|
|
/* TR-CONTINUE.ind from TSL */
|
|
|
|
int tcap_csl_tr_continue_ind(struct tcap_transaction *tt, struct TCMessage *tcmsg, struct msgb *msg);
|
|
|
|
|
|
|
|
/* TR-U-ABORT.ind from TSL */
|
2010-07-14 21:59:31 +00:00
|
|
|
int tcap_csl_tr_u_abort_ind(struct tcap_transaction *tt, struct TCMessage *tcmsg, struct msgb *msg);
|
2010-07-13 09:29:19 +00:00
|
|
|
|
|
|
|
/* TR-P-ABORT.ind from TSL */
|
2010-07-14 18:47:34 +00:00
|
|
|
int tcap_csl_tr_p_abort_ind(struct tcap_transaction *tt);
|
2010-07-13 09:29:19 +00:00
|
|
|
|
2010-07-14 21:59:31 +00:00
|
|
|
|
|
|
|
/* TSL TCO */
|
2010-07-17 18:25:03 +00:00
|
|
|
int tcap_tco_n_unitdata_ind(struct tcap_transport_entity *se, struct msgb *msg);
|
|
|
|
int tcap_tco_n_notice_ind(struct tcap_transport_entity *se);
|
2010-07-14 21:59:31 +00:00
|
|
|
int tcap_tco_tsm_stopped_ind(struct tcap_transaction *tt);
|
2010-07-16 18:35:20 +00:00
|
|
|
int tcap_tco_tr_uni_req(struct tcap_transaction *tt, struct TCMessage *tcmsg);
|
|
|
|
int tcap_tco_tr_begin_req(struct tcap_transaction *tt, struct TCMessage *tcmsg);
|
|
|
|
int tcap_tco_tr_continue_req(struct tcap_transaction *tt, struct TCMessage *tcmsg);
|
|
|
|
int tcap_tco_tr_end_req(struct tcap_transaction *tt, struct TCMessage *tcmsg);
|
|
|
|
int tcap_tco_tr_u_abort_req(struct tcap_transaction *tt, struct TCMessage *tcmsg);
|
2010-07-14 21:59:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* TSL TSM */
|
2010-07-16 18:35:20 +00:00
|
|
|
int tcap_tsm_begin_trans(struct tcap_transaction *tt, struct TCMessage *tcmsg);
|
|
|
|
int tcap_tsm_continue_trans(struct tcap_transaction *tt, struct TCMessage *tcmsg);
|
|
|
|
int tcap_tsm_end_trans(struct tcap_transaction *tt, struct TCMessage *tcmsg);
|
|
|
|
int tcap_tsm_abort_trans(struct tcap_transaction *tt, struct TCMessage *tcmsg);
|
2010-07-14 21:59:31 +00:00
|
|
|
int tcap_tsm_begin_rcvd(struct tcap_transaction *tt, struct TCMessage *tcmsg, struct msgb *msg);
|
|
|
|
int tcap_tsm_continue_rcvd(struct tcap_transaction *tt, struct TCMessage *tcmsg, struct msgb *msg);
|
|
|
|
int tcap_tsm_end_rcvd(struct tcap_transaction *tt, struct TCMessage *tcmsg, struct msgb *msg);
|
|
|
|
int tcap_tsm_abort_rcvd(struct tcap_transaction *tt, struct TCMessage *tcmsg, struct msgb *msg);
|
|
|
|
int tcap_tsm_local_abort(struct tcap_transaction *tt);
|
|
|
|
|
|
|
|
|
|
|
|
/* dialogue.c */
|
2010-07-16 15:43:31 +00:00
|
|
|
uint32_t tcap_dialg_id_alloc(void);
|
2010-07-14 21:59:31 +00:00
|
|
|
struct tcap_dialogue *tcap_dialg_by_dialg_id(uint32_t dialogue_id);
|
|
|
|
struct tcap_dialogue *tcap_dialg_alloc(uint32_t dialogue_id);
|
2010-07-17 11:16:53 +00:00
|
|
|
void tcap_dialg_free(struct tcap_dialogue *td);
|
2010-07-16 15:43:31 +00:00
|
|
|
struct tcap_transaction *tcap_transaction_alloc(void);
|
|
|
|
struct tcap_transaction *tcap_transaction_by_remote_tid(uint32_t tid_remote);
|
|
|
|
struct tcap_transaction *tcap_transaction_by_local_tid(uint32_t tid_local);
|
|
|
|
uint32_t tcap_trans_id_alloc(void);
|
2010-07-17 16:49:24 +00:00
|
|
|
const char *tcap_trans_state_name(enum tcap_transaction_state ts);
|
|
|
|
const char *tcap_inv_state_name(enum tcap_invocation_state is);
|
2010-07-17 17:11:48 +00:00
|
|
|
void tcap_trans_set_state(struct tcap_transaction *tt, enum tcap_transaction_state st);
|
2010-07-14 21:59:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* scXp.c */
|
2010-07-17 18:25:03 +00:00
|
|
|
|
2010-07-14 21:59:31 +00:00
|
|
|
/* Called by TCAP stack if it wants to request transmission of UNITDATA */
|
2010-07-17 18:25:03 +00:00
|
|
|
int tcap_scXp_n_unitdata_req(struct tcap_transport_entity *se, struct msgb *msg);
|
2010-07-14 21:59:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* TCU */
|
2010-07-16 13:28:13 +00:00
|
|
|
int tcap_tcu_tc_invoke_ind(struct tcap_invocation *ti, struct OPERATION *oper, Parameter_t *param, int last);
|
2010-07-14 21:59:31 +00:00
|
|
|
int tcap_tcu_tc_l_rej_ind(struct tcap_invocation *td, int8_t *invoke_id, uint32_t problem);
|
2010-07-19 14:29:51 +00:00
|
|
|
int tcap_tcu_tc_r_rej_ind(struct tcap_invocation *td, int8_t *invoke_id, uint32_t problem, int is_last);
|
2010-07-14 21:59:31 +00:00
|
|
|
int tcap_tcu_begin_ind(struct tcap_dialogue *td, void *app_ctx_name, void *user_info, int comp_present);
|
|
|
|
int tcap_tcu_uni_ind(struct tcap_dialogue *td, void *app_ctx_name, void *user_info, int comp_present);
|
|
|
|
int tcap_tcu_cont_ind(struct tcap_dialogue *td, void *app_ctx_name, void *user_info, int comp_present);
|
|
|
|
int tcap_tcu_end_ind(struct tcap_dialogue *td, void *app_ctx_name, void *user_info, int comp_present);
|
|
|
|
int tcap_tcu_abort_ind(struct tcap_dialogue *td, void *app_ctx_name, void *user_info);
|
|
|
|
int tcap_tcu_notice_ind(struct tcap_dialogue *td, uint32_t cause);
|
|
|
|
|
2010-07-10 07:54:33 +00:00
|
|
|
#endif /* _OSMO_TCAP_H */
|