aboutsummaryrefslogtreecommitdiffstats
path: root/sualibrary/sua/sua_database.h
blob: 7fce37282285bd1dfb7f8d6d2ec0cfc887ce2d37 (plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
/***************************************************************************
                          sua_database.h  -  description
                             -------------------
    begin                : Tue Jan 8 2002
    copyright            : (C) 2002 by Lode Coene
    email                : lode.coene@siemens.atea.be
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
/*
 *  $Id: sua_database.h,v 1.4 2002/03/01 12:57:38 p82609 Exp $
 *
 * SUA implementation according to SUA draft issue 8.
 *
 * Author(s): Lode Coene
 *            
 *
 * Copyright (C) 2001 by Siemens Atea, Herentals, Belgium.
 *
 * Realized in co-operation between Siemens Atea and 
 * Siemens AG, Munich, Germany.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Contact: gery.verwimp@siemens.atea.be
 *          lode.coene@siemens.atea.be
 *
 * The alternative comment
 * inspiration : Ann S.
 * "Don't mention the war."
 *
 * Purpose: This code-file defines the SUA database objects for:
 *          - Sybsystem Number(SSN) Object
 *          - Address Object
 *          - Local SUA Object
 *          - Local SUA List
 *          - Remote SUA object  
 *          - Remote SUA List      
 *          - SUA Name Object(host names/Global Titles)
 *          - SUA Name List     
 *          - SUA Association Object
 *          - SUA Association List
 *          - SUA Application Server Process (ASP) Object
 *          - SUA Application Server (AS) Object
 *          - SUA Application Server (AS) List 
 */

#ifndef SUA_DATABASE_H
#define SUA_DATABASE_H

#include "sua.h"
#include "sua_asp_mgnt.h"

#include <string>



typedef enum {nc_empty, nc_ipv4, nc_ipv6} db_net_class;

const int db_MAX_MULTIHOME_ADDR = 10;
const int db_MAX_LOCAL_SUA = 10;
const int db_MAX_REMOTE_SUA = 1000;
const int db_MAX_SSN_SUA = 256;
const int db_MAX_SUA_AS = 100;
const int db_MAX_ASP_IN_1AS = 8; /* maximal 8 ASP's can be covered by a single AS */
const int db_MAX_1ASP_IN_AS = 4; /* 1 ASP can appear in maximal up till 4 different AS's */

/***********************************************************************/
/* Sua_SSNObject                                                       */
/***********************************************************************/
class db_Sua_SSNObject { 
 public:
  short ssn;
 public:
  void read_ssn(string ssn); 
}; ///:~

/***********************************************************************/
/* Sua_LocalObject                                                     */
/***********************************************************************/
class db_Sua_LocalObject{
 public:
  db_Sua_SSNObject  ssn;
  /* contains the initial SUA association */
  unsigned int init_assoc_id; 
  /* the local sua id with which it is linked. */
  unsigned int sua_id;
  Sua_ULP_CallBacks SUA_APLCallBack;
 public:
  // functions of the Class
  void initialize();
}; ///:~

/***********************************************************************/
/* Sua_LocalList                                                       */
/***********************************************************************/
class db_Sua_LocalList{
  public:
  int num_of_instance;
  db_Sua_LocalObject instance[db_MAX_LOCAL_SUA];  
  void initialize();
  void read_ssn(string ssn);
  short register_instance( unsigned int       local_sua_id, 
			   Sua_ULP_CallBacks  SUACallbackFunctions,
			   unsigned int       init_assoc_id
			  );
  short unregister_instance();
  void increase_instance();
}; ///:~

/***********************************************************************/
/* Sua_RemoteObject                                                    */
/***********************************************************************/
class db_Sua_RemoteObject{
 public:
  db_Sua_SSNObject ssn;
  /*  contains the SCTP assoc id */
  unsigned int SCTP_assoc_id; 
  /* contains the local sua id with which it is linked. */
  unsigned int sua_id;
 public:
  // functions of the Class
  void initialize();
}; ///:~

/***********************************************************************/
/* Sua_RemoteList                                                      */
/***********************************************************************/
class db_Sua_RemoteList{
  public:
  int num_of_instance;
  public:
  db_Sua_RemoteObject instance[db_MAX_REMOTE_SUA];  
  void initialize();
  void read_ssn(string ssn);
  void increase_instance();
  
}; ///:~


/***********************************************************************/
/* Sua_AddressObject                                                   */
/***********************************************************************/
class db_Sua_AddressObject { 
 public:
  int nr_of_addrs; // number of ip addresses used(multihoming)
  unsigned char address_string[db_MAX_MULTIHOME_ADDR][SCTP_MAX_IP_LEN];
  ipvxunion addrs[db_MAX_MULTIHOME_ADDR];
  SS7union pc;
 public:
  void read_addr_param(string address);
  void read_pointcode_param(string point_code);
  void read_port_num(string port);
}; ///:~

/***********************************************************************/
/* Sua_ApplicationServerProcessObject (ASP)                            */
/***********************************************************************/
class db_Sua_ASPObject { 
 public:
  asp_Sua_asp_state_set status; /* status of the ASP */
  short linked_to_AS[db_MAX_1ASP_IN_AS]; /* this ASP may belong to different Application Servers(AS) */
 public:
  void initialize();
  bool activate( unsigned int sua_assoc_id, short mode );
  void deactivate( unsigned int sua_assoc_id, short mode );
  void down( unsigned sua_assoc_id, short mode );
  void up( unsigned sua_assoc_id, short mode );
}; ///:~

/***********************************************************************/
/* Sua_LS_OverRideObject (LS_OverRide)                                 */
/***********************************************************************/
class db_Sua_LS_OverRideObject { 
 private:
  short     ASP_to_use; /* ASP presently being the workhorse)*/
 public:
  void     assign_ASP(short ASP_num);
  short    ASP_used();
}; ///:~

/***********************************************************************/
/* Sua_LS_RoundRobinObject (LS_RoundRobin)                             */
/***********************************************************************/
class db_Sua_LS_RoundRobinObject { 
 private:
  short     ASP_to_use; /* ASP presently being the workhorse)*/
 public:
  short     ASP_used();
}; 

/***********************************************************************/
/* Sua_LoadShareObject (LS_AS)                                         */
/***********************************************************************/
class db_Sua_LoadShareObject { 
 public:
  asp_Sua_loadmode_set        load_mode; /* mode of loadsharing)*/
  db_Sua_LS_OverRideObject    override;  /* AS has a ASP in override */
  db_Sua_LS_RoundRobinObject  RRobin;    /* AS is RR all active ASP's */
}; ///:~


/***********************************************************************/
/* Sua_ApplicationServerObject (AS)                                    */
/***********************************************************************/
class db_Sua_ASObject { 
 public:
  asp_Sua_as_state_set  status; /* status of the AS */
  short ASP_linked_to_this_AS[db_MAX_ASP_IN_1AS];/* AS may contain a couple of ASP's */
  db_Sua_LoadShareObject loadshare;
 public:
  void initialize();
}; ///:~

/***********************************************************************/
/* Sua_ApplicationServerList (AS list)                                 */
/***********************************************************************/
class db_Sua_ASList{
  public:
  int num_of_instance;
  db_Sua_ASObject instance[db_MAX_SUA_AS];  
 public:
  void initialize();
  short read_AS( string       address_str, 
		 unsigned int sua_id 
	       );
  void override_ASP( unsigned int  asp_sua_assoc_id,
		     unsigned int  AS_id,
		     short         mode
		   );
}; ///:~

/***********************************************************************/
/* Sua_AssociationsObject                                              */
/***********************************************************************/
class db_Sua_AssociationObject { 
 public:
  unsigned int          SCTP_assoc_id;
  unsigned int          SCTP_instance_name;
  unsigned int          remote_sua_id;
  unsigned int          local_sua_id;
  short                 nr_of_inbound_streams;
  short                 nr_of_outbound_streams;
  db_Sua_ASPObject      asp;
  db_net_class          netw; // sort of network(v4/v6) to be used
  // ip source/destination addresses , should be the same network type
  db_Sua_AddressObject  Source;
  db_Sua_AddressObject  Dest;
 public:
  void initialize();
  short shutdown();
}; ///:~

/***********************************************************************/
/* Sua_AssociationList                                                 */
/***********************************************************************/
class db_Sua_AssociationList{
  public:
  int num_of_instance;
  db_Sua_AssociationObject instance[db_MAX_REMOTE_SUA];  
 public:
  void initialize();
  void read_Source_addr(string address);
  void read_Dest_addr(string address);
  void read_Source_pointcode(string address);
  void read_Dest_pointcode(string address);
  void read_Source_port(string port);
  void read_Dest_port(string port);
  void read_stream_number(string stream_num);
  short register_instance(SCTP_ulp_Callbacks APLCallbackFunctions,
			  Sua_ULP_CallBacks  SUACallbackFunctions,
			  db_Sua_LocalList&  local_sua
			  );
  short unregister_instance();
  unsigned int Find_association( unsigned int sctp_assoc_id,
				 unsigned int &Local_sua_id,
				 unsigned int &Remote_sua_id
			       );
  unsigned int Find_local_sua( sccp_addr_str&     local_address 
			     );
  short associate_instance( db_Sua_LocalList&  local_sua,
			    db_Sua_RemoteList& remote_sua
			  );
  unsigned int passive_associate( unsigned int assoc_id,
				  db_Sua_LocalList& local_sua,
				  db_Sua_RemoteList& remote_sua,
				  unsigned short  nr_of_dest_addr,
				  unsigned short  nr_of_input_streams,
				  unsigned short  nr_of_output_streams
				);
  unsigned int Dynamic_Associate( db_Sua_LocalList&  local_sua,
				  db_Sua_RemoteList& remote_sua,
				  sccp_addr_str&     cld, 
				  sccp_addr_str&     clg,
				  unsigned short     nr_of_dest_addr,
				  unsigned short     nr_of_input_streams,
				  unsigned short     nr_of_output_streams
				);
  short Terminate_remote_assoc_instance();
  short shutdown();
  signed int resolve_host_name( hostname_str&  dest_name,
		  													pointcode_str& dest_pc
	        										);
  signed int route_msg( sccp_addr_str& cld,
		                    sccp_addr_str& clg,
		                    int&           sua_assoc_id
		                   );
  signed int route_on_IPpc ( ipvxunion& dest_pc,
			     									 ipvxunion& org_pc,
			     									 int&       sua_assoc_id
			   									 );
  signed int route_on_SS7pc ( SS7union&  dest_pc,
			    									  SS7union&  org_pc,
			      									int&       sua_assoc_id
			    									);
  signed int route_on_GTname ( hostname_str&  dest_name,
			      									 hostname_str&  org_name,
			       									 int&           sua_assoc_id,
			       									 pointcode_str& dest_pc,
			       									 pointcode_str& org_pc
			     									 );
  void increase_instance();
  bool activate( unsigned int sua_id,
		 short mode 
	       );
  void deactivate( unsigned int sua_id,
		   short mode 
		 );
  void down( unsigned int sua_id,
	     short mode 
	   );
  void up( unsigned int sua_id,
	   short mode 
	 );
}; ///:~

/***********************************************************************/
/* Sua_NameObject                                                      */
/***********************************************************************/
class db_Sua_NameObject { 
 public:
  unsigned int          SUA_assoc_id;  
 public:
  void initialize();

}; ///:~

/***********************************************************************/
/* Sua_NameList                                                        */
/***********************************************************************/
class db_Sua_NameList{
  public:
  int num_of_instance;
  db_Sua_NameObject instance[db_MAX_REMOTE_SUA];  
 public:
  void initialize();
  string read_host_name(string name);
  string read_Global_Title(string name);
  unsigned int perform_GTT( sccp_addr_str& cld_in, 
			    sccp_addr_str& clg_in,
			    sccp_addr_str& cld_out, 
			    sccp_addr_str& clg_out
			 );
  void increase_instance();
}; ///:~

#endif  // SUA_DATABASE_H

//end of module sua_database.h