Statistics
| Branch: | Revision:

ml / ml.c @ 8b17961c

History | View | Annotate | Download (5.25 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
#include "transmissionHandler.h"
48
#include "util/udpSocket.h"
49
#include "../includes/ml.h"
50

    
51
void init_messaging_layer(boolean 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){
52

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

    
55
}
56

    
57
/* register callbacks  */
58
void register_Get_recv_pkt_inf(get_recv_pkt_inf_cb recv_pkt_inf_cb){
59

    
60
  register_get_recv_pkt_inf(recv_pkt_inf_cb);
61

    
62
}
63

    
64
void register_Set_monitoring_header_pkt_cb(set_monitoring_header_pkt_cb monitoring_header_pkt_cb ){
65

    
66
  register_set_monitoring_header_pkt_cb(monitoring_header_pkt_cb);
67

    
68
}
69

    
70
void register_Get_recv_data_inf(get_recv_data_inf_cb recv_data_inf_cb){
71

    
72
  register_get_recv_data_inf(recv_data_inf_cb);
73

    
74
}
75

    
76
void register_Get_send_data_inf(get_send_data_inf_cb  send_data_inf_cb){
77

    
78
  register_get_send_data_inf(send_data_inf_cb);
79

    
80
}
81

    
82
void register_Set_monitoring_header_data_cb(set_monitoring_header_data_cb monitoring_header_data_cb){
83

    
84
  register_set_monitoring_header_data_cb(monitoring_header_data_cb);
85

    
86
}
87

    
88
void register_Recv_connection_cb(receive_connection_cb recv_conn_cb){
89

    
90
  register_recv_connection_cb(recv_conn_cb);
91

    
92
}
93

    
94
void register_Error_connection_cb(connection_failed_cb conn_failed){
95

    
96
  register_error_connection_cb(conn_failed);
97

    
98
}
99

    
100
void register_Recv_data_cb(receive_data_cb data_cb,unsigned char msgtype){
101

    
102
  register_recv_data_cb(data_cb,msgtype);
103

    
104
}
105

    
106
void close_Socket(socketID_handle socketID){
107

    
108
  close_socket(socketID);
109

    
110
}
111

    
112
/* connection functions */
113
int open_Connection(socketID_handle external_socketID,int *connectionID,receive_connection_cb connection_cb,void *arg){
114

    
115
  int return_val = open_connection(external_socketID,connectionID,connection_cb,arg); 
116

    
117
  return return_val;
118
}
119

    
120
void close_Connection(const int connectionID){
121

    
122
  close_connection(connectionID);
123

    
124
}
125

    
126
/* transmit data functions  */
127
int send_All_data(const int connectionID,send_all_data_container *container,int nr_entries,unsigned char msgtype,send_params *sParams){
128

    
129
  int returnvalue = send_all_data(connectionID,container,nr_entries,msgtype,sParams);
130
  return returnvalue;
131

    
132
}
133

    
134
void send_Data(const int connectionID,char *sendbuf,int bufsize,unsigned char msgtype,send_params *sParams){
135

    
136
   send_data(connectionID,sendbuf,bufsize,msgtype,sParams);
137

    
138
}
139

    
140
int recv_Data(const int connectionID,char *recvbuf,int *bufsize,recv_params *rParams){
141

    
142
  int i;
143
  i = recv_data(connectionID,recvbuf,bufsize,rParams);
144
  return i;
145

    
146
}
147

    
148
/* setter  */
149
void set_Stun_Server(const int port,const char *ipaddr){
150

    
151
  setStunServer(port,ipaddr);
152

    
153
}
154

    
155
void set_Recv_Timeout(struct timeval timeout_value){
156

    
157
  setRecvTimeout(timeout_value);
158

    
159
}
160

    
161
int get_Standard_ttl(socketID_handle socketID,int *ttl){
162

    
163
  int returnValue = get_standard_ttl(socketID,ttl);
164

    
165
  return returnValue;
166
}
167

    
168
socketID_handle get_Local_socketID(int *errorstatus){
169

    
170
  socketID_handle local_socketID = get_local_socketID(errorstatus);
171

    
172
  return local_socketID;
173

    
174
}
175

    
176
int get_External_IP(char* external_addr){
177

    
178
  int returnvalue = get_external_IP(external_addr);
179

    
180
  return returnvalue; 
181

    
182
}
183

    
184
int socketID_To_String(socketID_handle socketID,char* socketID_string){
185

    
186
  int returnvalue  = socketID_to_String(socketID,socketID_string);
187

    
188
  return returnvalue;
189

    
190
}
191

    
192
socketID_handle string_To_socketID(char* socketID_string){
193

    
194
  socketID_handle new_socketID = string_to_socketID(socketID_string);
195

    
196
  return new_socketID;
197

    
198
}
199

    
200
int get_Connection_status(int connectionID){
201

    
202
  int returnvalue  = get_connection_status(connectionID);
203

    
204
  return returnvalue;
205
    
206
}
207

    
208

    
209
int connection_Exist(socketID_handle socketID){
210

    
211
  int returnvalue  = connection_exist(socketID);
212

    
213
  return returnvalue;
214

    
215
}