Statistics
| Branch: | Revision:

ml / ml.c @ 8808cf25

History | View | Annotate | Download (5.69 KB)

1
/*
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

    
35
#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
#include <event.h>
46

    
47

    
48
#include "ml.h"
49
#include "transmissionHandler.h"
50
#include "util/udpSocket.h"
51

    
52
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

    
54
  init_transmissionHandler(recv_data_cb,timeout_value,port,ipaddr,stun_port,stun_ipaddr,local_socketID_cb,arg);
55

    
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
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
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
int open_Connection(socketID_handle external_socketID,receive_connection_cb connection_cb,void *arg){
122

    
123
  return open_connection(external_socketID,connection_cb,arg);
124

    
125
}
126

    
127
void close_Connection(const int connectionID){
128

    
129
  close_connection(connectionID);
130

    
131
}
132

    
133
/* transmit data functions  */
134
int send_All_data(const int connectionID,send_all_data_container *container,int nr_entries,unsigned char msgtype,send_params *sParams){
135

    
136
  return send_all_data(connectionID,container,nr_entries,msgtype,sParams);
137

    
138
}
139

    
140
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
  return recv_data(connectionID,recvbuf,bufsize,rParams);
149

    
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
int get_Standard_ttl(socketID_handle socketID,uint8_t *ttl){
166

    
167
  return get_standard_ttl(socketID,ttl);
168

    
169
}
170

    
171
socketID_handle get_Local_socketID(int *errorstatus){
172

    
173
  return get_local_socketID(errorstatus);
174

    
175
}
176

    
177
int get_External_IP(char* external_addr){
178

    
179
  return get_external_IP(external_addr);
180

    
181
}
182

    
183
int socketID_To_String(socketID_handle socketID,char* socketID_string, size_t len){
184

    
185
  return socketID_to_String(socketID,socketID_string, len);
186

    
187
}
188

    
189
int string_To_SocketID(char* socketID_string, socketID_handle socketID){
190

    
191
  return string_to_socketID(socketID_string, socketID);
192

    
193
}
194

    
195
int get_Connection_status(int connectionID){
196

    
197
  return get_connection_status(connectionID);
198
    
199
}
200

    
201

    
202
int connection_Exist(socketID_handle socketID){
203

    
204
  return connection_exist(socketID);
205

    
206
}
207

    
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
{ 
223
        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
}
232

    
233
int get_Path_Mtu(int ConnectionId) {
234
        get_path_mtu(ConnectionId);
235
}