summaryrefslogtreecommitdiff
path: root/ace
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
parentd0eb18f135f2ecf9318beec97ba99c35a3fc8b3f (diff)
downloadATCD-70b6ff8b3e2d5e5257427e343ea9f055502f4ddb.tar.gz
Adding support for ATM on Linux. (Thanks to Pedro Brandao <pbrandao@inescn.pt>)
Diffstat (limited to 'ace')
-rw-r--r--ace/ATM_Acceptor.cpp166
-rw-r--r--ace/ATM_Acceptor.h8
-rw-r--r--ace/ATM_Acceptor.i13
-rw-r--r--ace/ATM_Addr.cpp277
-rw-r--r--ace/ATM_Addr.h10
-rw-r--r--ace/ATM_Addr.i8
-rw-r--r--ace/ATM_Connector.cpp62
-rw-r--r--ace/ATM_Connector.h27
-rw-r--r--ace/ATM_Connector.i9
-rw-r--r--ace/ATM_Params.h16
-rw-r--r--ace/ATM_QoS.cpp96
-rw-r--r--ace/ATM_QoS.h15
-rw-r--r--ace/ATM_QoS.i6
-rw-r--r--ace/ATM_Stream.cpp78
14 files changed, 508 insertions, 283 deletions
diff --git a/ace/ATM_Acceptor.cpp b/ace/ATM_Acceptor.cpp
index 3cf879f257b..a0542eda94a 100644
--- a/ace/ATM_Acceptor.cpp
+++ b/ace/ATM_Acceptor.cpp
@@ -6,6 +6,10 @@ ACE_RCSID(ace, ATM_Acceptor, "$Id$")
#if defined (ACE_HAS_ATM)
+#if defined (ACE_HAS_LINUX_ATM)
+#include "linux/atmdev.h"
+#endif /* ACE_HAS_LINUX_ATM */
+
#if !defined (__ACE_INLINE__)
#include "ace/ATM_Acceptor.i"
#endif /* __ACE_INLINE__ */
@@ -66,6 +70,20 @@ ACE_ATM_Acceptor::get_local_addr( ACE_ATM_Addr &local_addr )
ACE_UNUSED_ARG( local_addr );
return 0;
+#elif defined (ACE_HAS_LINUX_ATM)
+ ATM_Addr *myaddr = (ATM_Addr *)local_addr.get_addr();
+ int addrlen = sizeof(myaddr->sockaddratmsvc);
+
+ if (ACE_OS::getsockname(acceptor_.get_handle(),
+ (struct sockaddr *) &(myaddr->sockaddratmsvc),
+ &addrlen) < 0) {
+ ACE_DEBUG((LM_DEBUG,
+ ASYS_TEXT("ATM_Acceptor(get_local_addr): ioctl: %d\n"),
+ errno));
+ return -1;
+ }
+
+ return (0);
#else
ACE_UNUSED_ARG( local_addr );
@@ -88,36 +106,25 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap,
params.get_device());
return (handle == ACE_INVALID_HANDLE ? -1 : 0);
#elif defined (ACE_HAS_FORE_ATM_WS2)
- //Unable to use ACE_SOCK_Acceptor.open
- //because of its assumption of using SOCK_STREAM
- //return (ACE_HANDLE)(acceptor_.open (remote_sap, //ACE_Addr
- // protocol_info, //ACE_Protocol_Info
- // 0, //ACE_SOCK_Group
- // 0, //u_long flags
- // params.get_reuse_addr(),
- // params.get_protocol_family(),
- // backlog,
- // params.get_protocol()));
-
struct sockaddr_atm local_atm_addr;
- ACE_HANDLE ret;
- DWORD flags = 0;
+ ACE_HANDLE ret;
+ DWORD flags = 0;
/* Create a local endpoint of communication */
// Only leaves can listen.
flags = ACE_FLAG_MULTIPOINT_C_LEAF | ACE_FLAG_MULTIPOINT_D_LEAF;
-
-
- if ((ret = ACE_OS::socket (AF_ATM,
- SOCK_RAW,
- ATMPROTO_AAL5,
- NULL,
- 0,
- flags ))
- == ACE_INVALID_HANDLE) {
- ACE_OS::printf( "Acceptor(open): socket %d\n", ::WSAGetLastError()),
- ACE_OS::exit (1);
+
+ if ((ret = ACE_OS::socket (AF_ATM,
+ SOCK_RAW,
+ ATMPROTO_AAL5,
+ NULL,
+ 0,
+ flags ))
+ == ACE_INVALID_HANDLE) {
+ ACE_OS::printf( "Acceptor(open): socket %d\n",
+ ::WSAGetLastError());
+ return (ret);
}
((ACE_SOCK_Acceptor *)this) -> set_handle( ret );
@@ -137,7 +144,7 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap,
ACE_reinterpret_cast(struct sockaddr *, &local_atm_addr),
sizeof local_atm_addr) == -1) {
ACE_OS::printf( "Acceptor(open): bind %d\n", ::WSAGetLastError());
- ACE_OS::exit (1);
+ return (ACE_INVALID_HANDLE);
}
/* Make endpoint listen for service requests */
@@ -145,7 +152,78 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap,
backlog)
== -1) {
ACE_OS::printf( "Acceptor(open): listen %d\n", ::WSAGetLastError());
- ACE_OS::exit (1);
+ return (ACE_INVALID_HANDLE);
+ }
+
+ return 0;
+#elif defined (ACE_HAS_LINUX_ATM)
+ //we need to set the qos before binding to the socket
+ //use remote_sap as local_sap
+
+ ACE_ATM_Addr local_sap;
+ ATM_Addr *local_sap_addr = (ATM_Addr*)local_sap.get_addr();
+ ACE_ATM_QoS def_qos;
+ ATM_QoS qos = def_qos.get_qos();
+
+ ACE_HANDLE handle;
+ if ((handle = ACE_OS::socket (params.get_protocol_family(),
+ params.get_type(),
+ params.get_protocol(),
+ params.get_protocol_info(),
+ params.get_sock_group(),
+ params.get_flags()
+ ))
+ == ACE_INVALID_HANDLE) {
+ ACE_DEBUG(LM_DEBUG,
+ ASYS_TEXT("Acceptor(socket): socket %d\n"),
+ errno);
+ return (ACE_INVALID_HANDLE);
+ }
+
+ ((ACE_SOCK_Acceptor *)this) -> set_handle( handle );
+ if (ACE_OS::setsockopt(handle,
+ SOL_ATM,
+ SO_ATMQOS,
+ ACE_reinterpret_cast(char*, &qos),
+ sizeof(qos)) < 0) {
+ ACE_OS::printf("Acceptor(setsockopt): setsockopt:%d\n",
+ errno);
+ }
+
+ struct atmif_sioc req;
+ struct sockaddr_atmsvc aux_addr[1024];
+
+ req.number = 0;
+ req.arg = aux_addr;
+ req.length = sizeof(aux_addr);
+ if (ACE_OS::ioctl(handle,
+ ATM_GETADDR,
+ &req) < 0) {
+ ACE_OS::perror( "Acceptor(setsockopt): ioctl:");
+ }
+ else {
+ local_sap_addr->sockaddratmsvc = aux_addr[0];
+ }
+ local_sap.set_selector(((ACE_ATM_Addr*)&remote_sap)->get_selector());
+
+ if (ACE_OS::bind (handle,
+ ACE_reinterpret_cast(struct sockaddr *,
+ &(local_sap_addr->sockaddratmsvc)),
+ sizeof (local_sap_addr->sockaddratmsvc)
+ ) == -1) {
+ ACE_DEBUG(LM_DEBUG,
+ ASYS_TEXT("Acceptor(open): bind %d\n"),
+ errno);
+ return -1;
+ }
+ // Make endpoint listen for service requests
+ if (ACE_OS::listen (handle,
+ backlog)
+ == -1) {
+ ACE_DEBUG(LM_DEBUG,
+ ASYS_TEXT("Acceptor(listen): listen %d\n"),
+ errno);
+ return -1;
}
return 0;
@@ -153,7 +231,7 @@ ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap,
ACE_UNUSED_ARG (remote_sap);
ACE_UNUSED_ARG (backlog);
ACE_UNUSED_ARG (params);
-#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
@@ -178,11 +256,6 @@ ACE_ATM_Acceptor::accept (ACE_ATM_Stream &new_sap,
params.get_user_data(),
&optbuf));
#elif defined (ACE_HAS_FORE_ATM_WS2)
-// return (acceptor_.accept(new_sap.get_stream(),
-// remote_addr,
-// timeout,
-// restart,
-// reset_new_handle));
ACE_HANDLE n_handle;
ACE_HANDLE s_handle = (( ACE_SOCK_Acceptor *) this ) -> get_handle();
struct sockaddr_atm *cli_addr
@@ -190,17 +263,37 @@ ACE_ATM_Acceptor::accept (ACE_ATM_Stream &new_sap,
int caddr_len = sizeof( struct sockaddr_atm );
do {
- n_handle = ACE_OS::accept( s_handle,
- ACE_reinterpret_cast( struct sockaddr *,
- cli_addr ),
+ n_handle = ACE_OS::accept(s_handle,
+ ACE_reinterpret_cast(struct sockaddr *,
+ cli_addr ),
&caddr_len );
} while ( n_handle == ACE_INVALID_HANDLE && errno == EINTR );
- (( ACE_ATM_Addr *)remote_addr ) -> set( cli_addr,
+ (( ACE_ATM_Addr *)remote_addr ) -> set( cli_addr,
(( ACE_ATM_Addr *)remote_addr ) -> get_selector());
(( ACE_IPC_SAP *)&new_sap ) -> set_handle( n_handle );
return 0;
+#elif defined (ACE_HAS_LINUX_ATM)
+ ACE_UNUSED_ARG (params);
+
+ ACE_HANDLE s_handle = (( ACE_SOCK_Acceptor *) this ) -> get_handle();
+ struct atm_qos accept_qos = qos.get_qos();
+
+ if (ACE_OS::setsockopt(s_handle,
+ SOL_ATM,
+ SO_ATMQOS,
+ ACE_reinterpret_cast(char*,
+ &accept_qos),
+ sizeof(accept_qos)) < 0) {
+ ACE_OS::printf("Acceptor(accept): error setting Qos");
+ }
+
+ return(acceptor_.accept(new_sap.get_stream(),
+ remote_addr,
+ timeout,
+ restart,
+ reset_new_handle));
#else
ACE_UNUSED_ARG(new_sap);
ACE_UNUSED_ARG(remote_addr);
@@ -214,4 +307,3 @@ ACE_ATM_Acceptor::accept (ACE_ATM_Stream &new_sap,
}
#endif /* ACE_HAS_ATM */
-
diff --git a/ace/ATM_Acceptor.h b/ace/ATM_Acceptor.h
index 86206c6b3ef..0c093c40ce5 100644
--- a/ace/ATM_Acceptor.h
+++ b/ace/ATM_Acceptor.h
@@ -29,13 +29,17 @@
#if defined (ACE_HAS_ATM)
-#if defined (ACE_HAS_FORE_ATM_WS2)
+#if defined (ACE_HAS_LINUX_ATM)
+#include "atm.h"
+#endif /* ACE_HAS_LINUX_ATM */
+
+#if defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM)
#include "SOCK_Acceptor.h"
typedef ACE_SOCK_Acceptor ATM_Acceptor;
#elif defined (ACE_HAS_FORE_ATM_XTI)
#include "TLI_Acceptor.h"
typedef ACE_TLI_Acceptor ATM_Acceptor;
-#endif
+#endif // ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM
class ACE_Export ACE_ATM_Acceptor
{
diff --git a/ace/ATM_Acceptor.i b/ace/ATM_Acceptor.i
index 55aa1568d05..f93394b3a14 100644
--- a/ace/ATM_Acceptor.i
+++ b/ace/ATM_Acceptor.i
@@ -8,20 +8,23 @@ ACE_ATM_Acceptor::ACE_ATM_Acceptor (const ACE_Addr &remote_sap,
ACE_ATM_Params params)
{
ACE_TRACE ("ACE_ATM_Acceptor::ACE_ATM_Acceptor");
- open (remote_sap,
- backlog,
- params);
+ if (open (remote_sap,
+ backlog,
+ params) < 0)
+ ACE_ERROR ((LM_ERROR,
+ ASYS_TEXT ("%p\n"),
+ ASYS_TEXT ("ACE_ATM_Acceptor::ACE_ATM_Acceptor")));
}
ACE_INLINE
int
ACE_ATM_Acceptor::close (void)
{
-#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 (acceptor_.close());
#else
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
}
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 */
-// }
-
diff --git a/ace/ATM_Addr.h b/ace/ATM_Addr.h
index 1c24b1088f2..f36d386aed7 100644
--- a/ace/ATM_Addr.h
+++ b/ace/ATM_Addr.h
@@ -29,9 +29,17 @@ typedef ATMSAPAddress ATM_Addr;
#elif defined (ACE_HAS_FORE_ATM_WS2)
#define FORE_NAME_SPACE NS_ALL
typedef struct sockaddr_atm ATM_Addr;
+#elif defined (ACE_HAS_LINUX_ATM)
+#include "atm.h"
+//pbrandao:as Linux has this 2 structs separeted we "link it" here
+typedef struct _linux_atm_addr
+{
+ struct sockaddr_atmsvc sockaddratmsvc;
+ struct atm_sap atmsap;
+} ATM_Addr;
#else
typedef int ATM_Addr;
-#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 */
class ACE_Export ACE_ATM_Addr : public ACE_Addr
{
diff --git a/ace/ATM_Addr.i b/ace/ATM_Addr.i
index 3b133b1a5aa..4b588c8faa7 100644
--- a/ace/ATM_Addr.i
+++ b/ace/ATM_Addr.i
@@ -25,9 +25,11 @@ ACE_ATM_Addr::get_selector (void) const
return atm_addr_.sap.t_atm_sap_addr.address[ATMNSAP_ADDR_LEN - 1];
#elif defined (ACE_HAS_FORE_ATM_WS2)
return atm_addr_.satm_number.Addr[ ATM_ADDR_SIZE - 1 ];
+#elif defined (ACE_HAS_LINUX_ATM)
+ return atm_addr_.sockaddratmsvc.sas_addr.prv[ATM_ESA_LEN - 1];
#else
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 */
}
ACE_INLINE void
@@ -38,8 +40,10 @@ ACE_ATM_Addr::set_selector (unsigned char selector)
atm_addr_.sap.t_atm_sap_addr.address[ATMNSAP_ADDR_LEN - 1] = selector;
#elif defined (ACE_HAS_FORE_ATM_WS2)
atm_addr_.satm_number.Addr[ ATM_ADDR_SIZE - 1 ] = selector;
+#elif defined (ACE_HAS_LINUX_ATM)
+ atm_addr_.sockaddratmsvc.sas_addr.prv[ATM_ESA_LEN - 1] = selector;
#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 */
}
diff --git a/ace/ATM_Connector.cpp b/ace/ATM_Connector.cpp
index 07a5b77b085..23971012d26 100644
--- a/ace/ATM_Connector.cpp
+++ b/ace/ATM_Connector.cpp
@@ -12,9 +12,9 @@ ACE_RCSID(ace, ATM_Connector, "$Id$")
#include "ace/ATM_Connector.i"
#endif /* __ACE_INLINE__ */
- ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Connector)
+ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Connector)
- void
+void
ACE_ATM_Connector::dump (void) const
{
ACE_TRACE ("ACE_ATM_Connector::dump");
@@ -55,15 +55,21 @@ ACE_ATM_Connector::connect (ACE_ATM_Stream &new_stream,
params.get_user_data(),
&options.get_qos());
#elif defined (ACE_HAS_FORE_ATM_WS2)
- ACE_OS::printf( "ATM_Connector(connect): set QoS parameters\n" );
+ ACE_DEBUG(LM_DEBUG,
+ ASYS_TEXT("ATM_Connector(connect): set QoS parameters\n" ));
ACE_HANDLE s = new_stream.get_handle();
struct sockaddr_atm *saddr = ( struct sockaddr_atm *)remote_sap.get_addr();
ACE_QoS cqos = options.get_qos();
- ACE_QoS_Params qos_params = ACE_QoS_Params( 0, 0, &cqos, 0, 0 );
-
- ACE_OS::printf( "ATM_Connector(connect): connecting...\n" );
+ ACE_QoS_Params qos_params = ACE_QoS_Params(0,
+ 0,
+ &cqos,
+ 0,
+ 0);
+
+ ACE_DEBUG(LM_DEBUG,
+ ASYS_TEXT("ATM_Connector(connect): connecting...\n"));
int result = ACE_OS::connect( s,
( struct sockaddr *)saddr,
@@ -75,6 +81,48 @@ ACE_ATM_Connector::connect (ACE_ATM_Stream &new_stream,
::WSAGetLastError());
return result;
+#elif defined (ACE_HAS_LINUX_ATM)
+ ACE_UNUSED_ARG (params);
+ ACE_UNUSED_ARG (timeout);
+ ACE_UNUSED_ARG (reuse_addr);
+ ACE_UNUSED_ARG (perms);
+ ACE_UNUSED_ARG (flags);
+
+ ACE_HANDLE handle = new_stream.get_handle();
+ ATM_QoS qos =options.get_qos();
+ ATM_Addr *local_addr=(ATM_Addr*)local_sap.get_addr(),
+ *remote_addr=(ATM_Addr*)remote_sap.get_addr();
+
+ if (ACE_OS::setsockopt(handle,
+ SOL_ATM,
+ SO_ATMSAP,
+ ACE_reinterpret_cast(char*,
+ &(local_addr->atmsap)),
+ sizeof(local_addr->atmsap)) < 0) {
+ ACE_OS::printf( "ATM_Connector(connect): unable to set atmsap %d\nContinuing...",
+ errno);
+ }
+ if (ACE_OS::setsockopt(handle,
+ SOL_ATM,
+ SO_ATMQOS,
+ ACE_reinterpret_cast(char*,
+ &qos),
+ sizeof(qos)) < 0) {
+ ACE_DEBUG((LM_DEBUG,ASYS_TEXT("ATM_Connector(connect): unable to set qos %d\n"),
+ errno));
+ return -1;
+ }
+
+ int result = ACE_OS::connect(handle,
+ (struct sockaddr *)&(remote_addr->sockaddratmsvc),
+ sizeof( remote_addr->sockaddratmsvc));
+
+ if ( result != 0 )
+ ACE_DEBUG(LM_DEBUG,
+ ASYS_TEXT("ATM_Connector(connect): connection failed, %d\n"),
+ errno);
+
+ return result;
#else
ACE_UNUSED_ARG (new_stream);
ACE_UNUSED_ARG (remote_sap);
@@ -86,7 +134,7 @@ ACE_ATM_Connector::connect (ACE_ATM_Stream &new_stream,
ACE_UNUSED_ARG (flags);
ACE_UNUSED_ARG (perms);
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 */
}
#endif /* ACE_HAS_ATM */
diff --git a/ace/ATM_Connector.h b/ace/ATM_Connector.h
index 7f42588a7ed..b5f31b94325 100644
--- a/ace/ATM_Connector.h
+++ b/ace/ATM_Connector.h
@@ -28,7 +28,7 @@
#if defined (ACE_HAS_ATM)
-#if defined (ACE_WIN32)
+#if defined (ACE_WIN32) || defined (ACE_HAS_LINUX_ATM)
#include "SOCK_Connector.h"
typedef ACE_SOCK_Connector ATM_Connector;
#else
@@ -74,19 +74,20 @@ public:
// the user is letting the OS do the binding. If <reuse_addr> == 1
// then the <local_addr> is reused, even if it hasn't been cleanedup yet.
- connect (ACE_ATM_Stream &new_stream,
- const ACE_ATM_Addr &remote_sap,
- ACE_ATM_Params params = ACE_ATM_Params(),
- ACE_ATM_QoS options = ACE_ATM_QoS(),
- ACE_Time_Value *timeout = 0,
- const ACE_ATM_Addr &local_sap = ACE_ATM_Addr( "", 0 ),
- int reuse_addr = 0,
+ int connect (ACE_ATM_Stream &new_stream,
+ const ACE_ATM_Addr &remote_sap,
+ ACE_ATM_Params params = ACE_ATM_Params(),
+ ACE_ATM_QoS options = ACE_ATM_QoS(),
+ ACE_Time_Value *timeout = 0,
+ const ACE_ATM_Addr &local_sap = ACE_ATM_Addr( "",
+ 0 ),
+ int reuse_addr = 0,
#if defined (ACE_WIN32)
- int flags = 0,
+ int flags = 0,
#else
- int flags = O_RDWR,
+ int flags = O_RDWR,
#endif /* ACE_WIN32 */
- int perms = 0);
+ int perms = 0);
// Actively connect and produce a <new_stream> if things go well.
// The <remote_sap> is the address that we are trying to connect
// with. The <params> are the parameters needed for either socket
@@ -124,6 +125,10 @@ public:
int reset_new_handle (ACE_HANDLE handle);
// Resets any event associations on this handle
+ // = Meta-type info
+ typedef ACE_ATM_Addr PEER_ADDR;
+ typedef ACE_ATM_Stream PEER_STREAM;
+
void dump (void) const;
// Dump the state of an object.
diff --git a/ace/ATM_Connector.i b/ace/ATM_Connector.i
index c4dafa39496..9ac8281cfbf 100644
--- a/ace/ATM_Connector.i
+++ b/ace/ATM_Connector.i
@@ -85,6 +85,15 @@ ACE_ATM_Connector::add_leaf (ACE_ATM_Stream &current_stream,
::WSAGetLastError());
return (result != ACE_INVALID_HANDLE);
+#elif defined (ACE_HAS_LINUX_ATM)
+ ACE_OS::printf("ATM_Connector(add_leaf): not yet implemented in Linux \n");
+
+ ACE_UNUSED_ARG(current_stream);
+ ACE_UNUSED_ARG(remote_sap);
+ ACE_UNUSED_ARG(leaf_id);
+ ACE_UNUSED_ARG(timeout);
+
+ return 0;
#else
ACE_UNUSED_ARG(current_stream);
ACE_UNUSED_ARG(remote_sap);
diff --git a/ace/ATM_Params.h b/ace/ATM_Params.h
index 3f73dd819f7..9c8fb6de383 100644
--- a/ace/ATM_Params.h
+++ b/ace/ATM_Params.h
@@ -36,11 +36,18 @@ typedef struct netbuf Param_Udata;
#define ACE_XTI_ATM_DEVICE ""
typedef int Param_Info;
typedef int Param_Udata;
+#elif defined (ACE_HAS_LINUX_ATM)
+#include "atm.h"
+#define AF_ATM PF_ATMSVC
+#define ACE_XTI_ATM_DEVICE ""
+#define ATM_PROTOCOL_DEFAULT ATM_AAL5
+typedef int Param_Info;
+typedef int Param_Udata;
#else
#define ACE_XTI_ATM_DEVICE ""
typedef int Param_Info;
typedef int Param_Udata;
-#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 */
class ACE_Export ACE_ATM_Params
{
@@ -55,7 +62,12 @@ public:
int oflag = O_RDWR,
int protocol_family = AF_ATM,
int protocol = ATM_PROTOCOL_DEFAULT,
- int type = SOCK_RAW,
+ int type =
+#if defined (ACE_HAS_LINUX_ATM)
+ SOCK_DGRAM,
+#else
+ SOCK_RAW,
+#endif /* ACE_HAS_LINUX_ATM */
ACE_Protocol_Info *protocol_info = 0,
ACE_SOCK_GROUP g = 0,
u_long flags
diff --git a/ace/ATM_QoS.cpp b/ace/ATM_QoS.cpp
index b28e5b7e1d7..2bd5af4eb2d 100644
--- a/ace/ATM_QoS.cpp
+++ b/ace/ATM_QoS.cpp
@@ -12,21 +12,48 @@ ACE_RCSID(ace, ATM_QoS, "$Id$")
#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2)
#define BHLI_MAGIC "FORE_ATM"
- // This is line rate in cells/s for an OC-3 MM interface.
- const long ACE_ATM_QoS::LINE_RATE = 353207;
+// This is line rate in cells/s for an OC-3 MM interface.
+const long ACE_ATM_QoS::LINE_RATE = 353207;
const int ACE_ATM_QoS::OPT_FLAGS_CPID = 0x1;
const int ACE_ATM_QoS::OPT_FLAGS_PMP = 0x2;
const int ACE_ATM_QoS::DEFAULT_SELECTOR = 0x99;
+const int ACE_ATM_QoS::DEFAULT_PKT_SIZE = 8192;
+#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_QoS::LINE_RATE = 353207;
+const int ACE_ATM_QoS::OPT_FLAGS_CPID = 0x1;
+const int ACE_ATM_QoS::OPT_FLAGS_PMP = 0x2;
+const int ACE_ATM_QoS::DEFAULT_SELECTOR = 0x99;
+const int ACE_ATM_QoS::DEFAULT_PKT_SIZE = 8192;
#else
const long ACE_ATM_QoS::LINE_RATE = 0L;
const int ACE_ATM_QoS::OPT_FLAGS_CPID = 0;
const int ACE_ATM_QoS::OPT_FLAGS_PMP = 0;
const int ACE_ATM_QoS::DEFAULT_SELECTOR = 0x0;
-#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */
+const int ACE_ATM_QoS::DEFAULT_PKT_SIZE = 0;
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
ACE_ALLOC_HOOK_DEFINE(ACE_ATM_QoS)
- ACE_ATM_QoS::ACE_ATM_QoS( int rate )
+ACE_ATM_QoS::ACE_ATM_QoS (int pktSize)
+{
+ ACE_TRACE ("ACE_ATM_QoS::ACE_ATM_QoS");
+#if defined (ACE_HAS_LINUX_ATM)
+ ACE_OS::memset(&qos_, 0, sizeof(qos_));
+ qos_.aal = ATM_PROTOCOL_DEFAULT;
+ qos_.rxtp.traffic_class = ATM_ANYCLASS;
+ qos_.rxtp.max_sdu = pktSize;
+ qos_.txtp.traffic_class = ATM_ANYCLASS;
+ qos_.txtp.max_sdu = pktSize;
+#else
+ ACE_UNUSED_ARG (pktSize);
+#endif /* ACE_HAS_LINUX_ATM */
+}
+
+ACE_ATM_QoS::ACE_ATM_QoS(int rate,
+ int pktSize)
{
ACE_TRACE( "ACE_ATM_QoS::ACE_ATM_QoS" );
#if defined (ACE_HAS_FORE_ATM_WS2)
@@ -40,9 +67,9 @@ ACE_ALLOC_HOOK_DEFINE(ACE_ATM_QoS)
// Setting up cbr parameters ...
ie_aalparams.AALType = AALTYPE_5;
ie_aalparams.AALSpecificParameters.AAL5Parameters.ForwardMaxCPCSSDUSize
- = 1516; //8096;
+ = pktSize; // was 1516;
ie_aalparams.AALSpecificParameters.AAL5Parameters.BackwardMaxCPCSSDUSize
- = 1516; //8096;
+ = pktSize; // was 1516;
ie_aalparams.AALSpecificParameters.AAL5Parameters.Mode = AAL5_MODE_MESSAGE;
ie_aalparams.AALSpecificParameters.AAL5Parameters.SSCSType = AAL5_SSCS_NULL;
@@ -87,6 +114,12 @@ ACE_ALLOC_HOOK_DEFINE(ACE_ATM_QoS)
size += sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(ATM_QOS_CLASS_IE);
qos_.ProviderSpecific.buf = (char *) ACE_OS::malloc(size);
+ if (qos_.ProviderSpecific.buf == 0) {
+ ACE_ERROR((LM_ERROR,
+ ASYS_TEXT("ACE_ATM_QoS::ACE_ATM_QoS: Unable to allocate %d bytes for qos_.ProviderSpecific.buf\n"),
+ size));
+ return;
+ }
qos_.ProviderSpecific.len = size;
ACE_OS::memset(qos_.ProviderSpecific.buf, 0, size);
@@ -167,13 +200,34 @@ ACE_ALLOC_HOOK_DEFINE(ACE_ATM_QoS)
qos_.receiving_flowspec( recv_fspec );
#elif defined (ACE_HAS_FORE_ATM_XTI)
ACE_UNUSED_ARG (rate);
+ ACE_UNUSED_ARG (pktSize);
+#elif defined (ACE_HAS_LINUX_ATM)
+ ACE_OS::memset(&qos_,
+ 0,
+ sizeof(qos_));
+ qos_.aal = ATM_PROTOCOL_DEFAULT;
+ qos_.rxtp.max_sdu = pktSize;
+
+ if (rate > 0) {
+ qos_.rxtp.pcr = rate;
+ qos_.rxtp.traffic_class = ATM_CBR;
+ qos_.txtp.traffic_class = ATM_CBR;
+ qos_.txtp.pcr = rate;
+ }
+ else {
+ qos_.rxtp.traffic_class = ATM_UBR;
+ qos_.txtp.traffic_class = ATM_UBR;
+ }
+
+ qos_.txtp.max_sdu = pktSize;
#else
ACE_UNUSED_ARG (rate);
-#endif /* ACE_HAS_FORE_ATM_WS2 */
+#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_FORE_ATM_XTI || ACE_HAS_LINUX_ATM */
}
void
-ACE_ATM_QoS::set_cbr_rate (int rate)
+ACE_ATM_QoS::set_cbr_rate (int rate,
+ int pktSize)
{
ACE_TRACE ("ACE_ATM_QoS::set_cbr_rate");
#if defined (ACE_HAS_FORE_ATM_WS2)
@@ -193,9 +247,9 @@ ACE_ATM_QoS::set_cbr_rate (int rate)
FORE has changed this - we no longer specify QoS this way
ie_aalparams.AALType = AALTYPE_5;
ie_aalparams.AALSpecificParameters.AAL5Parameters.ForwardMaxCPCSSDUSize
- = 1516; //8096;
+ = pktSize; // was 1516;
ie_aalparams.AALSpecificParameters.AAL5Parameters.BackwardMaxCPCSSDUSize
- = 1516; //8096;
+ = pktSize; // was 1516;
ie_aalparams.AALSpecificParameters.AAL5Parameters.Mode = AAL5_MODE_MESSAGE;
ie_aalparams.AALSpecificParameters.AAL5Parameters.SSCSType = AAL5_SSCS_NULL;
@@ -240,6 +294,12 @@ ACE_ATM_QoS::set_cbr_rate (int rate)
size += sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(ATM_QOS_CLASS_IE);
qos_.ProviderSpecific.buf = (char *) ACE_OS::malloc(size);
+ if (qos_.ProviderSpecific.buf == 0) {
+ ACE_ERROR((LM_ERROR,
+ ASYS_TEXT ("ACE_ATM_QoS::ACE_ATM_QoS: Unable to allocate %d bytes for qos_.ProviderSpecific.buf\n"),
+ size));
+ return;
+ }
qos_.ProviderSpecific.len = size;
ACE_OS::memset(qos_.ProviderSpecific.buf, 0, size);
@@ -342,9 +402,17 @@ ACE_ATM_QoS::set_cbr_rate (int rate)
*/
#elif defined (ACE_HAS_FORE_ATM_XTI)
ACE_UNUSED_ARG (rate);
+ ACE_UNUSED_ARG (pktSize);
+#elif defined (ACE_HAS_LINUX_ATM)
+ ACE_UNUSED_ARG (pktSize);
+
+ qos_.rxtp.traffic_class = ATM_CBR;
+ qos_.rxtp.pcr = rate;
+ qos_.txtp.traffic_class = ATM_CBR;
+ qos_.txtp.pcr = rate;
#else
ACE_UNUSED_ARG (rate);
-#endif /* ACE_HAS_FORE_ATM_WS2 */
+#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_FORE_ATM_XTI || ACE_HAS_LINUX_ATM */
}
void
@@ -359,7 +427,7 @@ ACE_ATM_QoS::set_rate (ACE_HANDLE fd,
int flags)
{
ACE_TRACE ("ACE_ATM_QoS::set_rate");
-#if defined (ACE_HAS_FORE_ATM_WS2)
+#if defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM)
set_cbr_rate( rate );
ACE_UNUSED_ARG( fd );
@@ -373,7 +441,7 @@ ACE_ATM_QoS::set_rate (ACE_HANDLE fd,
qos_.len = optlen;
#else
ACE_UNUSED_ARG (rate);
-#endif /* ACE_HAS_FORE_ATM_WS2 */
+#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM || ACE_HAS_FORE_ATM_XTI */
}
char*
@@ -382,7 +450,7 @@ ACE_ATM_QoS::construct_options (ACE_HANDLE fd,
int flags,
long *len)
{
-#if defined (ACE_HAS_FORE_ATM_WS2)
+#if defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM)
ACE_UNUSED_ARG (fd);
ACE_UNUSED_ARG (rate);
ACE_UNUSED_ARG (flags);
diff --git a/ace/ATM_QoS.h b/ace/ATM_QoS.h
index ed3a1eceb1f..95a8831ec46 100644
--- a/ace/ATM_QoS.h
+++ b/ace/ATM_QoS.h
@@ -31,9 +31,13 @@
typedef ACE_QoS ATM_QoS;
#elif defined (ACE_HAS_FORE_ATM_XTI)
typedef struct netbuf ATM_QoS;
+#elif defined (ACE_HAS_LINUX_ATM)
+#include "atm.h"
+#include "ATM_Params.h"
+typedef struct atm_qos ATM_QoS;
#else
typedef int ATM_QoS;
-#endif /* ACE_HAS_FORE_ATM_WS2 */
+#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_FORE_ATM_XTI || ACE_HAS_LINUX_ATM */
class ACE_Export ACE_ATM_QoS
{
@@ -50,12 +54,14 @@ public:
static const int OPT_FLAGS_CPID;
static const int OPT_FLAGS_PMP;
static const int DEFAULT_SELECTOR;
+ static const int DEFAULT_PKT_SIZE;
// = Initializattion and termination methods.
- ACE_ATM_QoS ();
+ ACE_ATM_QoS(int = DEFAULT_PKT_SIZE);
// Default constructor.
- ACE_ATM_QoS( int );
+ ACE_ATM_QoS(int,
+ int = DEFAULT_PKT_SIZE);
// Constructor with a CBR rate.
~ACE_ATM_QoS ();
@@ -65,7 +71,8 @@ public:
int);
// Set the rate.
- void set_cbr_rate (int);
+ void set_cbr_rate (int,
+ int = DEFAULT_PKT_SIZE);
// Set CBR rate in cells per second.
ATM_QoS get_qos (void);
diff --git a/ace/ATM_QoS.i b/ace/ATM_QoS.i
index ae38282fa44..349fb962027 100644
--- a/ace/ATM_QoS.i
+++ b/ace/ATM_QoS.i
@@ -3,12 +3,6 @@
// ATM_QoS.i
ACE_INLINE
-ACE_ATM_QoS::ACE_ATM_QoS ()
-{
- ACE_TRACE ("ACE_ATM_QoS::ACE_ATM_QoS");
-}
-
-ACE_INLINE
ACE_ATM_QoS::~ACE_ATM_QoS ()
{
ACE_TRACE ("ACE_ATM_QoS::~ACE_ATM_QoS");
diff --git a/ace/ATM_Stream.cpp b/ace/ATM_Stream.cpp
index 07f0eaadf8e..fa869ca705a 100644
--- a/ace/ATM_Stream.cpp
+++ b/ace/ATM_Stream.cpp
@@ -69,10 +69,9 @@ ACE_ATM_Stream::get_peer_name (void) const
if (ACE_OS::getpeername(this->get_handle (),
(struct sockaddr *) &name,
- &nameSize) != 0)
- {
- return 0;
- }
+ &nameSize) != 0) {
+ return 0;
+ }
char buffer[256];
for (unsigned int index = 0; index < ATM_ADDR_SIZE - 1; index++ ) {
@@ -108,20 +107,41 @@ ACE_ATM_Stream::get_peer_name (void) const
}
return host_name;
+#elif defined (ACE_HAS_LINUX_ATM)
+ ATM_Addr name;
+ int nameSize = sizeof(name.sockaddratmsvc);
+
+ if (ACE_OS::getpeername(this->get_handle (),
+ (struct sockaddr *) &(name.sockaddratmsvc),
+ &nameSize) < 0) {
+ ACE_OS::perror("ACE_ATM_Stream(get_peer_name): ");
+ return 0;
+ }
+
+ static ACE_TCHAR buffer[MAX_ATM_ADDR_LEN + 1];
+ int total_len;
+ if ((total_len = atm2text(buffer,sizeof buffer,
+ (struct sockaddr *)&(name.sockaddratmsvc),
+ A2T_PRETTY|A2T_NAME)) < 0) {
+ ACE_DEBUG((LM_DEBUG,ASYS_TEXT("ACE_ATM_Stream(get_peer_name):%d"),errno));
+ return 0;
+ }
+
+ return (char*)buffer;
#else
return 0;
-#endif /* ACE_HAS_FORE_ATM_XTI */
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
}
ACE_HANDLE
ACE_ATM_Stream::get_handle (void) const
{
ACE_TRACE ("ACE_ATM_Stream::get_handle");
-#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 stream_.get_handle ();
#else
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 */
}
int
@@ -223,9 +243,51 @@ ACE_ATM_Stream::get_vpi_vci (ACE_UINT16 &vpi,
vci = ( ACE_UINT16 )connID.VCI;
return 0;
+#elif defined (ACE_HAS_LINUX_ATM)
+#if defined (SO_ATMPVC) /* atm version>=0.62 */
+ struct sockaddr_atmpvc mypvcaddr;
+ int addrpvclen = sizeof(mypvcaddr);
+ if (ACE_OS::getsockopt(stream_.get_handle(),
+ SOL_ATM,
+ SO_ATMPVC,
+ ACE_reinterpret_cast(char*,&mypvcaddr),
+ &addrpvclen) < 0) {
+ ACE_DEBUG(LM_DEBUG,
+ ASYS_TEXT("ACE_ATM_Stream::get_vpi_vci: getsockopt %d\n"),
+ errno);
+ return -1;
+ }
+ vpi = (ACE_UINT16)mypvcaddr.sap_addr.vpi;
+ vci = (ACE_UINT16)mypvcaddr.sap_addr.vci;
+
+ return 0;
+#elif defined (SO_VCID) /* patch for atm version 0.59 */
+ struct atm_vcid mypvcid;
+ int pvcidlen = sizeof(mypvcid);
+ if (ACE_OS::getsockopt(stream_.get_handle(),
+ SOL_ATM,SO_VCID,
+ ACE_reinterpret_cast(char*,&mypvcid),
+ &pvcidlen) < 0) {
+ ACE_DEBUG(LM_DEBUG,
+ ASYS_TEXT("ACE_ATM_Stream::get_vpi_vci: getsockopt %d\n"),
+ errno);
+ return -1;
+ }
+ vpi = (ACE_UINT16)mypvcid.vpi;
+ vci = (ACE_UINT16)mypvcid.vci;
+
+ return 0;
+#else
+ ACE_DEBUG(LM_DEBUG,
+ ASYS_TEXT("ACE_ATM_Stream::get_vpi_vci: Not implemented in this ATM version. Update to >= 0.62\n Or patch 0.59"));
+ ACE_UNUSED_ARG (vci);
+ ACE_UNUSED_ARG (vpi);
+
+ return (-1);
+#endif /* SO_ATMPVC || SO_VCID */
#else
return (-1);
-#endif /* ACE_HAS_FORE_ATM_XTI */
+#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
}
#endif /* ACE_HAS_ATM */