Commit 09f9be17 authored by julien.delange's avatar julien.delange

* include/drivers/po_hi_driver_sockets.h

   include/drivers/po_hi_driver_sockets_common.h
   src/drivers/po_hi_driver_sockets_common.c
   src/drivers/po_hi_driver_sockets_asn1.c
   src/drivers/po_hi_driver_sockets.c
   src/drivers/configuration/Makefile.am
   - Delete old sockets driver
   - Delete old ASN.1 driver
   - Keep only ne2000 driver for RTEMS
     and generic driver configured using ASN.1 types




git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-c@2047 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent daeb8d8a
......@@ -13,25 +13,50 @@
#if (defined (__PO_HI_NEED_DRIVER_SOCKETS) \
|| defined (__PO_HI_NEED_DRIVER_SOCKETSNEW) \
|| defined (__PO_HI_NEED_DRIVER_RTEMS_NE2000_SOCKETS))
|| defined (__PO_HI_NEED_DRIVER_RTEMS_NE2000_SOCKETS))
#include <po_hi_transport.h>
#include <drivers/po_hi_driver_sockets_common.h>
/* Files from PolyORB-HI-C */
typedef __po_hi_uint16_t __po_hi_inetport_t;
typedef char* __po_hi_inetaddr_t;
#define __PO_HI_NOPORT 1
#define __PO_HI_NOADDR ""
typedef struct
{
int socket;
} __po_hi_inetnode_t;
extern __po_hi_node_t __po_hi_mynode;
void __po_hi_driver_sockets_receiver (void);
#ifdef __PO_HI_NEED_DRIVER_SOCKETS
int __po_hi_driver_sockets_send (__po_hi_entity_t from, __po_hi_entity_t to, __po_hi_msg_t* msg);
/* We only need to set the timeout for the NE2000 driver socket.
* So, this function is used only for this driver.
*/
#ifdef __PO_HI_NEED_DRIVER_RTEMS_NE2000_SOCKETS
#include <sys/time.h>
#define __PO_HI_SET_SOCKET_TIMEOUT(mysocket,nsec) { struct timeval timeout; \
timeout.tv_sec = nsec; \
timeout.tv_usec = 0; \
setsockopt (mysocket, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout,sizeof (timeout)); }
#else
#define __PO_HI_SET_SOCKET_TIMEOUT(mysocket,nsec)
#endif
#ifdef __PO_HI_NEED_DRIVER_SOCKETSNEW
#define __PO_HI_TRANSPORT_SOCKET_NEED_RECEIVER_TASK() \
(node_port[mynode] != __PO_HI_NOPORT)
/*
* Maccro that declare if we need to activate another thread
* that receives data from a socket (receiver task)
*/
void __po_hi_driver_sockets_receiver (void);
int __po_hi_driver_sockets_send (__po_hi_task_id task_id,
__po_hi_port_t port);
#endif
/*
* Send data through the sending socket
*/
......
/*
* This is a part of PolyORB-HI-C distribution, a minimal
* middleware written for generated code from AADL models.
* You should use it with the Ocarina toolsuite.
*
* For more informations, please visit http://ocarina.enst.fr
*
* Copyright (C) 2010, European Space Agency
*/
#ifndef __PO_HI_DRIVER_SOCKETS_COMMON_H__
#define __PO_HI_DRIVER_SOCKETS_COMMON_H__
#include <deployment.h>
typedef __po_hi_uint16_t __po_hi_inetport_t;
typedef char* __po_hi_inetaddr_t;
#if (defined (__PO_HI_NEED_DRIVER_SOCKETS) \
|| defined (__PO_HI_NEED_DRIVER_SOCKETS_ASN1) \
|| defined (__PO_HI_NEED_DRIVER_SOCKETSNEW) \
|| defined (__PO_HI_NEED_DRIVER_RTEMS_NE2000_SOCKETS))
#define __PO_HI_NOPORT 1
#define __PO_HI_NOADDR ""
typedef struct
{
int socket;
} __po_hi_inetnode_t;
extern __po_hi_inetport_t __po_hi_node_port[__PO_HI_NB_NODES];
extern __po_hi_inetaddr_t __po_hi_node_addr[__PO_HI_NB_NODES];
extern __po_hi_node_t __po_hi_mynode;
/* We only need to set the timeout for the NE2000 driver socket.
* So, this function is used only for this driver.
*/
#ifdef __PO_HI_NEED_DRIVER_RTEMS_NE2000_SOCKETS
#include <sys/time.h>
#define __PO_HI_SET_SOCKET_TIMEOUT(mysocket,nsec) { struct timeval timeout; \
timeout.tv_sec = nsec; \
timeout.tv_usec = 0; \
setsockopt (mysocket, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout,sizeof (timeout)); }
#else
#define __PO_HI_SET_SOCKET_TIMEOUT(mysocket,nsec)
#endif
#define __PO_HI_TRANSPORT_SOCKET_NEED_RECEIVER_TASK() \
(node_port[mynode] != __PO_HI_NOPORT)
/*
* Maccro that declare if we need to activate another thread
* that receives data from a socket (receiver task)
*/
void __po_hi_driver_sockets_common_generic_init (__po_hi_device_id id, void* (*poller) (void));
#endif /* __PO_HI_DRIVER_SOCKETS_COMMON_H__ */
#endif /* __PO_HI_NEED_DRIVER_SOCKETS || __PO_HI_NEED_DRIVER_SOCKETS_ASN1 */
......@@ -11,7 +11,9 @@ $(srcdir)/1553.c:
asn1.exe -c -typePrefix __po_hi_c_ 1553.asn
sed -e 's/Mil\_1553\_Conf\_T/mil\_1553\_conf\_t/g' 1553.h > 1553new.h
mv 1553new.h 1553.h
sed -e 's/Mil\_1553\_Conf\_T/mil\_1553\_conf\_t/g' 1553.c > 1553new.c
echo "#if (defined (__PO_HI_NEED_DRIVER_1553_RASTA))\n" > 1553new.c
sed -e 's/Mil\_1553\_Conf\_T/mil\_1553\_conf\_t/g' 1553.c >> 1553new.c
echo "\n#endif" >> 1553new.c
mv 1553new.c 1553.c
mv 1553.h ../../../include/drivers/configuration/
mv asn1crt.h ../../../include/drivers/configuration/
......@@ -20,7 +22,9 @@ $(srcdir)/spacewire.c:
asn1.exe -c -typePrefix __po_hi_c_ spacewire.asn
sed -e 's/Spacewire\_Conf\_T/spacewire\_conf\_t/g' spacewire.h > spacewirenew.h
mv spacewirenew.h spacewire.h
sed -e 's/Spacewire\_Conf\_T/spacewire\_conf\_t/g' spacewire.c > spacewirenew.c
echo "#if (defined (__PO_HI_NEED_DRIVER_SPACEWIRE_RASTA))\n" > spacewirenew.c
sed -e 's/Spacewire\_Conf\_T/spacewire\_conf\_t/g' spacewire.c >> spacewirenew.c
echo "\n#endif" >> spacewirenew.c
mv spacewirenew.c spacewire.c
mv spacewire.h ../../../include/drivers/configuration/
mv asn1crt.h ../../../include/drivers/configuration/
......@@ -30,7 +34,9 @@ $(srcdir)/ip.c:
mv asn1crt.h ../../../include/drivers/configuration/
sed -e 's/IP\_Conf\_T/ip\_conf\_t/g' ip.h > ipnew.h
mv ipnew.h ip.h
sed -e 's/IP\_Conf\_T/ip\_conf\_t/g' ip.c > ipnew.c
echo "#if (defined (__PO_HI_NEED_DRIVER_SOCKETS) || defined (__PO_HI_NEED_DRIVER_RTEMS_NE2000_SOCKETS))\n" > ipnew.c
sed -e 's/IP\_Conf\_T/ip\_conf\_t/g' ip.c >> ipnew.c
echo "\n#endif" >> ipnew.c
mv ipnew.c ip.c
mv ip.h ../../../include/drivers/configuration/
......@@ -38,7 +44,9 @@ $(srcdir)/serial.c:
asn1.exe -c -typePrefix __po_hi_c_ serial.asn
sed -e 's/Serial\_Conf\_T/serial\_conf\_t/g' serial.h > serialnew.h
mv serialnew.h serial.h
sed -e 's/Serial\_Conf\_T/serial\_conf\_t/g' serial.c > serialnew.c
echo "#if (defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX) || defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX_RECEIVER) || defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX_SENDER) || defined (__PO_HI_NEED_DRIVER_SERIAL_RASTA) || defined (__PO_HI_NEED_DRIVER_SERIAL_LEON) || defined (__PO_HI_NEED_DRIVER_SERIAL_LEON_SENDER) || defined (__PO_HI_NEED_DRIVER_SERIAL_LEON_RECEIVER))\n" > serialnew.c
sed -e 's/Serial\_Conf\_T/serial\_conf\_t/g' serial.c >> serialnew.c
echo "\n#endif" >> serialnew.c
mv serialnew.c serial.c
mv serial.h ../../../include/drivers/configuration/
mv asn1crt.h ../../../include/drivers/configuration/
......
......@@ -13,7 +13,6 @@
#include <marshallers.h>
#if (defined (__PO_HI_NEED_DRIVER_SOCKETS) || \
defined (__PO_HI_NEED_DRIVER_SOCKETSNEW) || \
defined (__PO_HI_NEED_DRIVER_RTEMS_NE2000_SOCKETS))
#include <po_hi_config.h>
......@@ -27,7 +26,6 @@
#include <po_hi_task.h>
#include <po_hi_gqueue.h>
#include <drivers/po_hi_driver_sockets.h>
#include <drivers/po_hi_driver_sockets_common.h>
#include <activity.h>
......@@ -68,90 +66,10 @@
* listen socket. This array is used only by the receiver_task
*/
#ifdef __PO_HI_NEED_DRIVER_SOCKETS
__po_hi_inetnode_t nodes[__PO_HI_NB_NODES];
__po_hi_inetnode_t rnodes[__PO_HI_NB_NODES];
#else
__po_hi_inetnode_t nodes[__PO_HI_NB_DEVICES];
__po_hi_inetnode_t rnodes[__PO_HI_NB_DEVICES];
#endif
#ifdef __PO_HI_NEED_DRIVER_SOCKETS
int __po_hi_driver_sockets_send (__po_hi_entity_t from,
__po_hi_entity_t to,
__po_hi_msg_t* msg)
{
__po_hi_node_t node;
int len;
int size_to_write;
int optval = 0;
socklen_t optlen = 0;
node = __po_hi_transport_get_node_from_entity (to);
if (nodes[node].socket == -1 )
{
#ifdef __PO_HI_DEBUG
__DEBUGMSG (" [... failure ...]\n");
#endif
return __PO_HI_ERROR_TRANSPORT_SEND;
}
/*
* After sending the entity identifier, we send the message which
* contains the request.
*/
size_to_write = __PO_HI_MESSAGES_MAX_SIZE;
if (getsockopt (nodes[node].socket, SOL_SOCKET, SO_ERROR, &optval, &optlen) == -1)
{
__DEBUGMSG (" [error getsockopt() in file %s, line%d ]\n", __FILE__, __LINE__);
close (nodes[node].socket);
nodes[node].socket = -1;
return __PO_HI_ERROR_TRANSPORT_SEND;
}
if (optval != 0)
{
__DEBUGMSG (" [error getsockopt() return code in file %s, line%d ]\n", __FILE__, __LINE__);
close (nodes[node].socket);
nodes[node].socket = -1;
return __PO_HI_ERROR_TRANSPORT_SEND;
}
/* Ignore SIGPIPE to be able to recover from errors instead of crashing the node */
if (signal (SIGPIPE, SIG_IGN) == SIG_ERR)
{
__DEBUGMSG (" [error signal() return code in file %s, line%d ]\n", __FILE__, __LINE__);
close (nodes[node].socket);
nodes[node].socket = -1;
return __PO_HI_ERROR_TRANSPORT_SEND;
}
#ifdef __PO_HI_DEBUG
__po_hi_messages_debug (msg);
#endif
len = write (nodes[node].socket, &(msg->content), size_to_write);
if (len != size_to_write)
{
__DEBUGMSG (" [error write() length in file %s, line%d ]\n", __FILE__, __LINE__);
close (nodes[node].socket);
nodes[node].socket = -1;
return __PO_HI_ERROR_TRANSPORT_SEND;
}
__DEBUGMSG (" [SUCCESS]\n");
return __PO_HI_SUCCESS;
}
#endif
#if (defined (__PO_HI_NEED_DRIVER_SOCKETSNEW) || \
defined (__PO_HI_NEED_DRIVER_RTEMS_NE2000_SOCKETS))
__po_hi_device_id socket_device_id;
int __po_hi_driver_sockets_send (__po_hi_task_id task_id,
__po_hi_port_t port)
......@@ -245,11 +163,6 @@ int __po_hi_driver_sockets_send (__po_hi_task_id task_id,
}
#endif
extern __po_hi_device_id socket_device_id;
void* __po_hi_sockets_poller (void)
{
__DEBUGMSG ("Poller launched, device-id=%d\n", socket_device_id);
......@@ -498,77 +411,70 @@ void* __po_hi_sockets_receiver_task (void)
return NULL;
}
#ifdef __PO_HI_NEED_DRIVER_SOCKETSNEW
void __po_hi_driver_sockets_init (__po_hi_device_id id)
{
__po_hi_driver_sockets_common_generic_init (id, __po_hi_sockets_poller);
}
#endif
/*
* The following code implements the old socket layer
* for PolyORB-HI-C and AADLv1.
* Would be considered as deprecated.
*/
#ifdef __PO_HI_NEED_DRIVER_SOCKETS
void __po_hi_driver_sockets_init (__po_hi_device_id id)
{
int i;
int ret;
int reuse;
char *tmp;
__po_hi_uint16_t dev;
__po_hi_time_t mytime;
struct sockaddr_in sa;
struct hostent* hostinfo;
char dev_addr[16];
int node;
memset (dev_addr, '\0', 16);
__po_hi_c_ip_conf_t* ipconf;
char ip_addr[16];
int ip_port;
int node;
socket_device_id = id;
for (node = 0 ; node < __PO_HI_NB_NODES ; node++)
for (node = 0 ; node < __PO_HI_NB_DEVICES ; node++)
{
nodes[node].socket = -1;
}
ipconf = (__po_hi_c_ip_conf_t*)__po_hi_get_device_configuration (id);
ip_port = (int)ipconf->port;
__DEBUGMSG ("My configuration, addr=%s, port=%lld\n", ipconf->address, ipconf->port );
/*
* If the current node port has a port number, then it has to
* listen to other nodes. So, we create a socket, bind it and
* listen to other nodes.
*/
if ( __po_hi_node_port[__po_hi_mynode] != __PO_HI_NOPORT )
if (ip_port != 0)
{
nodes[__po_hi_mynode].socket = socket (AF_INET, SOCK_STREAM, 0);
nodes[id].socket = socket (AF_INET, SOCK_STREAM, 0);
if (nodes[__po_hi_mynode].socket == -1 )
if (nodes[id].socket == -1 )
{
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("Cannot create socket for node %d\n", __po_hi_mynode);
__DEBUGMSG ("Cannot create socket for device %d\n", id);
#endif
return;
}
reuse = 1;
setsockopt (nodes[__po_hi_mynode].socket, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof (reuse));
setsockopt (nodes[id].socket, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof (reuse));
sa.sin_addr.s_addr = htonl (INADDR_ANY); /* We listen on all adresses */
sa.sin_family = AF_INET;
sa.sin_port = htons (__po_hi_node_port[__po_hi_mynode]); /* Port provided by the generated code */
sa.sin_port = htons (ip_port); /* Port provided by the generated code */
if( bind( nodes[__po_hi_mynode].socket , ( struct sockaddr * ) &sa , sizeof( struct sockaddr_in ) ) < 0 )
if( bind( nodes[id].socket , ( struct sockaddr * ) &sa , sizeof( struct sockaddr_in ) ) < 0 )
{
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("Unable to bind socket and port on socket %d\n", nodes[__po_hi_mynode].socket);
__DEBUGMSG ("Unable to bind socket and port on socket %d\n", nodes[id].socket);
#endif
}
if( listen( nodes[__po_hi_mynode].socket , __PO_HI_NB_ENTITIES ) < 0 )
if( listen( nodes[id].socket , __PO_HI_NB_ENTITIES ) < 0 )
{
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("Cannot listen on socket %d\n", nodes[__po_hi_mynode].socket);
__DEBUGMSG ("Cannot listen on socket %d\n", nodes[id].socket);
#endif
}
......@@ -581,98 +487,117 @@ void __po_hi_driver_sockets_init (__po_hi_device_id id)
__po_hi_initialize_add_task ();
__po_hi_create_generic_task
(-1, 0,__PO_HI_MAX_PRIORITY, 0, __po_hi_sockets_receiver_task);
(-1, 0,__PO_HI_MAX_PRIORITY, 0, __po_hi_sockets_poller);
}
/*
* For each node in the sytem that may communicate with the current
* node we create a socket. This socket will be used to send data.
*/
for (node = 0 ; node < __PO_HI_NB_NODES ; node++ )
for (dev = 0 ; dev < __PO_HI_NB_DEVICES ; dev++ )
{
if ( (node != __po_hi_mynode) && (__po_hi_node_port[node] != __PO_HI_NOPORT) && (nodes[node].socket == -1) )
if (dev == id)
{
while (1)
continue;
}
__DEBUGMSG ("[DRIVER SOCKETS] Will initialize connection with device %d\n", dev);
memset (ip_addr, '\0', 16);
ip_port = 0;
ipconf = (__po_hi_c_ip_conf_t*) __po_hi_get_device_configuration (dev);
ip_port = (int)ipconf->port;
__DEBUGMSG ("[DRIVER SOCKETS] Configuration for device %d, addr=%s, port=%d\n", dev, ipconf->address, ip_port);
if (ip_port == 0)
{
__DEBUGMSG ("[DRIVER SOCKETS] Invalid remote port\n");
continue;
}
while (1)
{
nodes[dev].socket = socket (AF_INET, SOCK_STREAM, 0);
if (nodes[dev].socket == -1 )
{
nodes[node].socket = socket (AF_INET, SOCK_STREAM, 0);
__DEBUGMSG ("[DRIVER SOCKETS] Socket for dev %d is not created\n", dev);
return;
}
if (nodes[node].socket == -1 )
{
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("Socket for node %d is not created", node);
#endif
return;
}
__DEBUGMSG ("[DRIVER SOCKETS] Socket for dev %d created, value=%d\n", dev, nodes[dev].socket);
hostinfo = gethostbyname ((char*)__po_hi_node_addr[node]);
hostinfo = gethostbyname ((char*)ipconf->address);
if (hostinfo == NULL )
{
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("Error while getting host informations for node %d\n", node);
#endif
}
if (hostinfo == NULL )
{
__DEBUGMSG ("[DRIVER SOCKETS] Error while getting host informations for device %d\n", dev);
}
sa.sin_port = htons( __po_hi_node_port[node] );
sa.sin_family = AF_INET;
/* The following lines are used to copy the
* hostinfo->h_length to the sa.sin_addr member. Most
* of program use the memcpy to do that, but the
* RT-POSIX profile we use forbid the use of this
* function. We use a loop instead to perform the
* copy. So, these lines replace the code :
*
* memcpy( (char*) &( sa.sin_addr ) , (char*)hostinfo->h_addr , hostinfo->h_length );
*/
tmp = (char*) &(sa.sin_addr);
for (i=0 ; i<hostinfo->h_length ; i++)
{
tmp[i] = hostinfo->h_addr[i];
}
sa.sin_port = htons (ip_port);
sa.sin_family = AF_INET;
/* The following lines are used to copy the
* hostinfo->h_length to the sa.sin_addr member. Most
* of program use the memcpy to do that, but the
* RT-POSIX profile we use forbid the use of this
* function. We use a loop instead to perform the
* copy. So, these lines replace the code :
*
* memcpy( (char*) &( sa.sin_addr ) , (char*)hostinfo->h_addr , hostinfo->h_length );
*/
tmp = (char*) &(sa.sin_addr);
for (i=0 ; i<hostinfo->h_length ; i++)
{
tmp[i] = hostinfo->h_addr[i];
}
/*
* We try to connect on the remote host. We try every
* second to connect on.
*/
/*
* We try to connect on the remote host. We try every
* second to connect on.
__PO_HI_SET_SOCKET_TIMEOUT(nodes[dev].socket,5);
*/
ret = connect
(nodes[node].socket, ( struct sockaddr* ) &sa , sizeof( struct sockaddr_in ));
ret = connect (nodes[dev].socket,
(struct sockaddr*) &sa ,
sizeof (struct sockaddr_in));
if (ret == 0)
{
if (write (nodes[node].socket, &__po_hi_mynode, sizeof (__po_hi_node_t)) != sizeof (__po_hi_node_t))
{
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("Node %d cannot send his node-id\n", node);
#endif
}
break;
}
if (ret == 0)
{
if (close (nodes[node].socket))
__DEBUGMSG ("[DRIVER SOCKETS] Send my id (%d)\n", id);
if (write (nodes[dev].socket, &id, sizeof (__po_hi_device_id)) != sizeof (__po_hi_device_id))
{
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("Cannot close socket %d\n", nodes[node].socket);
#endif
__DEBUGMSG ("[DRIVER SOCKETS] Device %d cannot send his id\n", id);
}
__DEBUGMSG ("[DRIVER SOCKETS] Connection established with device %d, socket=%d\n", dev, nodes[dev].socket);
break;
}
else
{
__DEBUGMSG ("connect() failed, return=%d\n", ret);
}
/*
* We wait 500ms each time we try to connect on the
* remote host
*/
__po_hi_get_time (&mytime);
__po_hi_delay_until (__po_hi_add_times (mytime, __po_hi_milliseconds (500)));
if (close (nodes[dev].socket))
{
__DEBUGMSG ("[DRIVER SOCKETS] Cannot close socket %d\n", nodes[dev].socket);
}
}
}
}
#endif
/*
* We wait 500ms each time we try to connect on the
* remote host
*/
__po_hi_get_time (&mytime);
__DEBUGMSG ("[DRIVER SOCKETS] Cannot connect on device %d, wait 500ms\n", dev);
__po_hi_delay_until (__po_hi_add_times (mytime, __po_hi_milliseconds (500)));
}
}
}
#endif
/*
* This is a part of PolyORB-HI-C distribution, a minimal
* middleware written for generated code from AADL models.
* You should use it with the Ocarina toolsuite.
*
* For more informations, please visit http://ocarina.enst.fr
*
* Copyright (C) 2010, European Space Agency
*/
#include <deployment.h>
#include <marshallers.h>
#ifdef __PO_HI_NEED_DRIVER_SOCKETS_ASN1
#include <po_hi_common.h>
#include <po_hi_config.h>
#include <po_hi_task.h>
#include <po_hi_transport.h>
#include <po_hi_gqueue.h>
#include <po_hi_debug.h>
#include <po_hi_types.h>
#include <po_hi_messages.h>
#include <po_hi_returns.h>
#include <po_hi_main.h>
#include <po_hi_marshallers.h>
#include <po_hi_task.h>
#include <drivers/po_hi_driver_sockets_common.h>
#include <drivers/po_hi_driver_sockets_asn1.h>
#include <asn1_deployment.h>
/* PolyORB-HI-C headers */
#include <activity.h>
/* Generated code headers */
#include <signal.h>
#include <string.h>
#include <unistd.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>
/* POSIX headers */
#include <asn1crt.h>
/* ASN1SCC headers */
/*
* This file contains an implementation of a socket driver
* that send and receive data through POSIX sockets but encode
* data with the ASN1 protocol.
*/
/* The following declarations avoid conflicts
* with current generated code.
*/
#ifndef __PO_HI_NB_NODES
#define __PO_HI_NB_NODES 1
#endif
__po_hi_inetnode_t nodes[__PO_HI_NB_DEVICES];
__po_hi_inetnode_t rnodes[__PO_HI_NB_DEVICES];
extern __po_hi_device_id socket_device_id;
void __po_hi_driver_sockets_asn1_init (__po_hi_device_id id)
{
__po_hi_driver_sockets_common_generic_init (id, __po_hi_sockets_asn1_poller);
}
int __po_hi_driver_sockets_asn1_send (__po_hi_task_id task_id,
__po_hi_port_t port)
{
int len;
int size_to_write;
int optval = 0;
socklen_t optlen = 0;
__po_hi_device_id associated_device;
__po_hi_local_port_t local_port;
__po_hi_request_t* request;
__po_hi_asn1_pkt_t asn1_pkt;
__po_hi_port_t destination_port;
BitStream asn1_bitstream;
int asn1_error_code;
__po_hi_byte_t asn1_buffer[Pkt_REQUIRED_BYTES_FOR_ENCODING];
local_port = __po_hi_get_local_port_from_global_port (port);
request = __po_hi_gqueue_get_most_recent_value (task_id, local_port);
destination_port = __po_hi_gqueue_get_destination (task_id, local_port, 0);
associated_device = __po_hi_get_device_from_port (destination_port);
if (nodes[associated_device].socket == -1 )
{
#ifdef __PO_HI_DEBUG
__DEBUGMSG (" [DRIVER SOCKETS] Invalid socket for port-id %d, device-id %d\n", destination_port, associated_device);
#endif
return __PO_HI_ERROR_TRANSPORT_SEND;
}
/*
* After sending the entity identifier, we send the message which