diam_tcp.h

Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Copyright (C) 2001-2003 FhG Fokus
00005  *
00006  * This file is part of Kamailio, a free SIP server.
00007  *
00008  * Kamailio is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version
00012  *
00013  * Kamailio is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  */
00022 
00029 #ifdef DIAM_ACC
00030 
00031 #ifndef ACC_TCP
00032 #define ACC_TCP
00033 
00034 #include "../../str.h"
00035 #include "../../parser/msg_parser.h"
00036 
00037 /* information needed for reading messages from tcp connection */
00038 typedef struct rd_buf
00039 {
00040         unsigned int first_4bytes;
00041         unsigned int buf_len;
00042         unsigned char *buf;
00043 } rd_buf_t;
00044 
00045 
00046 #define AAA_ERROR                       -1
00047 #define AAA_CONN_CLOSED         -2
00048 #define AAA_TIMEOUT                     -3
00049 #define ACC_SUCCESS                     0
00050 #define ACC_FAILURE                     1
00051 
00052 #define AAA_NO_CONNECTION       -1
00053 
00054 #define MAX_WAIT_SEC    2
00055 #define MAX_WAIT_USEC   0
00056 
00057 #define MAX_AAA_MSG_SIZE  65536
00058 
00059 #define CONN_SUCCESS     1 
00060 #define CONN_ERROR              -1
00061 #define CONN_CLOSED             -2
00062 
00063 #define MAX_TRIES               10
00064 
00065 int sockfd;
00066 
00067 int do_read( int socket, rd_buf_t *p);
00068 void reset_read_buffer(rd_buf_t *rb);
00069 
00070 /* it initializes the TCP connection */ 
00071 int init_mytcp(char* host, int port);
00072 /* send a message over an already opened TCP connection */
00073 int tcp_send_recv(int sockfd, char* buf, int len, rd_buf_t* rb, 
00074                                         unsigned int waited_id);
00075 void close_tcp_connection(int sfd);
00076 
00077 int get_uri(struct sip_msg* m, str** uri);
00078 #endif
00079 
00080 #endif