Statistics
| Branch: | Revision:

ml / ml.c @ 6214e30a

History | View | Annotate | Download (5.71 KB)

1 a0a1f630 KristianBeckers
/*
2
 *          Policy Management
3
 *
4
 *          NEC Europe Ltd. PROPRIETARY INFORMATION
5
 *
6
 * This software is supplied under the terms of a license agreement
7
 * or nondisclosure agreement with NEC Europe Ltd. and may not be
8
 * copied or disclosed except in accordance with the terms of that
9
 * agreement.
10
 *
11
 *      Copyright (c) 2009 NEC Europe Ltd. All Rights Reserved.
12
 *
13
 * Authors: Kristian Beckers  <beckers@nw.neclab.eu>
14
 *          Sebastian Kiesel  <kiesel@nw.neclab.eu>
15
 *          
16
 *
17
 * NEC Europe Ltd. DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
18
 * INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY
19
 * AND FITNESS FOR A PARTICULAR PURPOSE AND THE WARRANTY AGAINST LATENT
20
 * DEFECTS, WITH RESPECT TO THE PROGRAM AND THE ACCOMPANYING
21
 * DOCUMENTATION.
22
 *
23
 * No Liability For Consequential Damages IN NO EVENT SHALL NEC Europe
24
 * Ltd., NEC Corporation OR ANY OF ITS SUBSIDIARIES BE LIABLE FOR ANY
25
 * DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS
26
 * OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF INFORMATION, OR
27
 * OTHER PECUNIARY LOSS AND INDIRECT, CONSEQUENTIAL, INCIDENTAL,
28
 * ECONOMIC OR PUNITIVE DAMAGES) ARISING OUT OF THE USE OF OR INABILITY
29
 * TO USE THIS PROGRAM, EVEN IF NEC Europe Ltd. HAS BEEN ADVISED OF THE
30
 * POSSIBILITY OF SUCH DAMAGES.
31
 *
32
 *     THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
33
 */
