uac.h

00001 /*
00002  * $Id$
00003  *
00004  *
00005  * Copyright (C) 2001-2003 FhG Fokus
00006  *
00007  * This file is part of ser, a free SIP server.
00008  *
00009  * ser is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version
00013  *
00014  * For a license to use the ser software under conditions
00015  * other than those described here, or to purchase support for this
00016  * software, please contact iptel.org by e-mail at the following addresses:
00017  *    info@iptel.org
00018  *
00019  * ser is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  * GNU General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU General Public License 
00025  * along with this program; if not, write to the Free Software 
00026  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027  *
00028  * History:
00029  * ----------
00030  * 2003-02-28 protocolization of t_uac_dlg completed (jiri)
00031  */
00032 
00033 #ifndef _UAC_H
00034 #define _UAC_H
00035 
00036 #include <stdio.h>
00037 #include "../../str.h"
00038 #include "dlg.h"
00039 #include "t_hooks.h"
00040 #include "h_table.h"
00041 
00042 #define DEFAULT_CSEQ 10 /* Default CSeq number */
00043 
00044 /* structure for UAC interface
00045  *
00046  * You can free the memory allocated
00047  * for the callback parameter if necessary:
00048  *  - when the function is unable to create the UAC
00049  *    and returns failure
00050  *  - when TMCB_DESTROY callback is called -- you must
00051  *    register it explicitly!
00052  */
00053 typedef struct uac_req {
00054         str     *method;
00055         str     *headers;
00056         str     *body;
00057         dlg_t   *dialog;
00058         int     cb_flags;
00059         transaction_cb  *cb;
00060         void    *cbp;
00061 } uac_req_t;
00062 
00063 /* macro for setting the values of uac_req_t struct */
00064 #define set_uac_req(_req, \
00065                 _m, _h, _b, _dlg, _cb_flags, _cb, _cbp) \
00066         do { \
00067                 (_req)->method = (_m); \
00068                 (_req)->headers = (_h); \
00069                 (_req)->body = (_b); \
00070                 (_req)->dialog = (_dlg); \
00071                 (_req)->cb_flags = (_cb_flags); \
00072                 (_req)->cb = (_cb); \
00073                 (_req)->cbp = (_cbp); \
00074         } while (0)
00075 
00076 
00077 #ifdef WITH_EVENT_LOCAL_REQUEST
00078 /* where to go for the local request route ("tm:local-request") */
00079 extern int goto_on_local_req;
00080 #endif /* WITH_EVEN_LOCAL_REQuEST */
00081 
00082 /*
00083  * Function prototypes
00084  */
00085 typedef int (*reqwith_t)(uac_req_t *uac_r);
00086 typedef int (*reqout_t)(uac_req_t *uac_r, str* ruri, str* to, str* from, str *next_hop);
00087 typedef int (*req_t)(uac_req_t *uac_r, str* ruri, str* to, str* from, str *next_hop);
00088 typedef int (*t_uac_t)(uac_req_t *uac_r);
00089 typedef int (*t_uac_with_ids_t)(uac_req_t *uac_r,
00090                 unsigned int *ret_index, unsigned int *ret_label);
00091 #ifdef WITH_AS_SUPPORT
00092 typedef int (*ack_local_uac_f)(struct cell *trans, str *hdrs, str *body);
00093 #endif
00094 typedef int (*prepare_request_within_f)(uac_req_t *uac_r,
00095                 struct retr_buf **dst_req);
00096 typedef void (*send_prepared_request_f)(struct retr_buf *request_dst);
00097 typedef void (*generate_fromtag_f)(str*, str*);
00098 
00099 /*
00100  * Generate a fromtag based on given Call-ID
00101  */
00102 void generate_fromtag(str* tag, str* callid);
00103 
00104 
00105 /*
00106  * Initialization function
00107  */
00108 int uac_init(void);
00109 
00110 
00111 /*
00112  * Send a request
00113  */
00114 int t_uac(uac_req_t *uac_r);
00115 
00116 /*
00117  * Send a request
00118  * ret_index and ret_label will identify the new cell
00119  */
00120 int t_uac_with_ids(uac_req_t *uac_r,
00121         unsigned int *ret_index, unsigned int *ret_label);
00122 /*
00123  * Send a message within a dialog
00124  */
00125 int req_within(uac_req_t *uac_r);
00126 
00127 
00128 /*
00129  * Send an initial request that will start a dialog
00130  */
00131 int req_outside(uac_req_t *uac_r, str* ruri, str* to, str* from, str* next_hop);
00132 
00133 
00134 #ifdef WITH_AS_SUPPORT
00135 struct retr_buf *local_ack_rb(sip_msg_t *rpl_2xx, struct cell *trans,
00136                                         unsigned int branch, str *hdrs, str *body);
00137 void free_local_ack(struct retr_buf *lack);
00138 void free_local_ack_unsafe(struct retr_buf *lack);
00139 
00143 int ack_local_uac(struct cell *trans, str *hdrs, str *body);
00144 #endif
00145 
00146 /*
00147  * Send a transactional request, no dialogs involved
00148  */
00149 int request(uac_req_t *uac_r, str* ruri, str* to, str* from, str *next_hop);
00150 
00151 int prepare_req_within(uac_req_t *uac_r,
00152                 struct retr_buf **dst_req);
00153 
00154 void send_prepared_request(struct retr_buf *request);
00155 
00156 
00157 #endif