This source file includes following definitions.
- sctp_no_nagle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 #ifndef _SANGOMABC_H
35 #define _SANGOMABC_H
36
37 #include "sangoma_boost_interface.h"
38
39 #include <ctype.h>
40 #include <string.h>
41 #ifndef WIN32
42 #include <unistd.h>
43 #include <sys/socket.h>
44 #include <netinet/in.h>
45 #ifdef HAVE_NETINET_SCTP_H
46 #include <netinet/sctp.h>
47 #endif
48 #include <arpa/inet.h>
49 #include <netdb.h>
50 #include <sys/time.h>
51 #endif
52 #include <stdlib.h>
53 #include <errno.h>
54 #include <stdarg.h>
55 #include <stdio.h>
56 #include <sys/types.h>
57 #include <stdarg.h>
58 #include "sigboost.h"
59
60 #define sangomabc_test_flag(p,flag) ((p)->flags & (flag))
61
62 #define sangomabc_set_flag(p,flag) do { \
63 ((p)->flags |= (flag)); \
64 } while (0)
65
66 #define sangomabc_clear_flag(p,flag) do { \
67 ((p)->flags &= ~(flag)); \
68 } while (0)
69
70 #define sangomabc_copy_flags(dest,src,flagz) do { \
71 (dest)->flags &= ~(flagz); \
72 (dest)->flags |= ((src)->flags & (flagz)); \
73 } while (0)
74
75 typedef t_sigboost_callstart sangomabc_event_t;
76 typedef t_sigboost_short sangomabc_short_event_t;
77 typedef uint32_t sangomabc_event_id_t;
78
79 typedef struct sangomabc_ip_cfg
80 {
81 char local_ip[25];
82 int local_port;
83 char remote_ip[25];
84 int remote_port;
85 }sangomabc_ip_cfg_t;
86
87 typedef enum {
88 MSU_FLAG_EVENT = (1 << 0),
89 MSU_FLAG_DOWN = (1 << 1)
90 } sangomabc_flag_t;
91
92
93 struct sangomabc_connection {
94 ftdm_socket_t socket;
95 struct sockaddr_in local_addr;
96 struct sockaddr_in remote_addr;
97 sangomabc_event_t event;
98 struct hostent remote_hp;
99 struct hostent local_hp;
100 unsigned int flags;
101 ftdm_mutex_t *mutex;
102 FILE *log;
103 unsigned int txseq;
104 unsigned int rxseq;
105 unsigned int txwindow;
106 unsigned int rxseq_reset;
107 sangomabc_ip_cfg_t cfg;
108
109 boost_sigmod_interface_t *sigmod;
110 ftdm_queue_t *boost_queue;
111 ftdm_interrupt_t *sock_interrupt;
112 ftdm_span_t *span;
113 int debuglevel;
114 };
115
116 typedef struct sangomabc_connection sangomabc_connection_t;
117
118 typedef struct sangomabc_queue_element {
119 unsigned char boostmsg[sizeof(sangomabc_event_t)];
120 ftdm_size_t size;
121 } sangomabc_queue_element_t;
122
123
124 static __inline__ void sctp_no_nagle(int socket)
125 {
126 #ifdef HAVE_NETINET_SCTP_H
127 int flag = 1;
128 setsockopt(socket, IPPROTO_SCTP, SCTP_NODELAY, (char *) &flag, sizeof(int));
129 #endif
130 }
131
132 int sangomabc_connection_close(sangomabc_connection_t *mcon);
133 int sangomabc_connection_open(sangomabc_connection_t *mcon, char *local_ip, int local_port, char *ip, int port);
134 sangomabc_event_t *__sangomabc_connection_read(sangomabc_connection_t *mcon, int iteration, const char *file, const char *func, int line);
135 sangomabc_event_t *__sangomabc_connection_readp(sangomabc_connection_t *mcon, int iteration, const char *file, const char *func, int line);
136 int __sangomabc_connection_write(sangomabc_connection_t *mcon, sangomabc_event_t *event, const char *file, const char *func, int line);
137 int __sangomabc_connection_writep(sangomabc_connection_t *mcon, sangomabc_event_t *event, const char *file, const char *func, int line);
138 #define sangomabc_connection_write(_m,_e) __sangomabc_connection_write(_m, _e, __FILE__, __FUNCTION__, __LINE__)
139 #define sangomabc_connection_writep(_m,_e) __sangomabc_connection_writep(_m, _e, __FILE__, __FUNCTION__, __LINE__)
140 #define sangomabc_connection_read(_m,_e) __sangomabc_connection_read(_m, _e, __FILE__, __FUNCTION__, __LINE__)
141 #define sangomabc_connection_readp(_m,_e) __sangomabc_connection_readp(_m, _e, __FILE__, __FUNCTION__, __LINE__)
142 void sangomabc_event_init(sangomabc_short_event_t *event, sangomabc_event_id_t event_id, int chan, int span);
143 void sangomabc_call_init(sangomabc_event_t *event, const char *calling, const char *called, int setup_id);
144 const char *sangomabc_event_id_name(uint32_t event_id);
145 int sangomabc_exec_command(sangomabc_connection_t *mcon, int span, int chan, int id, int cmd, int cause, int flags);
146 int sangomabc_exec_commandp(sangomabc_connection_t *pcon, int span, int chan, int id, int cmd, int cause);
147
148 #define BOOST_EVENT_SPAN(sigmod, event) ((sigmod) ? event->span : event->span + 1)
149 #define BOOST_EVENT_CHAN(sigmod, event) ((sigmod) ? event->chan : event->chan + 1)
150
151
152 #endif
153
154
155
156
157
158
159
160
161
162
163
164