root/src/m3ua_client.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. sctp_no_nagle

   1 /*
   2  *  m3ua_client.h
   3  *  freetdm
   4  *
   5  *  Created by Shane Burrell on 4/3/08.
   6  *  Copyright 2008 Shane Burrell. All rights reserved.
   7  *
   8  * Copyright (c) 2007, Anthony Minessale II, Nenad Corbic
   9  * 
  10  * Redistribution and use in source and binary forms, with or without
  11  * modification, are permitted provided that the following conditions
  12  * are met:
  13  * 
  14  * * Redistributions of source code must retain the above copyright
  15  * notice, this list of conditions and the following disclaimer.
  16  * 
  17  * * Redistributions in binary form must reproduce the above copyright
  18  * notice, this list of conditions and the following disclaimer in the
  19  * documentation and/or other materials provided with the distribution.
  20  * 
  21  * * Neither the name of the original author; nor the names of any contributors
  22  * may be used to endorse or promote products derived from this software
  23  * without specific prior written permission.
  24  * 
  25  * 
  26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  27  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  28  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  29  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
  30  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  31  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  32  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  33  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  34  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  35  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  36  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  37  */
  38 
  39 #include <ctype.h>
  40 #include <string.h>
  41 #include <unistd.h>
  42 #include <stdlib.h>
  43 #include <errno.h>
  44 #include <stdarg.h>
  45 #include <stdio.h>
  46 #include <sys/types.h>
  47 #include <sys/socket.h>
  48 #include <netinet/in.h>
  49 
  50 // Fix this for portability
  51 #include <sctp.h>
  52 //#include <netinet/sctp.h>
  53 #include <arpa/inet.h>
  54 #include <stdarg.h>
  55 #include <netdb.h>
  56 //#include <sigboost.h>
  57 #include <sys/time.h>
  58 
  59 #define MAX_DIALED_DIGITS       31
  60 #define MAX_CALLING_NAME        31
  61 
  62 /* Next two defines are used to create the range of values for call_setup_id
  63  * in the t_sigboost structure.
  64  * 0..((CORE_MAX_SPANS * CORE_MAX_CHAN_PER_SPAN) - 1) */
  65 #define CORE_MAX_SPANS          200
  66 #define CORE_MAX_CHAN_PER_SPAN  30
  67 #define MAX_PENDING_CALLS       CORE_MAX_SPANS * CORE_MAX_CHAN_PER_SPAN
  68 /* 0..(MAX_PENDING_CALLS-1) is range of call_setup_id below */
  69 #define SIZE_RDNIS              80
  70 
  71 //#undef MSGWINDOW
  72 #define MSGWINDOW
  73 
  74 
  75 typedef struct
  76 {
  77         uint32_t        event_id;
  78         uint32_t        fseqno;
  79 #ifdef MSGWINDOW
  80         uint32_t        bseqno;
  81 #endif
  82         uint16_t        call_setup_id;
  83         uint32_t        trunk_group;
  84         uint32_t        span;
  85         uint32_t        chan;
  86         uint8_t         called_number_digits_count;
  87         char            called_number_digits [MAX_DIALED_DIGITS + 1]; /* it's a null terminated string */
  88         uint8_t         calling_number_digits_count; /* it's an array */
  89         char            calling_number_digits [MAX_DIALED_DIGITS + 1]; /* it's a null terminated string */
  90         uint8_t         release_cause;
  91         struct timeval  tv;
  92         /* ref. Q.931 Table 4-11 and Q.951 Section 3 */
  93         uint8_t         calling_number_screening_ind;
  94         uint8_t         calling_number_presentation;
  95         char            redirection_string [SIZE_RDNIS]; /* it's a null terminated string */
  96         
  97 } t_m3ua;
  98 
  99 typedef t_m3ua m3uac_event_t;
 100 typedef uint32_t m3uac_event_id_t;
 101 
 102 
 103 typedef struct m3uac_ip_cfg
 104 {
 105         char local_ip[25];
 106         int local_port;
 107         char remote_ip[25];
 108         int remote_port;
 109 }m3uac_ip_cfg_t;
 110 
 111 struct m3uac_connection {
 112         ftdm_socket_t socket;
 113         struct sockaddr_in local_addr;
 114         struct sockaddr_in remote_addr;
 115         m3uac_event_t event;
 116         struct hostent remote_hp;
 117         struct hostent local_hp;
 118         unsigned int flags;
 119         ftdm_mutex_t *mutex;
 120         FILE *log;
 121         unsigned int txseq;
 122         unsigned int rxseq;
 123         unsigned int txwindow;
 124         unsigned int rxseq_reset;
 125         m3uac_ip_cfg_t cfg;
 126         uint32_t hb_elapsed;
 127         int up;
 128 };
 129 
 130 typedef enum {
 131         MSU_FLAG_EVENT = (1 << 0)
 132 } m3uac_flag_t;
 133 
 134 typedef struct m3uac_connection m3uac_connection_t;
 135 
 136 static inline void sctp_no_nagle(int socket)
 137 {
 138     //int flag = 1;
 139     //setsockopt(socket, IPPROTO_SCTP, SCTP_NODELAY, (char *) &flag, sizeof(int));
 140 }
 141 
 142 int m3uac_connection_close(m3uac_connection_t *mcon);
 143 int m3uac_connection_open(m3uac_connection_t *mcon, char *local_ip, int local_port, char *ip, int port);
 144 m3uac_event_t *m3uac_connection_read(m3uac_connection_t *mcon, int iteration);
 145 m3uac_event_t *m3uac_connection_readp(m3uac_connection_t *mcon, int iteration);
 146 int m3uac_connection_write(m3uac_connection_t *mcon, m3uac_event_t *event);
 147 void m3uac_event_init(m3uac_event_t *event, m3uac_event_id_t event_id, int chan, int span);
 148 void m3uac_call_init(m3uac_event_t *event, const char *calling, const char *called, int setup_id);
 149 const char *m3uac_event_id_name(uint32_t event_id);
 150 int m3uac_exec_command(m3uac_connection_t *mcon, int span, int chan, int id, int cmd, int cause);
 151 
 152 
 153 
 154 
 155 /* For Emacs:
 156  * Local Variables:
 157  * mode:c
 158  * indent-tabs-mode:t
 159  * tab-width:4
 160  * c-basic-offset:4
 161  * End:
 162  * For VIM:
 163  * vim:set softtabstop=4 shiftwidth=4 tabstop=4:
 164  */

/* [<][>][^][v][top][bottom][index][help] */