34 07355669 TivadarSzemethy
35 a0a1f630 KristianBeckers
#include <string.h>
36
#include <stdio.h>
37
#include <stddef.h>
38
#include <sys/types.h>
39
#include <netinet/in.h>
40
#include <arpa/inet.h>
41
#include <errno.h>
42
#include <stdlib.h>
43
#include <unistd.h>
44
#include <time.h>
45 2a178954 KristianBeckers
#include <event.h>
46 07355669 TivadarSzemethy
47 380cf1b9 RobertBirke
48 90cb1b52 TivadarSzemethy
#include "ml.h"
49 a0a1f630 KristianBeckers
#include "transmissionHandler.h"
50
#include "util/udpSocket.h"
51 07355669 TivadarSzemethy
52 90cb1b52 TivadarSzemethy
void init_messaging_layer(bool recv_data_cb,struct timeval timeout_value,const int port,const char *ipaddr,const int stun_port,const char *stun_ipaddr,receive_localsocketID_cb local_socketID_cb,void *arg){
53 d18d76c2 TivadarSzemethy
54 2a178954 KristianBeckers
  init_transmissionHandler(recv_data_cb,timeout_value,port,ipaddr,stun_port,stun_ipaddr,local_socketID_cb,arg);
55 a0a1f630 KristianBeckers
56
}
57
58
/* register callbacks  */
59
void register_Get_recv_pkt_inf(get_recv_pkt_inf_cb recv_pkt_inf_cb){
60
61
  register_get_recv_pkt_inf(recv_pkt_inf_cb);
62
63
}
64
65 8601bccf RobertBirke
void register_Get_send_pkt_inf(get_send_pkt_inf_cb  send_pkt_inf_cb){
66
67
  register_get_send_pkt_inf(send_pkt_inf_cb);
68
69
}
70
71
72 a0a1f630 KristianBeckers
void register_Set_monitoring_header_pkt_cb(set_monitoring_header_pkt_cb monitoring_header_pkt_cb ){
73
74
  register_set_monitoring_header_pkt_cb(monitoring_header_pkt_cb);
75
76
}
77
78
void register_Get_recv_data_inf(get_recv_data_inf_cb recv_data_inf_cb){
79
80
  register_get_recv_data_inf(recv_data_inf_cb);
81
82
}
83
84
void register_Get_send_data_inf(get_send_data_inf_cb  send_data_inf_cb){
85
86
  register_get_send_data_inf(send_data_inf_cb);
87
88
}
89
90
void register_Set_monitoring_header_data_cb(set_monitoring_header_data_cb monitoring_header_data_cb){
91
92
  register_set_monitoring_header_data_cb(monitoring_header_data_cb);
93
94
}
95
96
void register_Recv_connection_cb(receive_connection_cb recv_conn_cb){
97
98
  register_recv_connection_cb(recv_conn_cb);
99
100
}
101
102
void register_Error_connection_cb(connection_failed_cb conn_failed){
103
104
  register_error_connection_cb(conn_failed);
105
106
}
107
108
void register_Recv_data_cb(receive_data_cb data_cb,unsigned char msgtype){
109
110
  register_recv_data_cb(data_cb,msgtype);
111
112
}
113
114
void close_Socket(socketID_handle socketID){
115
116
  close_socket(socketID);
117
118
}
119
120
/* connection functions */
121 380cf1b9 RobertBirke
int open_Connection(socketID_handle external_socketID,receive_connection_cb connection_cb,void *arg){
122 a0a1f630 KristianBeckers
123 8808cf25 CsabaKiraly
  return open_connection(external_socketID,connection_cb,arg);
124 a0a1f630 KristianBeckers
125
}
126
127
void close_Connection(const int connectionID){
128
129
  close_connection(connectionID);
130
131
}
132
133
/* transmit data functions  */
134 2a178954 KristianBeckers
int send_All_data(const int connectionID,send_all_data_container *container,int nr_entries,unsigned char msgtype,send_params *sParams){
135
136 8808cf25 CsabaKiraly
  return send_all_data(connectionID,container,nr_entries,msgtype,sParams);
137 2a178954 KristianBeckers
138
}
139
140 a0a1f630 KristianBeckers
void send_Data(const int connectionID,char *sendbuf,int bufsize,unsigned char msgtype,send_params *sParams){
141
142
   send_data(connectionID,sendbuf,bufsize,msgtype,sParams);
143
144
}
145
146
int recv_Data(const int connectionID,char *recvbuf,int *bufsize,recv_params *rParams){
147
148 8808cf25 CsabaKiraly
  return recv_data(connectionID,recvbuf,bufsize,rParams);
149 a0a1f630 KristianBeckers
150
}
151
152
/* setter  */
153
void set_Stun_Server(const int port,const char *ipaddr){
154
155
  setStunServer(port,ipaddr);
156
157
}
158
159
void set_Recv_Timeout(struct timeval timeout_value){
160
161
  setRecvTimeout(timeout_value);
162
163
}
164
165 8601bccf RobertBirke
int get_Standard_ttl(socketID_handle socketID,uint8_t *ttl){
166 a0a1f630 KristianBeckers
167 8808cf25 CsabaKiraly
  return get_standard_ttl(socketID,ttl);
168 a0a1f630 KristianBeckers
169 07355669 TivadarSzemethy
}
170 2a178954 KristianBeckers
171
socketID_handle get_Local_socketID(int *errorstatus){
172
173 8808cf25 CsabaKiraly
  return get_local_socketID(errorstatus);
174 2a178954 KristianBeckers
175
}
176
177
int get_External_IP(char* external_addr){
178
179 8808cf25 CsabaKiraly
  return get_external_IP(external_addr);
180 2a178954 KristianBeckers
181
}
182
183 7455d709 TivadarSzemethy
int socketID_To_String(socketID_handle socketID,char* socketID_string, size_t len){
184 2a178954 KristianBeckers
185 8808cf25 CsabaKiraly
  return socketID_to_String(socketID,socketID_string, len);
186 2a178954 KristianBeckers
187
}
188
189 5842fcf1 TivadarSzemethy
int string_To_SocketID(const char* socketID_string, socketID_handle socketID){
190 2a178954 KristianBeckers
191 8808cf25 CsabaKiraly
  return string_to_socketID(socketID_string, socketID);
192 2a178954 KristianBeckers
193
}
194
195
int get_Connection_status(int connectionID){
196
197 8808cf25 CsabaKiraly
  return get_connection_status(connectionID);
198 2a178954 KristianBeckers
    
199
}
200
201
202 6214e30a TivadarSzemethy
int connection_Exist(socketID_handle socketID, bool ready){
203 2a178954 KristianBeckers
204 6214e30a TivadarSzemethy
  return connection_exist(socketID,ready);
205 2a178954 KristianBeckers
206
}
207 2c702104 RobertBirke
208
//Added by Robert Birke as comodity functions
209
210
int print_SocketID(socketID_handle socketID) {
211
        return print_socketID(socketID);
212
}
213
int hash_SocketID(socketID_handle sock) {
214
   return hash_socketID(sock);
215
}
216
217
int compare_SocketIDs(socketID_handle sock1, socketID_handle sock2) {
218
        return compare_socketIDs(sock1,sock2);
219
}
220
221
int compare_SocketIDs_By_Port(socketID_handle sock1, socketID_handle sock2)
222 380cf1b9 RobertBirke
{ 
223 2c702104 RobertBirke
        if (sock1->internal_addr.udpaddr.sin_port !=
224
                 sock2->internal_addr.udpaddr.sin_port)
225
                        return 1;
226
227
        if (sock1->external_addr.udpaddr.sin_port !=
228
                 sock2->external_addr.udpaddr.sin_port)
229
                        return 1;
230
        return 0;
231 380cf1b9 RobertBirke
}
232 bcf9c2dd RobertBirke
233
int get_Path_Mtu(int ConnectionId) {
234
        get_path_mtu(ConnectionId);
235
}