po_hi_driver_sockets.h 1.97 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
 * 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.
 *
 * Copyright (C) 2010, European Space Agency
 */

#include <deployment.h>

#ifndef __PO_HI_DRIVER_SOCKETS_H__
#define __PO_HI_DRIVER_SOCKETS_H__

14 15

#if (defined (__PO_HI_NEED_DRIVER_SOCKETS)  \
16
  || defined (__PO_HI_NEED_DRIVER_RTEMS_NE2000_SOCKETS))
17 18 19

#include <po_hi_transport.h>

20 21
typedef __po_hi_uint16_t __po_hi_inetport_t;
typedef char*            __po_hi_inetaddr_t;
22

23 24 25 26 27 28 29 30 31
#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;
32 33


34 35 36 37 38 39 40 41 42 43 44
/* 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)
45 46
#endif

47 48 49 50 51 52 53 54 55 56 57

#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);

58 59
int __po_hi_driver_sockets_send (__po_hi_task_id task_id,
                                 __po_hi_port_t port);
60 61 62 63 64 65 66 67 68 69
/*
 * Send data through the sending socket
 */

void* __po_hi_sockets_receiver_task (void);
/*
 * Task that polls for incoming data 
 * and dispatch it in po-hi-c queues
 */

70
void* __po_hi_sockets_poller (void);
julien.delange's avatar
julien.delange committed
71 72 73
/*
 * Generic poller for PO-HI-C protocol.
 */
74

julien.delange's avatar
julien.delange committed
75
void __po_hi_driver_sockets_init (__po_hi_device_id id);
76 77 78 79
#endif

#endif