aboutsummaryrefslogtreecommitdiffstats
path: root/sualibrary/sua/sua_datassoc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sualibrary/sua/sua_datassoc.cpp')
-rw-r--r--sualibrary/sua/sua_datassoc.cpp916
1 files changed, 476 insertions, 440 deletions
diff --git a/sualibrary/sua/sua_datassoc.cpp b/sualibrary/sua/sua_datassoc.cpp
index dd29625..bec142d 100644
--- a/sualibrary/sua/sua_datassoc.cpp
+++ b/sualibrary/sua/sua_datassoc.cpp
@@ -15,7 +15,7 @@
* *
***************************************************************************/
/*
- * $Id: sua_datassoc.cpp,v 1.6 2002/03/15 12:53:53 p82609 Exp $
+ * $Id: sua_datassoc.cpp,v 1.11 2002/11/12 11:04:12 p82609 Exp $
*
* SUA implementation according to SUA draft issue 6.
*
@@ -241,64 +241,47 @@ void db_Sua_AssociationList:: read_stream_number(string stream_num){
}
/***********************************************************************/
-/* db_Sua_AssociationList::resolve_host_name */
+/* Sua_AssociationList::read_Source_GT */
/***********************************************************************/
-signed int db_Sua_AssociationList::resolve_host_name ( hostname_str& dest_name,
- pointcode_str& dest_pc
- )
+void db_Sua_AssociationList::read_Source_GT( db_Sua_NameList &NameDB,
+ string address
+ )
{
- struct hostent *hptr;
- char **pptr;
- char str[INET6_ADDRSTRLEN];
- char *dest_carr;
-
- /* resolving can be done via: */
- /* - local global Titel database */
- /* - resolve hostname via DNS(simplest for single hop translations) */
- dest_carr = dest_name;
-
- if ((hptr = gethostbyname( dest_carr )) == NULL)
- {
- cout << "Hostname " << dest_name << " not known in DNS.\n";
- return(-1);
- }
-
-#ifdef DEBUG
- cout << "Hostname " << dest_name << " resolved to dest IP address(es)\n";
- cout << "IP address length = "<< hptr->h_length << "\n";
-#endif
+ ;
+}
- /* initialise the length field of the structure: */
- /* length field is NOT always present in every Unix like operating system */
- dest_pc.ipvx.ch[0] = 0;
+/***********************************************************************/
+/* Sua_AssociationList::read_Dest_GT */
+/***********************************************************************/
+void db_Sua_AssociationList::read_Dest_GT( db_Sua_NameList &NameDB,
+ string address
+ )
+{
+ unsigned int sua_assoc_id = num_of_instance;
+
+ NameDB.read_Global_Title( sua_assoc_id,
+ address
+ );
+
+ NameDB.num_of_instance++;
+
+}
- pptr = hptr->h_addr_list;
- for ( ; (*pptr != NULL) ;pptr++)
- {
- inet_ntop(hptr->h_addrtype, *pptr, str,sizeof(str));
-#ifdef DEBUG
- cout << str << "\n";
-#endif
- /* got a IP address */
- dest_pc.ipvx.sa.sa_family = hptr->h_addrtype;
- if (dest_pc.ipvx.sa.sa_family == AF_INET)
- inet_pton( AF_INET,
- str,
- &dest_pc.ipvx.sin.sin_addr
- );
- else if (dest_pc.ipvx.sa.sa_family == AF_INET6)
- inet_pton( AF_INET6,
- str,
- &dest_pc.ipvx.sin6.sin6_addr
- );
- else
- {
- cout << "ERROR resolve_host_name: Unknown IP addresstype\n";
- return(-2);
- }
- }
- return(0);
-};
+/***********************************************************************/
+/* Sua_AssociationList::read_hostname */
+/***********************************************************************/
+string db_Sua_AssociationList::read_host_name( db_Sua_NameList &NameDB,
+ string address )
+{
+ unsigned int sua_assoc_id = num_of_instance;
+ string host_ip_addr;
+
+ host_ip_addr = NameDB.read_host_name( sua_assoc_id,
+ address
+ );
+
+ return(host_ip_addr);
+}
/***********************************************************************/
/* Sua_AssociationList::register_instance */
@@ -446,135 +429,6 @@ Find_association( unsigned int sctp_assoc_id,
return(sua_assoc_id);
};
-/***********************************************************************/
-/* Sua_AssociationList::Find_local_sua */
-/***********************************************************************/
-unsigned int db_Sua_AssociationList::
-Find_local_sua( sccp_addr_str& local_address
- )
-{
- pointcode_str dest_pc;
- short i = 1, j = 0, count, addr_start, addr_stop;
- unsigned int Local_sua_id = 0;
- bool result = FALSE;
-
- while ((i < db_MAX_REMOTE_SUA) && !(result) && (instance[i].Source.nr_of_addrs != 0))
- {
- j = 0;
- while ((j < instance[i].Source.nr_of_addrs) && !(result))
- {
- /*result = ((instance[i].Source.addrs[j].sin.sin_addr.s_addr == local_address.pc.ipvx.sin.sin_addr.s_addr) ||
- (instance[i].Source.addrs[j].sin6.sin6_addr.s6_addr == local_address.pc.ipvx.sin6.sin6_addr.s6_addr));
-*/
- if (local_address.address_fields_present.pc == ipvx_pc_present)
- {
- result = (local_address.pc.ipvx.sa.sa_family == instance[i].Source.addrs[j].sa.sa_family);
- if (local_address.pc.ipvx.sa.sa_family == AF_INET)
- {
- addr_start = 4;
- addr_stop = addr_start + 4;
- }
- else if (local_address.pc.ipvx.sa.sa_family == AF_INET6)
- {
- addr_start = 8;
- addr_stop = addr_start + 16;
- }
- else
- {
- addr_start = 0;
- addr_stop = 0;
- result = false;
- cout << "ERROR Find_local_sua: Unknown IPvx addresstype\n";
- }
- /* compare the address family field */
- result = result &&
- (local_address.pc.ipvx.ch[1] == instance[i].Source.addrs[j].ch[1]);
-
- /* compare the ipv4/ipv6 address field */
- for (count = addr_start; count < addr_stop; count++)
- {
- result = result &&
- (local_address.pc.ipvx.ch[count] == instance[i].Source.addrs[j].ch[count]);
- }
- }
- else if (local_address.address_fields_present.pc == ss7_pc_present)
- {
- result = (local_address.pc.ss7.ITU14.family == instance[i].Source.pc.ITU14.family);
- if (((local_address.pc.ss7.ITU14.family == ITU14bit) ||
- (local_address.pc.ss7.ITU14.family == ITU24bit)) ||
- (local_address.pc.ss7.ITU14.family == ANSI24bit))
- {
- /* compare the ITU 14/24bit or ANSI 24bit PC address field */
- result = result &&
- (local_address.pc.ss7.ITU14.pc == instance[i].Source.pc.ITU14.pc);
- }
- else
- {
- result = false;
- cout << "ERROR Find_local_sua: Unknown SS7 pointcode addresstype\n";
- }
- }
- else if (local_address.address_fields_present.name_gt == hostname_present)
- {
- count = 0;
- result = resolve_host_name ( local_address.name.HostName,
- dest_pc
- );
-
- result = (dest_pc.ipvx.sa.sa_family == instance[i].Source.addrs[j].sa.sa_family);
-
- if (dest_pc.ipvx.sa.sa_family == AF_INET)
- {
- addr_start = 4;
- addr_stop = addr_start + 4;
- }
- else if (dest_pc.ipvx.sa.sa_family == AF_INET6)
- {
- addr_start = 8;
- addr_stop = addr_start + 16;
- }
- else
- {
- addr_start = 0;
- addr_stop = 0;
- result = false;
- cout << "ERROR Find_local_sua: Unknown IPvx addresstype\n";
- }
- /* compare the address family field : already done */
- /* compare the ipv4/ipv6 address field */
- short k=0;
- for (count = addr_start; count < addr_stop; count++)
- {
- result = result &&
- (dest_pc.ipvx.ch[count] == instance[i].Source.addrs[j].ch[count]);
- k++;
- }
-
- }
- else if (local_address.address_fields_present.name_gt == GT_present)
- {
- cout << "ERROR Find_local_sua: GT code not implemented yet\n";
- }
- else
- {
- cout << "ERROR Find_local_sua: Unknown SUA addresstype\n";
- result = false;
- }
-
- if (result)
- {
- Local_sua_id = instance[i].local_sua_id;
-#ifdef DEBUG
- cout << "Find_local_sua: local_sua_id = " << Local_sua_id << " , instance "<< i << "\n";
-#endif
- }
- j++;
- }
- i++;
- }
-
- return(Local_sua_id);
-};
/***********************************************************************/
/* Sua_AssociationList::passive_associate */
@@ -610,13 +464,13 @@ passive_associate( unsigned int assoc_id,
num_of_instance++;
assoc_instance_idx = num_of_instance;
instance[assoc_instance_idx].Source = instance[assoc_instance_idx-1].Source;
-
+
instance[assoc_instance_idx].nr_of_inbound_streams = nr_of_input_streams ;
instance[assoc_instance_idx].nr_of_outbound_streams = nr_of_input_streams ;
}
remote_sua.increase_instance();
-
+
instance[assoc_instance_idx].SCTP_assoc_id = assoc_id;
instance[assoc_instance_idx].remote_sua_id = remote_sua.num_of_instance;
remote_sua.instance[remote_sua.num_of_instance].ssn.ssn = local_sua.instance[local_sua.num_of_instance].ssn.ssn;
@@ -628,62 +482,62 @@ passive_associate( unsigned int assoc_id,
char logstring[100];
sprintf(logstring, "Associate Remote SUA(& SCTP) instance nr %d with local SUA(& SCTP) instance nr %d", assoc_id, assoc_instance_idx );
event_log("sua_database.c",logstring);
-
-
+
+
result = sctp_getAssocStatus( instance[assoc_instance_idx].SCTP_assoc_id,
- &status
- );
+ &status
+ );
/* conversion and fill in the destination address */
instance[assoc_instance_idx].Dest.nr_of_addrs = nr_of_dest_addr;
for(k=0; k < instance[assoc_instance_idx].Dest.nr_of_addrs ; k++)
{
result = sctp_getPathStatus( instance[assoc_instance_idx].SCTP_assoc_id,
- k,
- &path_x_status
- );
- instance[assoc_instance_idx].Dest.address_string[k] = path_x_status.destinationAddress;
- instance[assoc_instance_idx].Dest.addrs[k].sin.sin_port = status.destPort;
- }
+ k,
+ &path_x_status
+ );
+ instance[assoc_instance_idx].Dest.address_string[k] = path_x_status.destinationAddress;
+ instance[assoc_instance_idx].Dest.addrs[k].sin.sin_port = status.destPort;
+ }
/* try to figure out ipv4 or v6 address family: get it from the source address */
k = 0;
instance[assoc_instance_idx].Dest.addrs[0].sa.sa_family = AF_LOCAL;
cont = true;
while ((k < 24) && (cont))
{
- if (instance[assoc_instance_idx].Dest.address_string[0][k] == '.')
- {
- cont = false;
- instance[assoc_instance_idx].Dest.addrs[0].sa.sa_family = AF_INET;
- }
- if (instance[assoc_instance_idx].Dest.address_string[0][k] == ':')
- {
- cont = false;
- instance[assoc_instance_idx].Dest.addrs[0].sa.sa_family = AF_INET6;
- }
- k++;
- }
-
+ if (instance[assoc_instance_idx].Dest.address_string[0][k] == '.')
+ {
+ cont = false;
+ instance[assoc_instance_idx].Dest.addrs[0].sa.sa_family = AF_INET;
+ }
+ if (instance[assoc_instance_idx].Dest.address_string[0][k] == ':')
+ {
+ cont = false;
+ instance[assoc_instance_idx].Dest.addrs[0].sa.sa_family = AF_INET6;
+ }
+ k++;
+ }
+
for(k=0; k < instance[assoc_instance_idx].Dest.nr_of_addrs ; k++)
{
- if (instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family == AF_INET)
- bla = inet_pton( instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family,
- (char *)instance[assoc_instance_idx].Dest.address_string[k],
- &instance[assoc_instance_idx].Dest.addrs[k].sin.sin_addr
- );
+ if (instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family == AF_INET)
+ bla = inet_pton( instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family,
+ (char *)instance[assoc_instance_idx].Dest.address_string[k],
+ &instance[assoc_instance_idx].Dest.addrs[k].sin.sin_addr
+ );
else if (instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family == AF_INET6)
- bla = inet_pton( instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family,
- (char *)instance[assoc_instance_idx].Dest.address_string[k],
- &instance[assoc_instance_idx].Dest.addrs[k].sin6.sin6_addr
- );
+ bla = inet_pton( instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family,
+ (char *)instance[assoc_instance_idx].Dest.address_string[k],
+ &instance[assoc_instance_idx].Dest.addrs[k].sin6.sin6_addr
+ );
else
- cout << "Unsupported address family in passive associate\n";
-
+ cout << "Unsupported address family in passive associate\n";
+
}
/* no msg queued, mark assoc down(from sua management viewpoint)*/
instance[assoc_instance_idx].asp.status = asp_down;
-
+
return(assoc_instance_idx);
}
@@ -731,67 +585,67 @@ route_on_IPpc ( ipvxunion& dest_pc,
{
found_assoc = false;
j = 0;
- while ((j < instance[i].Dest.nr_of_addrs) && (!found_assoc))
- {
- found_assoc = (dest_pc.sa.sa_family == instance[i].Dest.addrs[j].sa.sa_family);
- if (dest_pc.sa.sa_family == AF_INET)
- {
- addr_start = 4;
- addr_stop = addr_start + 4;
- }
- else if (dest_pc.sa.sa_family == AF_INET6)
- {
- addr_start = 8;
- addr_stop = addr_start + 16;
- }
- else
- {
- addr_start = 0;
- addr_stop = 0;
- found_assoc = false;
- cout << "ERROR route_on_IPpc: Unknown addresstype\n";
- }
- /* compare the address family field */
- found_assoc = found_assoc && (dest_pc.ch[1] == instance[i].Dest.addrs[j].ch[1]);
-
- /* compare the ipv4/ipv6 address field */
- for (count = addr_start; count < addr_stop; count++)
- {
- found_assoc = found_assoc
- && (dest_pc.ch[count] == instance[i].Dest.addrs[j].ch[count]);
- }
- j++;
- }
-
+ while ((j < instance[i].Dest.nr_of_addrs) && (!found_assoc))
+ {
+ found_assoc = (dest_pc.sa.sa_family == instance[i].Dest.addrs[j].sa.sa_family);
+ if (dest_pc.sa.sa_family == AF_INET)
+ {
+ addr_start = 4;
+ addr_stop = addr_start + 4;
+ }
+ else if (dest_pc.sa.sa_family == AF_INET6)
+ {
+ addr_start = 8;
+ addr_stop = addr_start + 16;
+ }
+ else
+ {
+ addr_start = 0;
+ addr_stop = 0;
+ found_assoc = false;
+ cout << "ERROR route_on_IPpc: Unknown addresstype\n";
+ }
+ /* compare the address family field */
+ found_assoc = found_assoc && (dest_pc.ch[1] == instance[i].Dest.addrs[j].ch[1]);
+
+ /* compare the ipv4/ipv6 address field */
+ for (count = addr_start; count < addr_stop; count++)
+ {
+ found_assoc = found_assoc
+ && (dest_pc.ch[count] == instance[i].Dest.addrs[j].ch[count]);
+ }
+ j++;
+ }
+
if (found_assoc)
- {
- cont = false;
- sctp_assoc_id = instance[i].SCTP_assoc_id;
- sua_assoc_id = i;
+ {
+ cont = false;
+ sctp_assoc_id = instance[i].SCTP_assoc_id;
+ sua_assoc_id = i;
#ifdef DEBUG
- cout << "Found Sua association " << i << " with SCTP assoc " << sctp_assoc_id << "\n";
-
- if (dest_pc.sa.sa_family == AF_INET)
- {
- cout << "CLD ip v4 = " << dest_pc.sin.sin_addr.s_addr << "\n";
- cout << "Remote IP = " << instance[i].Dest.addrs[0].sin.sin_addr.s_addr << "\n";
- }
- else if (dest_pc.sa.sa_family == AF_INET6)
- {
- cout << "CLD ip v6 = " << dest_pc.sin6.sin6_addr.s6_addr << "\n";
- cout << "Remote IP = " << instance[i].Dest.addrs[0].sin6.sin6_addr.s6_addr << "\n";
- }
- else
- cout << "Unknown CLD IP address type format\n";
+ cout << "Found Sua association " << i << " with SCTP assoc " << sctp_assoc_id << "\n";
+
+ if (dest_pc.sa.sa_family == AF_INET)
+ {
+ cout << "CLD ip v4 = " << dest_pc.sin.sin_addr.s_addr << "\n";
+ cout << "Remote IP = " << instance[i].Dest.addrs[0].sin.sin_addr.s_addr << "\n";
+ }
+ else if (dest_pc.sa.sa_family == AF_INET6)
+ {
+ cout << "CLD ip v6 = " << dest_pc.sin6.sin6_addr.s6_addr << "\n";
+ cout << "Remote IP = " << instance[i].Dest.addrs[0].sin6.sin6_addr.s6_addr << "\n";
+ }
+ else
+ cout << "Unknown CLD IP address type format\n";
#endif
- }
+ }
else
- {
- i++;
- cont = (i <= num_of_instance);
- }
+ {
+ i++;
+ cont = (i <= num_of_instance);
+ }
}
-
+
return(sctp_assoc_id);
};
@@ -854,152 +708,381 @@ route_on_SS7pc ( SS7union& dest_pc,
return(sctp_assoc_id);
};
+
/***********************************************************************/
-/* Sua_AssociationList::route_on_GTname */
+/* Sua_AssociationList::increase_instance */
/***********************************************************************/
-signed int db_Sua_AssociationList::
+void db_Sua_AssociationList:: increase_instance(){
+
+ num_of_instance++;
+
+}
+
+
+/***********************************************************************/
+/* Sua_AssociationList::Activate_Association */
+/***********************************************************************/
+bool db_Sua_AssociationList::activate( unsigned int sua_assoc_id,
+ short mode
+ )
+{
+ return(instance[sua_assoc_id].asp.activate(mode,
+ sua_assoc_id
+ ));
+}
+
+/***********************************************************************/
+/* Sua_AssociationList::DeActivate_Association */
+/***********************************************************************/
+void db_Sua_AssociationList::deactivate( unsigned int sua_assoc_id,
+ short mode
+ )
+{
+ instance[sua_assoc_id].asp.deactivate(mode,
+ sua_assoc_id
+ );
+}
+
+/***********************************************************************/
+/* Sua_AssociationList::Down_Association */
+/***********************************************************************/
+void db_Sua_AssociationList::down( unsigned int sua_assoc_id,
+ short mode
+ )
+{
+ instance[sua_assoc_id].asp.down(mode,
+ sua_assoc_id
+ );
+}
+
+/***********************************************************************/
+/* Sua_AssociationList::Up_Association */
+/***********************************************************************/
+void db_Sua_AssociationList::up( unsigned int sua_assoc_id,
+ short mode
+ )
+{
+ instance[sua_assoc_id].asp.up(mode,
+ sua_assoc_id
+ );
+}
+
+/***********************************************************************/
+/* Sua_DatabaseList */
+/***********************************************************************/
+/***********************************************************************/
+/* Sua_DatabaseList::Find_local_sua */
+/***********************************************************************/
+unsigned int db_Sua_DatabaseList::
+Find_local_sua( sccp_addr_str& local_address
+ )
+{
+ pointcode_str dest_pc;
+ short i = 1, j = 0, count, addr_start, addr_stop;
+ unsigned int Local_sua_id = 0;
+ bool result = FALSE;
+
+ while ((i < db_MAX_REMOTE_SUA) && !(result) && (AssocDB.instance[i].Source.nr_of_addrs != 0))
+ {
+ j = 0;
+ while ((j < AssocDB.instance[i].Source.nr_of_addrs) && !(result))
+ {
+ /*result = ((AssocDB.instance[i].Source.addrs[j].sin.sin_addr.s_addr == local_address.pc.ipvx.sin.sin_addr.s_addr) ||
+ (AssocDB.instance[i].Source.addrs[j].sin6.sin6_addr.s6_addr == local_address.pc.ipvx.sin6.sin6_addr.s6_addr));
+ */
+ if (local_address.address_fields_present.pc == ipvx_pc_present)
+ {
+ result = (local_address.pc.ipvx.sa.sa_family == AssocDB.instance[i].Source.addrs[j].sa.sa_family);
+ if (local_address.pc.ipvx.sa.sa_family == AF_INET)
+ {
+ addr_start = 4;
+ addr_stop = addr_start + 4;
+ }
+ else if (local_address.pc.ipvx.sa.sa_family == AF_INET6)
+ {
+ addr_start = 8;
+ addr_stop = addr_start + 16;
+ }
+ else
+ {
+ addr_start = 0;
+ addr_stop = 0;
+ result = false;
+ cout << "ERROR Find_local_sua: Unknown IPvx addresstype\n";
+ }
+ /* compare the address family field */
+ result = result &&
+ (local_address.pc.ipvx.ch[1] == AssocDB.instance[i].Source.addrs[j].ch[1]);
+
+ /* compare the ipv4/ipv6 address field */
+ for (count = addr_start; count < addr_stop; count++)
+ {
+ result = result &&
+ (local_address.pc.ipvx.ch[count] == AssocDB.instance[i].Source.addrs[j].ch[count]);
+ }
+ }
+ else if (local_address.address_fields_present.pc == ss7_pc_present)
+ {
+ result = (local_address.pc.ss7.ITU14.family == AssocDB.instance[i].Source.pc.ITU14.family);
+ if (((local_address.pc.ss7.ITU14.family == ITU14bit) ||
+ (local_address.pc.ss7.ITU14.family == ITU24bit)) ||
+ (local_address.pc.ss7.ITU14.family == ANSI24bit))
+ {
+ /* compare the ITU 14/24bit or ANSI 24bit PC address field */
+ result = result &&
+ (local_address.pc.ss7.ITU14.pc == AssocDB.instance[i].Source.pc.ITU14.pc);
+ }
+ else
+ {
+ result = false;
+ cout << "ERROR Find_local_sua: Unknown SS7 pointcode addresstype\n";
+ }
+ }
+ else if (local_address.address_fields_present.name_gt == hostname_present)
+ {
+ count = 0;
+ result = NameDB.resolve_host_name ( local_address.name.HostName,
+ dest_pc
+ );
+
+ result = (dest_pc.ipvx.sa.sa_family == AssocDB.instance[i].Source.addrs[j].sa.sa_family);
+
+ if (dest_pc.ipvx.sa.sa_family == AF_INET)
+ {
+ addr_start = 4;
+ addr_stop = addr_start + 4;
+ }
+ else if (dest_pc.ipvx.sa.sa_family == AF_INET6)
+ {
+ addr_start = 8;
+ addr_stop = addr_start + 16;
+ }
+ else
+ {
+ addr_start = 0;
+ addr_stop = 0;
+ result = false;
+ cout << "ERROR Find_local_sua: Unknown IPvx addresstype\n";
+ }
+ /* compare the address family field : already done */
+ /* compare the ipv4/ipv6 address field */
+ short k=0;
+ for (count = addr_start; count < addr_stop; count++)
+ {
+ result = result &&
+ (dest_pc.ipvx.ch[count] == AssocDB.instance[i].Source.addrs[j].ch[count]);
+ k++;
+ }
+
+ }
+ else if (local_address.address_fields_present.name_gt == GT_present)
+ {
+ cout << "ERROR Find_local_sua: GT code not implemented yet\n";
+ }
+ else
+ {
+ cout << "ERROR Find_local_sua: Unknown SUA addresstype\n";
+ result = false;
+ }
+
+ if (result)
+ {
+ Local_sua_id = AssocDB.instance[i].local_sua_id;
+#ifdef DEBUG
+ cout << "Find_local_sua: local_sua_id = " << Local_sua_id << " , instance "<< i << "\n";
+#endif
+ }
+ j++;
+ }
+ i++;
+ }
+
+ return(Local_sua_id);
+};
+
+/***********************************************************************/
+/* Sua_DatabaseList::route_on_GTname */
+/***********************************************************************/
+signed int db_Sua_DatabaseList::
route_on_GTname ( hostname_str& dest_name,
- hostname_str& org_name,
- int& sua_assoc_id,
- pointcode_str& dest_pc,
- pointcode_str& org_pc
- )
+ hostname_str& org_name,
+ int& sua_assoc_id,
+ pointcode_str& dest_pc,
+ pointcode_str& org_pc
+ )
{
- int result = 0;
+ int result = 0;
unsigned int sctp_assoc_id = 0;
-
+
sua_assoc_id = 0;
-
- /* resolving can be done via: */
+
+ /* resolving can be done via: */
/* - local global Titel database */
/* - resolve hostname via DNS(simplest for single hop translations) */
- result = resolve_host_name ( dest_name,
- dest_pc
- );
-
- /*result = resolve_host_name ( org_name,
- org_pc
- ); */
-
- sctp_assoc_id = route_on_IPpc( dest_pc.ipvx,
- org_pc.ipvx,
- sua_assoc_id
- );
-
+ result = NameDB.resolve_host_name ( dest_name,
+ dest_pc
+ );
+
+ /*result = resolve_host_name ( org_name,
+ org_pc
+ ); */
+
+ sctp_assoc_id = AssocDB.route_on_IPpc( dest_pc.ipvx,
+ org_pc.ipvx,
+ sua_assoc_id
+ );
+
if (sctp_assoc_id != 0 )
- return(sctp_assoc_id);
-
+ return(sctp_assoc_id);
+
+
+ return(sctp_assoc_id);
+};
+/***********************************************************************/
+/* Sua_DatabaseList::route_on_GTT */
+/***********************************************************************/
+signed int db_Sua_DatabaseList::
+route_on_GTT ( global_title_str& dest_gt,
+ global_title_str& org_gt,
+ int& sua_assoc_id,
+ pointcode_str& dest_pc,
+ pointcode_str& org_pc
+ )
+{
+ int result = 0;
+ unsigned int sctp_assoc_id = 0;
+ global_title_str dest_tr_gt, org_tr_gt;
+
+ sua_assoc_id = 0;
+
+ /* resolving can be done via: */
+ /* - local global Titel database */
+ result = NameDB.perform_GTT ( dest_gt,
+ org_gt,
+ dest_tr_gt,
+ org_tr_gt,
+ dest_pc
+ );
+
+ sctp_assoc_id = AssocDB.route_on_IPpc( dest_pc.ipvx,
+ org_pc.ipvx,
+ sua_assoc_id
+ );
+
+ if (sctp_assoc_id != 0 )
+ return(sctp_assoc_id);
+
+
return(sctp_assoc_id);
};
+
/***********************************************************************/
-/* Sua_AssociationList::route_msg */
+/* Sua_DatabaseList::route_msg */
/***********************************************************************/
-signed int db_Sua_AssociationList::
+signed int db_Sua_DatabaseList::
route_msg( sccp_addr_str& cld,
- sccp_addr_str& clg,
- int& sua_assoc_id
- ){
-
+ sccp_addr_str& clg,
+ int& sua_assoc_id
+ ){
+
unsigned int sctp_assoc_id = 0;
-
+
sua_assoc_id = 0;
-
+
#ifdef DEBUG
- cout << "num_of_instance : "<< num_of_instance << "\n";
+ cout << "num_of_instance : "<< AssocDB.num_of_instance << "\n";
#endif
-
+
if ((cld.address_fields_present.pc == ipvx_pc_present) &&
(cld.routing_ind == route_on_ssn))
{
- sctp_assoc_id = route_on_IPpc( cld.pc.ipvx,
- clg.pc.ipvx,
- sua_assoc_id
- );
+ sctp_assoc_id = AssocDB.route_on_IPpc( cld.pc.ipvx,
+ clg.pc.ipvx,
+ sua_assoc_id
+ );
}
else if ((cld.address_fields_present.name_gt == hostname_present) &&
(cld.routing_ind == route_on_name_gt))
{
sctp_assoc_id = route_on_GTname( cld.name.HostName,
- clg.name.HostName,
+ clg.name.HostName,
sua_assoc_id,
cld.pc,
clg.pc
);
}
+ else if ((cld.address_fields_present.name_gt == GT_present) &&
+ (cld.routing_ind == route_on_name_gt))
+ {
+ sctp_assoc_id = route_on_GTT( cld.name.GT,
+ clg.name.GT,
+ sua_assoc_id,
+ cld.pc,
+ clg.pc
+ );
+ }
else if ((cld.address_fields_present.name_gt == hostname_present) &&
(cld.address_fields_present.pc == ipvx_pc_present) &&
(cld.routing_ind == route_on_name_gt_next_office))
{
- sctp_assoc_id = route_on_IPpc( cld.pc.ipvx,
- clg.pc.ipvx,
- sua_assoc_id
- );
+ sctp_assoc_id = AssocDB.route_on_IPpc( cld.pc.ipvx,
+ clg.pc.ipvx,
+ sua_assoc_id
+ );
}
else if ((cld.address_fields_present.pc == ss7_pc_present) &&
(cld.routing_ind == route_on_ssn))
{
- sctp_assoc_id = route_on_SS7pc( cld.pc.ss7,
- clg.pc.ss7,
- sua_assoc_id
- );
+ sctp_assoc_id = AssocDB.route_on_SS7pc( cld.pc.ss7,
+ clg.pc.ss7,
+ sua_assoc_id
+ );
}
else
{
- cout << "Unknown routing requested\n";
+ cout << "Unknown routing requested\n";
}
-
+
#ifdef SUA_MANAGEMENT
/* check if allowed to send msg over the association */
if ((sua_assoc_id > 0) &&
- (sua_assoc_id <= num_of_instance) &&
- (instance[sua_assoc_id].asp.status != asp_active))
+ (sua_assoc_id <= AssocDB.num_of_instance) &&
+ (AssocDB.instance[sua_assoc_id].asp.status != asp_active))
{
sctp_assoc_id = (-sctp_assoc_id);
}
#endif
-
+
#ifdef DEBUG
cout << "route msg towards remote SUA(& SCTP) association " << sctp_assoc_id << " \n";
#endif
char logstring[100];
sprintf(logstring, "Route msg towards Remote SUA(& SCTP) instance nr %d", sctp_assoc_id );
event_log("sua_database.c",logstring);
-
+
return(sctp_assoc_id);
};
/***********************************************************************/
-/* Sua_AssociationList::increase_instance */
-/***********************************************************************/
-void db_Sua_AssociationList:: increase_instance(){
-
- num_of_instance++;
-
-}
-
+/* Sua_DatabaseList::Dynamic_Associate */
/***********************************************************************/
-/* Sua_AssociationList::Dynamic_Associate */
-/***********************************************************************/
-unsigned int db_Sua_AssociationList::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
- )
+unsigned int db_Sua_DatabaseList::Dynamic_Associate( 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 sua_portnumber = SUA_PORT;
-
+
short i = 1, assoc_instance_idx = 1, assoc_source_idx = 0;
bool partial_assoc_found = FALSE;
-
- while ((i <= num_of_instance) && !(partial_assoc_found)){
- partial_assoc_found = (instance[i].Dest.nr_of_addrs == 0);
- if (partial_assoc_found)
+
+ while ((i <= AssocDB.num_of_instance) && !(partial_assoc_found)){
+ partial_assoc_found = (AssocDB.instance[i].Dest.nr_of_addrs == 0);
+ if (partial_assoc_found)
assoc_instance_idx = i;
i++;
}
@@ -1007,41 +1090,41 @@ unsigned int db_Sua_AssociationList::Dynamic_Associate(
if (!(partial_assoc_found))
{
/* all assoc's are complete, allocate a new one */
- num_of_instance++;
- assoc_instance_idx = num_of_instance;
+ AssocDB.num_of_instance++;
+ assoc_instance_idx = AssocDB.num_of_instance;
}
-
+
assoc_source_idx = Find_local_sua ( clg);
-
+
#ifdef DEBUG
cout << " assoc source idx = " << assoc_source_idx << ", assoc_instance_idx = " << assoc_instance_idx << "\n";
#endif
- instance[assoc_instance_idx].Source = instance[assoc_source_idx].Source;
- instance[assoc_instance_idx].SCTP_instance_name = instance[assoc_source_idx].SCTP_instance_name;
- instance[assoc_instance_idx].local_sua_id = instance[assoc_source_idx].local_sua_id;
- instance[assoc_instance_idx].nr_of_inbound_streams = nr_of_input_streams ;
- instance[assoc_instance_idx].nr_of_outbound_streams = nr_of_input_streams ;
-
- /* conversion and fill in the destination address */
- instance[assoc_instance_idx].Dest.nr_of_addrs = 1;
- instance[assoc_instance_idx].Dest.addrs[0] = cld.pc.ipvx;
-
+ AssocDB.instance[assoc_instance_idx].Source = AssocDB.instance[assoc_source_idx].Source;
+ AssocDB.instance[assoc_instance_idx].SCTP_instance_name = AssocDB.instance[assoc_source_idx].SCTP_instance_name;
+ AssocDB.instance[assoc_instance_idx].local_sua_id = AssocDB.instance[assoc_source_idx].local_sua_id;
+ AssocDB.instance[assoc_instance_idx].nr_of_inbound_streams = nr_of_input_streams ;
+ AssocDB.instance[assoc_instance_idx].nr_of_outbound_streams = nr_of_input_streams ;
+
+ /* conversion and fill in the destination address */
+ AssocDB.instance[assoc_instance_idx].Dest.nr_of_addrs = 1;
+ AssocDB.instance[assoc_instance_idx].Dest.addrs[0] = cld.pc.ipvx;
+
short k;
const char *ptr;
- for(k=0; k < instance[assoc_instance_idx].Dest.nr_of_addrs ; k++)
+ for(k=0; k < AssocDB.instance[assoc_instance_idx].Dest.nr_of_addrs ; k++)
{
- if ( instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family == AF_INET )
- ptr = inet_ntop( instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family,
- &instance[assoc_instance_idx].Dest.addrs[k].sin.sin_addr,
- (char *)instance[assoc_instance_idx].Dest.address_string[k],
+ if ( AssocDB.instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family == AF_INET )
+ ptr = inet_ntop( AssocDB.instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family,
+ &AssocDB.instance[assoc_instance_idx].Dest.addrs[k].sin.sin_addr,
+ (char *)AssocDB.instance[assoc_instance_idx].Dest.address_string[k],
SCTP_MAX_IP_LEN
- );
- else if ( instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family == AF_INET6 )
- ptr = inet_ntop( instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family,
- &instance[assoc_instance_idx].Dest.addrs[k].sin6.sin6_addr,
- (char *)instance[assoc_instance_idx].Dest.address_string[k],
+ );
+ else if ( AssocDB.instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family == AF_INET6 )
+ ptr = inet_ntop( AssocDB.instance[assoc_instance_idx].Dest.addrs[k].sa.sa_family,
+ &AssocDB.instance[assoc_instance_idx].Dest.addrs[k].sin6.sin6_addr,
+ (char *)AssocDB.instance[assoc_instance_idx].Dest.address_string[k],
SCTP_MAX_IP_LEN
);
else
@@ -1049,80 +1132,33 @@ unsigned int db_Sua_AssociationList::Dynamic_Associate(
}
remote_sua.increase_instance();
-
- instance[assoc_instance_idx].SCTP_assoc_id =
- sctp_associate( instance[assoc_instance_idx].SCTP_instance_name,
- instance[assoc_instance_idx].nr_of_outbound_streams,
- instance[assoc_instance_idx].Dest.address_string[0],
+
+ AssocDB.instance[assoc_instance_idx].SCTP_assoc_id =
+ sctp_associate( AssocDB.instance[assoc_instance_idx].SCTP_instance_name,
+ AssocDB.instance[assoc_instance_idx].nr_of_outbound_streams,
+ AssocDB.instance[assoc_instance_idx].Dest.address_string[0],
sua_portnumber,
NULL
);
- instance[assoc_instance_idx].remote_sua_id = remote_sua.num_of_instance;
- remote_sua.instance[remote_sua.num_of_instance].ssn.ssn = local_sua.instance[instance[assoc_instance_idx].local_sua_id].ssn.ssn;
-
+ AssocDB.instance[assoc_instance_idx].remote_sua_id = remote_sua.num_of_instance;
+ remote_sua.instance[remote_sua.num_of_instance].ssn.ssn = local_sua.instance[AssocDB.instance[assoc_instance_idx].local_sua_id].ssn.ssn;
+
/* a message is queued for this association -> send decision is taken */
/* on receiving the communicationUp notification of SCTP AND whether */
/* SUA management is going to be used */
- instance[assoc_instance_idx].asp.status = asp_down_traf_hold;
+ AssocDB.instance[assoc_instance_idx].asp.status = asp_down_traf_hold;
#ifdef DEBUG
- cout << "Dynamic Associate remote SUA(& SCTP) instance nr " << assoc_instance_idx << " with local SUA(& SCTP) instance nr " << instance[assoc_instance_idx].local_sua_id << " \n";
+ cout << "Dynamic Associate remote SUA(& SCTP) instance nr " << assoc_instance_idx << " with local SUA(& SCTP) instance nr " << AssocDB.instance[assoc_instance_idx].local_sua_id << " \n";
#endif
char logstring[100];
- sprintf(logstring, "Dynamic Associate Remote SUA(& SCTP) instance nr %d with local SUA(& SCTP) instance nr %d", assoc_instance_idx, instance[assoc_instance_idx].local_sua_id );
+ sprintf(logstring, "Dynamic Associate Remote SUA(& SCTP) instance nr %d with local SUA(& SCTP) instance nr %d", assoc_instance_idx, AssocDB.instance[assoc_instance_idx].local_sua_id );
event_log("sua_datasoc.c",logstring);
-
+
+
return(assoc_instance_idx);
}
-/***********************************************************************/
-/* Sua_AssociationList::Activate_Association */
-/***********************************************************************/
-bool db_Sua_AssociationList::activate( unsigned int sua_assoc_id,
- short mode
- )
-{
- return(instance[sua_assoc_id].asp.activate(mode,
- sua_assoc_id
- ));
-}
-
-/***********************************************************************/
-/* Sua_AssociationList::DeActivate_Association */
-/***********************************************************************/
-void db_Sua_AssociationList::deactivate( unsigned int sua_assoc_id,
- short mode
- )
-{
- instance[sua_assoc_id].asp.deactivate(mode,
- sua_assoc_id
- );
-}
-
-/***********************************************************************/
-/* Sua_AssociationList::Down_Association */
-/***********************************************************************/
-void db_Sua_AssociationList::down( unsigned int sua_assoc_id,
- short mode
- )
-{
- instance[sua_assoc_id].asp.down(mode,
- sua_assoc_id
- );
-}
-
-/***********************************************************************/
-/* Sua_AssociationList::Up_Association */
-/***********************************************************************/
-void db_Sua_AssociationList::up( unsigned int sua_assoc_id,
- short mode
- )
-{
- instance[sua_assoc_id].asp.up(mode,
- sua_assoc_id
- );
-}
-
// end of module sua_database.c