po_hi_driver_sockets_common.h 1.96 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * 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;


20
#if (defined (__PO_HI_NEED_DRIVER_SOCKETS)  \
julien.delange's avatar
julien.delange committed
21
      || defined (__PO_HI_NEED_DRIVER_SOCKETS_ASN1) \
22
      || defined (__PO_HI_NEED_DRIVER_SOCKETSNEW) \
julien.delange's avatar
julien.delange committed
23
      || defined (__PO_HI_NEED_DRIVER_RTEMS_NE2000_SOCKETS))
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

#define __PO_HI_NOPORT 1
#define __PO_HI_NOADDR ""



typedef struct
{
   int socket;
} __po_hi_inetnode_t;

extern __po_hi_inetport_t node_port[__PO_HI_NB_NODES];
extern __po_hi_inetaddr_t node_addr[__PO_HI_NB_NODES];
extern __po_hi_node_t mynode;

39
40
41
42
43
44
45
46
47
48
49

/* 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
50
   #define __PO_HI_SET_SOCKET_TIMEOUT(mysocket,nsec)
51
52
53
#endif


54
55
56
57
58
59
60
#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)
 */

julien.delange's avatar
julien.delange committed
61
void __po_hi_driver_sockets_common_generic_init (__po_hi_device_id id, void* (*poller) (void));
62
63
64
65
66
67


#endif /* __PO_HI_DRIVER_SOCKETS_COMMON_H__ */
#endif /* __PO_HI_NEED_DRIVER_SOCKETS || __PO_HI_NEED_DRIVER_SOCKETS_ASN1 */