Files
torstenandCopilot 342ffd3e5c Update submodule to latest BUILD_RTI fixes
- HandlerMinelayerData: BUILD_RTI Guards für RTI-Abhängigkeiten
- svcTabCommon: Export-Header-Fix via Fallback-Target
- TrainingAreaBase: Stub-Header für BUILD_RTI=OFF
- ddsfts: Include-Pfad und Dependency-Fixes
- BUILD_RTI=OFF Compilation vollständig unterstützt

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Entire-Checkpoint: 01M0JNZA586SACX1PRZ2DJAE5S
2026-08-21 19:30:20 +02:00

229 lines
6.9 KiB
C

/*
* (c) Copyright, Real-Time Innovations, 2006-2024.
* All rights reserved.
*
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*/
#ifndef osapi_socket6_h
#define osapi_socket6_h
#include "osapi/osapi_type.h"
#include "osapi/osapi_dll.h"
#include "osapi/osapi_socket.h"
#include "osapi/osapi_interfaces.h"
#if (defined(RTI_IPV6) \
&& !(defined(RTI_UNIX) || defined(RTI_QNX) || defined(RTI_VXWORKS) \
|| defined(RTI_WINCE) || defined(RTI_WIN32) || defined(RTI_INTIME)))
#error Need to port
#endif
#ifdef __cplusplus
extern "C" {
#endif
/** @internal \file
* \brief Socket
* This module contains methods to manipulate sockets, including methods
* to create, write and read the socket, etc. These methods may be IPv6-
* specific.
*/
#if defined(RTI_UNIX) || defined(RTI_VXWORKS) || defined(RTI_QNX) \
|| defined(RTI_INTIME)
typedef u_int RTIOsapiSocket6MulticastLoopbackFlag;
typedef u_int RTIOsapiSocket6TTL;
#elif defined(RTI_WIN32) || defined(RTI_WINCE)
#define RTIOsapiSocket6MulticastLoopbackFlag BOOL
#define RTIOsapiSocket6TTL int
#elif defined(RTI_IPV6)
#error "Need to port"
#endif
/** @internal \ingroup RTIOsapiSocketClass
* OS independent function to get socket option for IPv6 socket.
*
* @param s Socket
* @param optType Desired action.
* @param optVal Pointer to the desired value corresponding to the
* optType.
* @param optLenPtr Pointer to the integer to return the actual value.
* Don't set the initial value to 0!
*
* @return 0 if successful, -1 if error
*
* @see RTIOsapiSocketOption RTIOsapiSocket6_setOption
*/
extern RTIOsapiDllExport int RTIOsapiSocket6_getOption(
int s,
RTIOsapiSocketOption optType,
char *optVal,
unsigned int *optLenPtr);
/** @internal \ingroup RTIOsapiSocketClass
* OS independent function to set socket option for IPv6 socket.
*
* @param s Socket
* @param optType Desired action.
* @param optVal Pointer to the desired value corresponding to the
* optType.
* @param optLen Length of the optVal in bytes.
*
* @return 0 if successful, -1 if error
*
* @see RTIOsapiSocket6_getOption
*/
extern RTIOsapiDllExport int RTIOsapiSocket6_setOption(
int s,
RTIOsapiSocketOption optType,
const char *optVal,
unsigned int optLen);
#if defined(RTI_SOL210) || (defined(RTI_LINUX26) && !defined(RTI_GCC3))
/*
* Transport priority for IPv6 (TCLASS) only supported on Solaris 10 AND
* Linux 2.6
*/
#define RTI_SOCKET_PRIORITY_IPv6
#endif
#ifdef RTI_IPV6 /* req'd for any functions that take sockaddr_in6 */
/** @internal \ingroup RTIOsapiSocketClass
*
* @brief Assign a port number to an (IPv6) socket.
*
* Bind a port to a socket. Fills in sockAddr. If the passed port
* number is 0, then the system will assign a new port number. If the
* bind succeeds, the bound port number is returned, and is also
* available as ntohs(sockAddr->sin6_port). This is only necessary if the
* socket will receive data.
*/
extern RTIOsapiDllExport unsigned int RTIOsapiSocket6_bind(
int sd,
struct sockaddr_in6 *sockAddr,
unsigned int portnum);
/** @internal \ingroup RTIOsapiSocketClass
*
* @brief Assign a port number to an (IPv6) socket.
*
* Bind a port to a socket. Fills in sockAddr. If the passed port number is
* 0, then the system will assign a new port number. If the bind succeeds, the
* bound port number is returned, and is also available as
* ntohs(sockAddr->sin6_port). This is only necessary if the socket will receive
* data.
*/
extern RTIOsapiDllExport unsigned int RTIOsapiSocket6_bindWithIP(
int sd,
struct sockaddr_in6 *sockAddr,
const struct in6_addr *ip,
unsigned int portnum);
/** @internal \ingroup RTIOsapiSocketClass
*
* @brief Add an IPv6 multicast group.
*
* Adds a socket to a multicast group to receive traffic sent to that
* destination. This is only necessary if the socket will receive data.
*/
extern RTIOsapiDllExport int RTIOsapiSocket_multicastAdd(
int sd,
const struct sockaddr *mcAddr,
int ifIndex);
/** @internal \ingroup RTIOsapiSocketClass
*
* @brief Drop an IPv6 multicast group.
*
* Drops a socket from a multicast group previously added. This is
* implicitly done on closing the socket.
*/
extern RTIOsapiDllExport int RTIOsapiSocket_multicastDrop(
int sd,
const struct sockaddr *mcAddr,
int ifIndex);
/** @internal \ingroup RTIOsapiSocketClass
* \brief Generic buffer to hold data, described by a pointer to the
* data and length of the data. Must be equivalent to NDDS_Transport_Buffer_t
* (and also REDABuffer_t).
*/
typedef struct {
/** @internal @brief Length of the buffer pointed to by pointer. */
RTI_INT32 length;
/** @internal @brief Pre-allocated (by the caller) buffer. */
char *pointer;
} RTIOsapiSocketBuffer_t;
/** @internal \ingroup RTIOsapiSocketClass
* \brief Opaque buffer used to hold scatter/gather information on platforms
* where this is needed.
*/
typedef void *RTIOsapiSocketGatherBuffer_t;
/** @internal \ingroup RTIOsapiSocketClass
*
* @brief Send data to a single socket.
*/
#define RTIOsapiSocket_sendMessage(s, gB, bufs, bufCount, address, addrLen) \
RTIOsapiSocket_sendMessageN(&s, 1, gB, bufs, bufCount, address, addrLen)
/** @internal \ingroup RTIOsapiSocketClass
* @brief Send data to a set of sockets (needed for multicast send).
*/
extern RTIOsapiDllExport int RTIOsapiSocket_sendMessageN(
int *sockets,
size_t socketCount,
RTIOsapiSocketGatherBuffer_t gatherBuffer,
const RTIOsapiSocketBuffer_t *buffers,
size_t bufferCount,
const struct sockaddr *address,
socklen_t addressLen);
#endif /* RTI_IPV6 */
/* Interface enumeration methods */
/** @internal \ingroup RTIOsapiSocketClass
* \brief Interface is running
*/
#define RTI_OSAPI_SOCKET_INTERFACE_FLAG_UP (0x1)
/** @internal \ingroup RTIOsapiSocketClass
* \brief Interface supports broadcast
*/
#define RTI_OSAPI_SOCKET_INTERFACE_FLAG_BROADCAST (0x2)
/** @internal \ingroup RTIOsapiSocketClass
* \brief Interface supports a loopback interface
*/
#define RTI_OSAPI_SOCKET_INTERFACE_FLAG_LOOPBACK (0x4)
/** @internal \ingroup RTIOsapiSocketClass
* \brief Interface is a point-to-point connection.
*/
#define RTI_OSAPI_SOCKET_INTERFACE_FLAG_POINTOPOINT (0x8)
/** @internal \ingroup RTIOsapiSocketClass
* \brief Interface supports multicast.
*/
#define RTI_OSAPI_SOCKET_INTERFACE_FLAG_MULTICAST (0x10)
/** @internal \ingroup RTIOsapiSocketClass
* \brief Interface has all resources allocated.
*/
#define RTI_OSAPI_SOCKET_INTERFACE_FLAG_RUNNING (0x20)
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* osapi_socket6_h */