summaryrefslogtreecommitdiff
path: root/ace/ATM_Addr.cpp
diff options
context:
space:
mode:
authorjoeh <joeh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-05-24 14:58:42 +0000
committerjoeh <joeh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-05-24 14:58:42 +0000
commit70b6ff8b3e2d5e5257427e343ea9f055502f4ddb (patch)
treeb119c05b306fc054c054d13a68414805125566b9 /ace/ATM_Addr.cpp
parentd0eb18f135f2ecf9318beec97ba99c35a3fc8b3f (diff)
downloadATCD-70b6ff8b3e2d5e5257427e343ea9f055502f4ddb.tar.gz
Adding support for ATM on Linux. (Thanks to Pedro Brandao <pbrandao@inescn.pt>)
Diffstat (limited to 'ace/ATM_Addr.cpp')
-rw-r--r--ace/ATM_Addr.cpp277
1 files changed, 93 insertions, 184 deletions
diff --git a/ace/ATM_Addr.cpp b/ace/ATM_Addr.cpp
index 6f921ace15e..873245df6e3 100644
--- a/ace/ATM_Addr.cpp
+++ b/ace/ATM_Addr.cpp
@@ -23,21 +23,31 @@ const long ACE_ATM_Addr::LINE_RATE = 353207;
const int ACE_ATM_Addr::OPT_FLAGS_CPID = 0x1;
const int ACE_ATM_Addr::OPT_FLAGS_PMP = 0x2;
const int ACE_ATM_Addr::DEFAULT_SELECTOR = 0x99;
+#elif defined (ACE_HAS_LINUX_ATM)
+//pbrandao:for Linux:
+//pbrandao:for now stick with current definitions
+//pbrandao:see if later need to change
+const long ACE_ATM_Addr::LINE_RATE = 353207;
+const int ACE_ATM_Addr::OPT_FLAGS_CPID = 0;
+const int ACE_ATM_Addr::OPT_FLAGS_PMP = 0;
+const int ACE_ATM_Addr::DEFAULT_SELECTOR = 0x99;
#else
const long ACE_ATM_Addr::LINE_RATE = 0L;
const int ACE_ATM_Addr::OPT_FLAGS_CPID = 0;
const int ACE_ATM_Addr::OPT_FLAGS_PMP = 0;
const int ACE_ATM_Addr::DEFAULT_SELECTOR = 0x0;
-#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
// Default constructor
ACE_ATM_Addr::ACE_ATM_Addr (unsigned char selector)
#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
: ACE_Addr (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ : ACE_Addr (PF_ATMSVC,
#else
: ACE_Addr (AF_UNSPEC,
-#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
sizeof this->atm_addr_)
{
// ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr");
@@ -53,22 +63,32 @@ ACE_ATM_Addr::ACE_ATM_Addr (const ACE_ATM_Addr &sap,
unsigned char selector)
#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
: ACE_Addr (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ : ACE_Addr (PF_ATMSVC,
#else
: ACE_Addr (AF_UNSPEC,
-#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
sizeof this->atm_addr_)
{
ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr");
this->set (sap, selector);
+#if defined (ACE_HAS_LINUX_ATM)
+ this->atm_addr_.sockaddratmsvc.sas_family = PF_ATMSVC;
+ this->atm_addr_.atmsap.blli[0].l3_proto = ATM_L3_NONE;
+ this->atm_addr_.atmsap.blli[0].l2_proto = ATM_L2_NONE;
+ this->atm_addr_.atmsap.bhli.hl_type = ATM_HL_NONE;
+#endif /* ACE_HAS_LINUX_ATM */
}
ACE_ATM_Addr::ACE_ATM_Addr (const ATM_Addr *sap,
unsigned char selector)
#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
: ACE_Addr (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ : ACE_Addr (PF_ATMSVC,
#else
: ACE_Addr (AF_UNSPEC,
-#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
sizeof this->atm_addr_)
{
ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr");
@@ -80,9 +100,11 @@ ACE_ATM_Addr::ACE_ATM_Addr (const ACE_TCHAR sap[],
unsigned char selector)
#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
: ACE_Addr (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ : ACE_Addr (PF_ATMSVC,
#else
: ACE_Addr (AF_UNSPEC,
-#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
sizeof this->atm_addr_)
{
ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr");
@@ -133,9 +155,15 @@ ACE_ATM_Addr::init (unsigned char selector)
//ACE_OS::memcpy (atm_addr_.sap.t_atm_sap_appl.ID.user_defined_ID,
// BHLI_MAGIC,
// sizeof atm_addr_.sap.t_atm_sap_appl.ID);
+#elif defined (ACE_HAS_LINUX_ATM)
+ atm_addr_.sockaddratmsvc.sas_family = AF_ATMSVC;
+ atm_addr_.sockaddratmsvc.sas_addr.prv[ATM_ESA_LEN - 1] = ( char )selector;
+ atm_addr_.atmsap.blli[0].l3_proto = ATM_L3_NONE;
+ atm_addr_.atmsap.blli[0].l2_proto = ATM_L2_NONE;
+ atm_addr_.atmsap.bhli.hl_type = ATM_HL_NONE;
#else
ACE_UNUSED_ARG (selector);
-#endif /* ACE_HAS_FORE_ATM_XTI && ACE_HAS_FORE_ATM_WS2 */
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
}
int
@@ -151,6 +179,8 @@ ACE_ATM_Addr::set (const ACE_ATM_Addr &sap,
#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
ACE_ASSERT (sap.get_type () == AF_ATM);
+#elif defined (ACE_HAS_LINUX_ATM)
+ ACE_ASSERT (sap.get_type () == PF_ATMSVC);
#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
(void) ACE_OS::memcpy ((void *) &this->atm_addr_,
@@ -169,6 +199,8 @@ ACE_ATM_Addr::set (const ATM_Addr *sap,
#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
this->ACE_Addr::base_set (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ this->ACE_Addr::base_set (PF_ATMSVC,
#else
this->ACE_Addr::base_set (AF_UNSPEC,
#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
@@ -208,9 +240,11 @@ ACE_ATM_Addr::string_to_addr (const ACE_TCHAR sap[])
#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
this->ACE_Addr::base_set (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ this->ACE_Addr::base_set (PF_ATMSVC,
#else
this->ACE_Addr::base_set (AF_UNSPEC,
-#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
sizeof this->atm_addr_);
#if defined (ACE_HAS_FORE_ATM_XTI)
struct hostent *entry;
@@ -291,13 +325,28 @@ ACE_ATM_Addr::string_to_addr (const ACE_TCHAR sap[])
errno = EINVAL;
return -1;
}
+#elif defined (ACE_HAS_LINUX_ATM)
+ if (sap == 0 || !ACE_OS::strcmp(sap,"")) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if ( text2atm((ACE_TCHAR *)sap,
+ (struct sockaddr *)&(atm_addr_.sockaddratmsvc),
+ sizeof(atm_addr_.sockaddratmsvc),
+ T2A_SVC | T2A_NAME) < 0 ) {
+ ACE_DEBUG(LM_DEBUG,
+ "Error : text2atm failed!\n");
+ errno = EINVAL;
+ return -1;
+ }
#else
ACE_UNUSED_ARG (sap);
return 0;
-#endif /* ACE_HAS_FORE_ATM_XTI && ACE_HAS_FORE_ATM_WS2 */
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
-#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
+#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM)
return 0;
#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
}
@@ -320,8 +369,7 @@ ACE_ATM_Addr::addr_to_string (ACE_TCHAR addr[],
ACE_TEXT ("%s"),
atmnsap_ntoa (nsap));
- size_t total_len = ACE_OS::strlen (buffer)
- + sizeof ('\0'); // For trailing '\0'.
+ size_t total_len = ACE_OS::strlen (buffer) + sizeof ('\0');
if (addrlen < total_len)
return -1;
@@ -347,6 +395,23 @@ ACE_ATM_Addr::addr_to_string (ACE_TCHAR addr[],
ACE_OS::strcpy( addr, buffer );
return 0;
+#elif defined (ACE_HAS_LINUX_ATM)
+ ACE_TCHAR buffer[MAX_ATM_ADDR_LEN + 1];
+ int total_len;
+ if ((total_len = atm2text(buffer,
+ sizeof buffer,
+ (struct sockaddr *)&(atm_addr_.sockaddratmsvc),
+ A2T_PRETTY)) < 0) {
+ ACE_DEBUG((LM_DEBUG,"ACE_ATM_Addr(addr_to_string): atm2text failed\n"));
+ return -1;
+ }
+ if (addrlen < (size_t)total_len)
+ return -1;
+ else
+ ACE_OS::strcpy(addr,
+ buffer);
+
+ return 0;
#else
ACE_UNUSED_ARG (addr);
ACE_UNUSED_ARG (addrlen);
@@ -360,8 +425,10 @@ ACE_ATM_Addr::addr_to_string (void) const
ACE_TRACE ("ACE_ATM_Addr::addr_to_string");
static ACE_TCHAR addr[MAXHOSTNAMELEN + 1];
- this->addr_to_string (addr,
- MAXHOSTNAMELEN + 1);
+ if (this->addr_to_string (addr,
+ MAXHOSTNAMELEN + 1) < 0)
+ return 0;
+
return addr;
}
@@ -373,6 +440,8 @@ ACE_ATM_Addr::set_addr (void *addr, int len)
#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
this->ACE_Addr::base_set (AF_ATM,
+#elif defined (ACE_HAS_LINUX_ATM)
+ this->ACE_Addr::base_set (PF_ATMSVC,
#else
this->ACE_Addr::base_set (AF_UNSPEC,
#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_WS2 */
@@ -397,9 +466,20 @@ ACE_ATM_Addr::operator == (const ACE_ATM_Addr &sap) const
{
ACE_TRACE ("ACE_ATM_Addr::operator ==");
+#if defined (ACE_HAS_LINUX_ATM)
+ return (atm_equal((const struct sockaddr *)&(this->atm_addr_.sockaddratmsvc),
+ (const struct sockaddr *)&(sap.atm_addr_.sockaddratmsvc),
+ 0,
+ 0)
+ &&
+ sap_equal(&(this->atm_addr_.atmsap),
+ &(sap.atm_addr_.atmsap),
+ 0));
+#else
return ACE_OS::memcmp (&atm_addr_,
&sap.atm_addr_,
sizeof (ATM_Addr)) == 0;
+#endif /* ACE_HAS_LINUX_ATM */
}
void
@@ -416,174 +496,3 @@ ACE_ATM_Addr::dump (void) const
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s"), s));
ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
}
-
-// char *
-// ACE_ATM_Addr::construct_options(ACE_HANDLE fd,
-// int qos_kb,
-// int flags,
-// long *optsize)
-// {
-// #if defined (ACE_HAS_FORE_ATM_XTI)
-// struct t_opthdr *popt;
-// char *buf;
-// int qos_cells;
-// struct t_info info;
-
-// if (ACE_OS::t_getinfo (fd, &info) == -1)
-// {
-// ACE_OS::t_error ("t_getinfo");
-// return 0;
-// }
-
-// buf = (char *) ACE_OS::malloc (info.options);
-
-// if (buf == 0)
-// ACE_ERROR_RETURN ((LM_ERROR,
-// ACE_TEXT ("Unable to allocate %d bytes for options\n"),
-// info.options),
-// 0);
-
-// popt = (struct t_opthdr *) buf;
-
-// if (flags & OPT_FLAGS_CPID)
-// {
-// // This constructs the T_ATM_ORIG_ADDR option, which is used to
-// // signal the UNI 3.1 Calling Party ID Information Element.
-// t_atm_addr *source_addr;
-
-// popt->len = sizeof (struct t_opthdr) + sizeof (t_atm_addr);
-// popt->level = T_ATM_SIGNALING;
-// popt->name = T_ATM_ORIG_ADDR;
-// popt->status = 0;
-
-// source_addr =
-// (t_atm_addr *)((char *) popt + sizeof (struct t_opthdr));
-
-// source_addr->address_format = T_ATM_ENDSYS_ADDR;
-// source_addr->address_length = ATMNSAP_ADDR_LEN;
-
-// ACE_OS::memcpy(source_addr->address,
-// atm_addr_.sap.t_atm_sap_addr.address,
-// 20);
-// //if (get_local_address (fd, source_addr->address))
-// // {
-// // ACE_ERROR ((LM_ERROR,
-// // ACE_TEXT ("Can't get local address!\n")));
-// // ACE_OS::free (buf);
-// // return 0;
-// // }
-
-// popt = T_OPT_NEXTHDR (buf, info.options , popt);
-// }
-
-// // This constructs all options necessary (bearer cap., QoS, and
-// // Traffic Descriptor) to signal for a CBR connection with the
-// // specified QoS in kbit/sec., and/or specify a PMP connection.
-
-// // For FORE 200e cards, the adapter shapes traffic to CBR with rate
-// // equal to PCR CLP=0+1 (traffic.forward.PCR_all_traffic)
-
-// qos_cells = (qos_kb * 1000) / (48*8);
-
-// if ((qos_cells > 0 && qos_cells < LINE_RATE)
-// || (ACE_BIT_ENABLED (flags, OPT_FLAGS_PMP)))
-// {
-// struct t_atm_bearer *bearer;
-// struct t_atm_traffic *traffic;
-
-// // T_ATM_BEARER_CAP: Broadband bearer capability
-// popt->len = sizeof (struct t_opthdr) + sizeof (struct t_atm_bearer);
-// popt->level = T_ATM_SIGNALING;
-// popt->name = T_ATM_BEARER_CAP;
-// popt->status = 0;
-
-// bearer = (struct t_atm_bearer *)((char *) popt + sizeof (struct t_opthdr));
-// bearer->bearer_class = T_ATM_CLASS_X;
-
-// if (qos_cells)
-// {
-// bearer->traffic_type = T_ATM_CBR;
-// bearer->timing_requirements = T_ATM_END_TO_END;
-// }
-// else
-// {
-// bearer->traffic_type = 0; // UBR
-// bearer->timing_requirements = 0;
-// }
-// bearer->clipping_susceptibility = T_ATM_NULL;
-
-// if (ACE_BIT_ENABLED (flags, OPT_FLAGS_PMP))
-// bearer->connection_configuration = T_ATM_1_TO_MANY;
-// else
-// bearer->connection_configuration = T_ATM_1_TO_1;
-
-// popt = T_OPT_NEXTHDR (buf, info.options, popt);
-
-// // T_ATM_TRAFFIC: traffic descriptor
-// popt->len = sizeof (struct t_opthdr) + sizeof (struct t_atm_traffic);
-// popt->level = T_ATM_SIGNALING;
-// popt->name = T_ATM_TRAFFIC;
-// popt->status = 0;
-
-// traffic = (struct t_atm_traffic *)((char *) popt + sizeof (struct t_opthdr));
-
-// traffic->forward.PCR_high_priority = T_ATM_ABSENT;
-// traffic->forward.PCR_all_traffic = qos_cells ? qos_cells : LINE_RATE;
-// traffic->forward.SCR_high_priority = T_ATM_ABSENT;
-// traffic->forward.SCR_all_traffic = T_ATM_ABSENT;
-// traffic->forward.MBS_high_priority = T_ATM_ABSENT;
-// traffic->forward.MBS_all_traffic = T_ATM_ABSENT;
-// traffic->forward.tagging = T_NO;
-
-// traffic->backward.PCR_high_priority = T_ATM_ABSENT;
-// traffic->backward.PCR_all_traffic =
-// (ACE_BIT_ENABLED (flags, OPT_FLAGS_PMP))
-// ? 0 : qos_cells ? qos_cells : LINE_RATE;
-// traffic->backward.SCR_high_priority = T_ATM_ABSENT;
-// traffic->backward.SCR_all_traffic = T_ATM_ABSENT;
-// traffic->backward.MBS_high_priority = T_ATM_ABSENT;
-// traffic->backward.MBS_all_traffic = T_ATM_ABSENT;
-// traffic->backward.tagging = T_NO;
-
-// traffic->best_effort = qos_cells ? T_NO : T_YES;
-
-// popt = T_OPT_NEXTHDR (buf,
-// info.options,
-// popt);
-// }
-
-// if (qos_cells > 0 && qos_cells < LINE_RATE)
-// {
-// struct t_atm_qos *qos;
-
-// // T_ATM_QOS: Quality of Service
-// popt->len = sizeof (struct t_opthdr) + sizeof (struct t_atm_qos);
-// popt->level = T_ATM_SIGNALING;
-// popt->name = T_ATM_QOS;
-// popt->status = 0;
-
-// qos = (struct t_atm_qos *)((char *) popt + sizeof (struct t_opthdr));
-// qos->coding_standard = T_ATM_ITU_CODING;
-// qos->forward.qos_class = T_ATM_QOS_CLASS_1;
-// qos->backward.qos_class = T_ATM_QOS_CLASS_1;
-
-// popt = T_OPT_NEXTHDR (buf, info.options, popt);
-// }
-
-// // return actual size of options and option buffer to user
-// *optsize = (char *) popt - buf;
-
-// return buf;
-// #elif defined (ACE_HAS_FORE_ATM_WS2)
-// // WinSock Part
-// // Unlike XTI, WinSock does QoS with a QoS class passed into
-// // connect call, so it may be better to do this in XXX_Connector
-// #else
-// ACE_UNUSED_ARG (fd);
-// ACE_UNUSED_ARG (qos_kb);
-// ACE_UNUSED_ARG (flags);
-// ACE_UNUSED_ARG (optsize);
-// return 0;
-// #endif /* ACE_HAS_FORE_ATM_XTI && ACE_HAS_FORE_ATM_WS2 */
-// }
-