dlg.h

Go to the documentation of this file.
00001 /*
00002  * $Id: dlg.h 4951 2008-09-18 14:20:46Z henningw $
00003  * Copyright (C) 2001-2003 FhG Fokus
00004  *
00005  * This file is part of Kamailio, a free SIP server.
00006  *
00007  * Kamailio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version
00011  *
00012  * Kamailio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  * History:
00022  * -------
00023  * 2003-03-29 Created by janakj
00024  * 2008-04-04 added support for local and remote dispaly name in TM dialogs
00025  *            (by Andrei Pisau <andrei.pisau at voice-system dot ro> )
00026  */
00027 
00028 /*! \file
00029  * \brief TM :: Dialog handling
00030  *
00031  * \ingroup tm
00032  * - Module: \ref tm
00033  * - \ref dlg.c
00034  */
00035 
00036 
00037 #ifndef DLG_H
00038 #define DLG_H
00039 
00040 
00041 #include <stdio.h>
00042 #include "../../str.h"
00043 #include "../../parser/parse_rr.h"
00044 #include "../../parser/msg_parser.h"
00045 
00046 
00047 /*! Dialog sequence */
00048 typedef struct dlg_seq {
00049    unsigned int value;    /*!< Sequence value */
00050    unsigned char is_set;  /*!< is_set flag */
00051 } dlg_seq_t;
00052 
00053 
00054 /* Dialog state */
00055 typedef enum dlg_state {
00056    DLG_NEW = 0,   /*!< New dialog, no reply received yet */
00057    DLG_EARLY,     /*!< Early dialog, provisional response received */
00058    DLG_CONFIRMED, /*!< Confirmed dialog, 2xx received */
00059    DLG_DESTROYED  /*!< Destroyed dialog */
00060 } dlg_state_t;
00061 
00062 
00063 /* Structure describing a dialog identifier */
00064 typedef struct dlg_id {
00065    str call_id;    /*!< Call-ID */
00066    str rem_tag;    /*!< Remote tag of the dialog */
00067    str loc_tag;    /*!< Local tag of the dialog */
00068 } dlg_id_t;
00069 
00070 
00071 /*!
00072  * It is necessary to analyze the dialog data to find out
00073  * what URI put into the Record-Route, where the message
00074  * should be really sent and how to construct the route
00075  * set of the message. This structure stores this information
00076  * so we don't have to calculate each time we want to send a
00077  * message within dialog
00078  */
00079 typedef struct dlg_hooks {
00080    str ru;
00081    str nh;
00082    str* request_uri;   /*!< This should be put into Request-URI */
00083    str* next_hop;      /*!< Where the message should be really sent */
00084    rr_t* first_route;  /*!< First route to be printed into the message */
00085    str* last_route;    /*!< If not zero add this as the last route */
00086 } dlg_hooks_t;
00087 
00088 
00089 /*! Structure representing dialog state */
00090 typedef struct dlg {
00091    dlg_id_t id;            /*!< Dialog identifier */
00092    dlg_seq_t loc_seq;      /*!< Local sequence number */
00093    dlg_seq_t rem_seq;      /*!< Remote sequence number */
00094    str loc_uri;            /*!< Local URI */
00095    str rem_uri;            /*!< Remote URI */
00096    str rem_target;         /*!< Remote target URI */
00097    str loc_dname;       /*!< Local Display Name */
00098    str rem_dname;       /*!< Remote Display Name */
00099    unsigned int T_flags;   /*!< Flags to be passed to transaction */
00100    dlg_state_t state;      /*!< State of the dialog */
00101    rr_t* route_set;        /*!< Route set */
00102    dlg_hooks_t hooks;      /*!< Various hooks used to store information that
00103                         * can be reused when building a message (to
00104                         * prevent repeated analyzing of the dialog data */
00105    struct socket_info* send_sock;
00106 } dlg_t;
00107 
00108 
00109 /*
00110  * Create a new dialog
00111  */
00112 int new_dlg_uac(str* _cid, str* _ltag, unsigned int _lseq, str* _luri, str* _ruri, dlg_t** _d);
00113 typedef int (*new_dlg_uac_f)(str* _cid, str* _ltag, unsigned int _lseq, str* _luri, str* _ruri, dlg_t** _d);
00114 
00115 /*
00116  * Function which adds Display Names to an existing dialog
00117  */
00118 int dlg_add_extra(dlg_t* _d, str* _ldname, str* _rdname);
00119 typedef int (*dlg_add_extra_f)(dlg_t* _d, str* _ldname, str* _rdname);
00120 
00121 /*
00122  * A response arrived, update dialog
00123  */
00124 int dlg_response_uac(dlg_t* _d, struct sip_msg* _m);
00125 typedef int (*dlg_response_uac_f)(dlg_t* _d, struct sip_msg* _m);
00126 
00127 /*
00128  * Establishing a new dialog, UAS side
00129  */
00130 int new_dlg_uas(struct sip_msg* _req, int _code, /*str* _tag,*/ dlg_t** _d);
00131 typedef int (*new_dlg_uas_f)(struct sip_msg* _req, int _code, dlg_t** _d);
00132 
00133 
00134 /*
00135  * UAS side - update a dialog from a request
00136  */
00137 int dlg_request_uas(dlg_t* _d, struct sip_msg* _m);
00138 typedef int (*dlg_request_uas_f)(dlg_t* _d, struct sip_msg* _m);
00139 
00140 
00141 /*
00142  * Destroy a dialog state
00143  */
00144 void free_dlg(dlg_t* _d);
00145 typedef void (*free_dlg_f)(dlg_t* _d);
00146 
00147 
00148 /*
00149  * Print a dialog structure, just for debugging
00150  */
00151 void print_dlg(FILE* out, dlg_t* _d);
00152 typedef void (*print_dlg_f)(FILE* out, dlg_t* _d);
00153 
00154 
00155 /*
00156  * Calculate length of the route set
00157  */
00158 int calculate_routeset_length(dlg_t* _d);
00159 
00160 
00161 /*
00162  *
00163  * Print the route set
00164  */
00165 char* print_routeset(char* buf, dlg_t* _d);
00166 
00167 /*
00168  * wrapper to calculate_hooks
00169  * added by dcm
00170  */
00171 int w_calculate_hooks(dlg_t* _d);
00172 
00173 #endif /* DLG_H */

Generated on Tue May 22 16:00:26 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6