1 /* 2 * Copyright (C) 2001-2003 FhG Fokus 3 * 4 * This file is part of Kamailio, a free SIP server. 5 * 6 * Kamailio is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version 10 * 11 * Kamailio is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 * 20 */ 21 22 #ifndef _UAC_H 23 #define _UAC_H 24 25 #include <stdio.h> 26 #include "../../core/str.h" 27 #include "dlg.h" 28 #include "t_hooks.h" 29 #include "h_table.h" 30 31 #define DEFAULT_CSEQ 10 /* Default CSeq number */ 32 33 /* structure for UAC interface 34 * 35 * You can free the memory allocated 36 * for the callback parameter if necessary: 37 * - when the function is unable to create the UAC 38 * and returns failure 39 * - when TMCB_DESTROY callback is called -- you must 40 * register it explicitly! 41 */ 42 typedef struct uac_req { 43 str *method; 44 str *headers; 45 str *body; 46 str *ssock; 47 str *ssockname; 48 dlg_t *dialog; 49 int cb_flags; 50 transaction_cb *cb; 51 void *cbp; 52 str *callid; 53 } uac_req_t; 54 55 /* macro for setting the values of uac_req_t struct */ 56 #define set_uac_req(_req, \ 57 _m, _h, _b, _dlg, _cb_flags, _cb, _cbp) \ 58 do { \ 59 memset((_req), 0, sizeof(uac_req_t)); \ 60 (_req)->method = (_m); \ 61 (_req)->headers = (_h); \ 62 (_req)->body = (_b); \ 63 (_req)->dialog = (_dlg); \ 64 (_req)->cb_flags = (_cb_flags); \ 65 (_req)->cb = (_cb); \ 66 (_req)->cbp = (_cbp); \ 67 } while (0) 68 69 70 #ifdef WITH_EVENT_LOCAL_REQUEST 71 /* where to go for the local request route ("tm:local-request") */ 72 extern int goto_on_local_req; 73 #endif /* WITH_EVEN_LOCAL_REQuEST */ 74 75 /* 76 * Function prototypes 77 */ 78 typedef int (*reqwith_t)(uac_req_t *uac_r); 79 typedef int (*reqout_t)(uac_req_t *uac_r, str* ruri, str* to, str* from, str *next_hop); 80 typedef int (*req_t)(uac_req_t *uac_r, str* ruri, str* to, str* from, str *next_hop); 81 typedef int (*t_uac_t)(uac_req_t *uac_r); 82 typedef int (*t_uac_with_ids_t)(uac_req_t *uac_r, 83 unsigned int *ret_index, unsigned int *ret_label); 84 typedef int (*ack_local_uac_f)(struct cell *trans, str *hdrs, str *body); 85 typedef int (*prepare_request_within_f)(uac_req_t *uac_r, 86 struct retr_buf **dst_req); 87 typedef void (*send_prepared_request_f)(struct retr_buf *request_dst); 88 typedef void (*generate_fromtag_f)(str*, str*, str*); 89 90 /* 91 * Generate a fromtag based on given Call-ID 92 */ 93 void generate_fromtag(str* tag, str* callid, str* ruri); 94 95 96 /* 97 * Initialization function 98 */ 99 int uac_init(void); 100 101 102 /* 103 * Send a request 104 */ 105 int t_uac(uac_req_t *uac_r); 106 107 /* 108 * Send a request 109 * ret_index and ret_label will identify the new cell 110 */ 111 int t_uac_with_ids(uac_req_t *uac_r, 112 unsigned int *ret_index, unsigned int *ret_label); 113 /* 114 * Send a message within a dialog 115 */ 116 int req_within(uac_req_t *uac_r); 117 118 119 /* 120 * Send an initial request that will start a dialog 121 */ 122 int req_outside(uac_req_t *uac_r, str* ruri, str* to, str* from, str* next_hop); 123 124 125 struct retr_buf *local_ack_rb(sip_msg_t *rpl_2xx, struct cell *trans, 126 unsigned int branch, str *hdrs, str *body); 127 void free_local_ack(struct retr_buf *lack); 128 void free_local_ack_unsafe(struct retr_buf *lack); 129 130 /** 131 * ACK an existing local INVITE transaction... 132 */ 133 int ack_local_uac(struct cell *trans, str *hdrs, str *body); 134 135 /* 136 * Send a transactional request, no dialogs involved 137 */ 138 int request(uac_req_t *uac_r, str* ruri, str* to, str* from, str *next_hop); 139 140 int prepare_req_within(uac_req_t *uac_r, 141 struct retr_buf **dst_req); 142 143 void send_prepared_request(struct retr_buf *request); 144 145 #endif 146