Entire-Metadata: .entire/metadata/fb87247f-2a75-407e-b336-cbc8c20ba5a6 Entire-Session: fb87247f-2a75-407e-b336-cbc8c20ba5a6 Entire-Strategy: manual-commit
164 lines
4.5 KiB
C
164 lines
4.5 KiB
C
/*
|
|
* (c) Copyright, Real-Time Innovations, 2015-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_interfaces_h
|
|
#define osapi_interfaces_h
|
|
|
|
#include "osapi/osapi_dll.h"
|
|
#include "osapi/osapi_type.h"
|
|
#include "osapi/osapi_socket.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
|
|
#define RTI_OSAPI_IPv4_ADDRESS_LENGTH (4)
|
|
|
|
/** @internal
|
|
* \ingroup RTIOsapiSocketClass
|
|
* \brief The maximum length of the interface name. For windows We store the
|
|
* friendlyName that can have a longer length. A larger value is required.
|
|
* According to the Windows documentation the maximum required length would be
|
|
* IF_MAX_STRING_SIZE + 1
|
|
*/
|
|
#if defined(RTI_WIN32)
|
|
#include <ifdef.h>
|
|
#define RTI_OSAPI_INTERFACE_NAME_LENGTH IF_MAX_STRING_SIZE + 1
|
|
#else
|
|
#define RTI_OSAPI_INTERFACE_NAME_LENGTH 16
|
|
#endif
|
|
|
|
typedef struct {
|
|
unsigned char address[RTI_OSAPI_IPv4_ADDRESS_LENGTH];
|
|
} RTIOsapiIPv4Address_t;
|
|
|
|
#define RTI_OSAPI_IPv4_ADDRESS_LOCALHOST \
|
|
{ \
|
|
{ \
|
|
127, 0, 0, 1 \
|
|
} \
|
|
}
|
|
|
|
|
|
#if defined(RTI_QNX) || (defined(RTI_LINUX) && !defined(RTI_ANDROID)) \
|
|
|| defined(RTI_DARWIN) || defined(RTI_INTIME) || defined(RTI_ANDROID)
|
|
/**
|
|
* In this case we retrieve interface info using the getifaddrs call so we
|
|
* use struct ifaddrs.
|
|
*/
|
|
#define RTI_OSAPI_INTERFACE_USEGETIFADDRS
|
|
#endif
|
|
|
|
/** @internal \ingroup RTIOsapiSocketClass
|
|
* @brief Internal structure for platform-independent interface enumeration.
|
|
*/
|
|
typedef struct RTIOsapiSocket_InterfaceDescription {
|
|
const char *name;
|
|
unsigned int index;
|
|
struct sockaddr *address;
|
|
unsigned int flags;
|
|
#if defined(RTI_WIN32)
|
|
char nameArray[RTI_OSAPI_INTERFACE_NAME_LENGTH];
|
|
#endif
|
|
} RTIOsapiSocket_InterfaceDescription;
|
|
|
|
|
|
#if defined(RTI_WIN32)
|
|
#define RTIOsapiSocket_InterfaceDescription_INITIALIZER \
|
|
{ \
|
|
NULL /* name */, \
|
|
0 /* index */, \
|
|
NULL /* address */, \
|
|
0 /* flags */, \
|
|
"\0" /* nameArray */ \
|
|
}
|
|
#else
|
|
#define RTIOsapiSocket_InterfaceDescription_INITIALIZER \
|
|
{ \
|
|
NULL /* name */, \
|
|
0 /* index */, \
|
|
NULL /* address */, \
|
|
0 /* flags */ \
|
|
}
|
|
#endif /* RTI_WIN32 */
|
|
|
|
/** @internal \ingroup RTIOsapiSocketClass
|
|
* @brief Enumerate local network socket interfaces.
|
|
*
|
|
* Return 1 on success and sets output parameters. Note: allocates memory;
|
|
* should be freed by \ref freeInterfaces
|
|
*/
|
|
extern RTIOsapiDllExport RTI_INT32 RTIOsapiSocket_getInterfaces(
|
|
char **outInterfaceBuffer,
|
|
int *outInterfaceBufferSize,
|
|
struct RTIOsapiSocket_InterfaceDescription **outInterfaceArray,
|
|
int *outInterfaceCount,
|
|
RTIOsapiSocketAFKind kindAF,
|
|
unsigned int requestedInterfacesMask,
|
|
unsigned int reportIgnoreInterfaceWarnings,
|
|
int inSocket);
|
|
|
|
/** @internal \ingroup RTIOsapiSocketClass
|
|
* @brief Free interface data returned from getInterfaces.
|
|
*/
|
|
extern RTIOsapiDllExport void RTIOsapiSocket_freeInterfaces(
|
|
int interfaceBufferSize,
|
|
char *interfaceBuffer,
|
|
int numInterfaces,
|
|
RTIOsapiSocket_InterfaceDescription *interfaceArray);
|
|
|
|
/** @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 allocated all resources.
|
|
*/
|
|
#define RTI_OSAPI_SOCKET_INTERFACE_FLAG_RUNNING (0x20)
|
|
|
|
/** @internal \ingroup RTIOsapiSocketClass
|
|
* \brief Interface is master
|
|
*/
|
|
#define RTI_OSAPI_SOCKET_INTERFACE_FLAG_MASTER (0x40)
|
|
|
|
/** @internal \ingroup RTIOsapiSocketClass
|
|
* \brief Interface is slave
|
|
*/
|
|
#define RTI_OSAPI_SOCKET_INTERFACE_FLAG_SLAVE (0x80)
|
|
|
|
|
|
#ifdef __cplusplus
|
|
} /* extern "C" */
|
|
#endif
|
|
|
|
#endif /* osapi_interfaces_h */
|