Add osiSockOptMcastLoop_t and osiSockTest
This commit is contained in:
@@ -165,7 +165,7 @@ udpiiu::udpiiu (
|
||||
|
||||
#ifdef IP_ADD_MEMBERSHIP
|
||||
{
|
||||
int flag = 1;
|
||||
osiSockOptMcastLoop_t flag = 1;
|
||||
if ( setsockopt ( this->sock, IPPROTO_IP, IP_MULTICAST_LOOP,
|
||||
(char *) &flag, sizeof ( flag ) ) == -1 ) {
|
||||
char sockErrBuf[64];
|
||||
|
||||
@@ -308,7 +308,7 @@ void rsrv_build_addr_lists(void)
|
||||
}
|
||||
#ifdef IP_ADD_MEMBERSHIP
|
||||
{
|
||||
int flag = 1;
|
||||
osiSockOptMcastLoop_t flag = 1;
|
||||
if (setsockopt(beaconSocket, IPPROTO_IP, IP_MULTICAST_LOOP,
|
||||
(char *)&flag, sizeof(flag))<0) {
|
||||
char sockErrBuf[64];
|
||||
|
||||
@@ -31,6 +31,7 @@ typedef int SOCKET;
|
||||
#define socket_ioctl(A,B,C) ioctl(A,B,C)
|
||||
typedef int osiSockIoctl_t;
|
||||
typedef socklen_t osiSocklen_t;
|
||||
typedef int osiSockOptMcastLoop_t;
|
||||
|
||||
#define FD_IN_FDSET(FD) ((FD)<FD_SETSIZE)
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ typedef int SOCKET;
|
||||
#define socket_ioctl(A,B,C) ioctl(A,B,C)
|
||||
typedef int osiSockIoctl_t;
|
||||
typedef socklen_t osiSocklen_t;
|
||||
typedef int osiSockOptMcastLoop_t;
|
||||
|
||||
#define FD_IN_FDSET(FD) ((FD)<FD_SETSIZE)
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ typedef int SOCKET;
|
||||
#define socket_ioctl(A,B,C) ioctl(A,B,C)
|
||||
typedef int osiSockIoctl_t;
|
||||
typedef socklen_t osiSocklen_t;
|
||||
typedef char osiSockOptMcastLoop_t;
|
||||
|
||||
#define FD_IN_FDSET(FD) ((FD)<FD_SETSIZE)
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#define socket_ioctl(A,B,C) ioctlsocket(A,B,C)
|
||||
typedef u_long FAR osiSockIoctl_t;
|
||||
typedef int osiSocklen_t;
|
||||
typedef BOOL osiSockOptMcastLoop_t;
|
||||
|
||||
#ifndef SHUT_RD
|
||||
# define SHUT_RD SD_RECEIVE
|
||||
|
||||
@@ -34,6 +34,7 @@ typedef int SOCKET;
|
||||
#define socket_ioctl(A,B,C) ioctl(A,B,C)
|
||||
typedef int osiSockIoctl_t;
|
||||
typedef int osiSocklen_t;
|
||||
typedef int osiSockOptMcastLoop_t;
|
||||
#define FD_IN_FDSET(FD) ((FD)<FD_SETSIZE&&(FD)>=0)
|
||||
#ifndef SHUT_RD
|
||||
#define SHUT_RD 0
|
||||
|
||||
@@ -36,6 +36,7 @@ typedef int SOCKET;
|
||||
#define socket_ioctl(A,B,C) ioctl(A,B,C)
|
||||
typedef int osiSockIoctl_t;
|
||||
typedef socklen_t osiSocklen_t;
|
||||
typedef int osiSockOptMcastLoop_t;
|
||||
|
||||
#define FD_IN_FDSET(FD) ((FD)<FD_SETSIZE)
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ typedef int SOCKET;
|
||||
#define socket_ioctl(A,B,C) ioctl(A,B,C)
|
||||
typedef int osiSockIoctl_t;
|
||||
typedef socklen_t osiSocklen_t;
|
||||
typedef int osiSockOptMcastLoop_t;
|
||||
|
||||
#define FD_IN_FDSET(FD) ((FD)<FD_SETSIZE)
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ typedef int osiSockIoctl_t;
|
||||
#else
|
||||
typedef int osiSocklen_t;
|
||||
#endif
|
||||
typedef int osiSockOptMcastLoop_t;
|
||||
|
||||
#define DOES_NOT_ACCEPT_ZERO_LENGTH_UDP
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ typedef int SOCKET;
|
||||
#define socket_ioctl(A,B,C) ioctl(A,B,(int)C)
|
||||
typedef int osiSockIoctl_t;
|
||||
typedef int osiSocklen_t;
|
||||
typedef int osiSockOptMcastLoop_t;
|
||||
|
||||
#define FD_IN_FDSET(FD) ((FD)<FD_SETSIZE&&(FD)>=0)
|
||||
|
||||
|
||||
@@ -210,6 +210,11 @@ ipAddrToAsciiTest_SRCS += ipAddrToAsciiTest.cpp
|
||||
testHarness_SRCS += ipAddrToAsciiTest.cpp
|
||||
TESTS += ipAddrToAsciiTest
|
||||
|
||||
TESTPROD_HOST += osiSockTest
|
||||
osiSockTest_SRCS += osiSockTest.c
|
||||
testHarness_SRCS += osiSockTest.c
|
||||
TESTS += osiSockTest
|
||||
|
||||
# The testHarness runs all the test programs in a known working order.
|
||||
testHarness_SRCS += epicsRunLibComTests.c
|
||||
|
||||
@@ -254,4 +259,3 @@ cvtFastPerform_SRCS += cvtFastPerform.cpp
|
||||
testHarness_SRCS += cvtFastPerform.cpp
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ int epicsInlineTest(void);
|
||||
int ipAddrToAsciiTest(void);
|
||||
int macDefExpandTest(void);
|
||||
int macLibTest(void);
|
||||
int osiSockTest(void);
|
||||
int ringBytesTest(void);
|
||||
int ringPointerTest(void);
|
||||
int taskwdTest(void);
|
||||
@@ -104,6 +105,7 @@ void epicsRunLibComTests(void)
|
||||
runTest(ipAddrToAsciiTest);
|
||||
runTest(macDefExpandTest);
|
||||
runTest(macLibTest);
|
||||
runTest(osiSockTest);
|
||||
runTest(ringBytesTest);
|
||||
runTest(ringPointerTest);
|
||||
runTest(taskwdTest);
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2017 UChicago Argonne LLC, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* EPICS BASE is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "osiSock.h"
|
||||
#include "epicsUnitTest.h"
|
||||
#include "testMain.h"
|
||||
|
||||
void udpSockTest(void)
|
||||
{
|
||||
SOCKET s;
|
||||
int status, one = 1, get = 0;
|
||||
osiSocklen_t len;
|
||||
osiSockOptMcastLoop_t flag = 1;
|
||||
|
||||
s = epicsSocketCreate(AF_INET, SOCK_DGRAM, 0);
|
||||
testOk(s != INVALID_SOCKET, "epicsSocketCreate INET, DGRAM, 0");
|
||||
|
||||
status = setsockopt(s, SOL_SOCKET, SO_BROADCAST, (char *)&one, sizeof(one));
|
||||
testOk(status >= 0, "setsockopt BROADCAST, 1");
|
||||
|
||||
len = sizeof(get);
|
||||
status = getsockopt(s, SOL_SOCKET, SO_BROADCAST, (char *)&get, &len);
|
||||
testOk(status >= 0 && len == sizeof(get) && get == 1,
|
||||
"getsockopt BROADCAST == 1");
|
||||
|
||||
status = setsockopt(s, IPPROTO_IP, IP_MULTICAST_LOOP,
|
||||
(char *)&flag, sizeof(flag));
|
||||
testOk(status >= 0, "setsockopt MULTICAST_LOOP, 1");
|
||||
|
||||
flag = 0;
|
||||
len = sizeof(flag);
|
||||
status = getsockopt(s, IPPROTO_IP, IP_MULTICAST_LOOP, (char *)&flag, &len);
|
||||
testOk(status >= 0 && len == sizeof(flag) && flag == 1,
|
||||
"getsockopt MULTICAST_LOOP == 1");
|
||||
|
||||
epicsSocketDestroy(s);
|
||||
}
|
||||
|
||||
|
||||
MAIN(osiSockTest)
|
||||
{
|
||||
int status;
|
||||
testPlan(6);
|
||||
|
||||
status = osiSockAttach();
|
||||
testOk(status, "osiSockAttach");
|
||||
|
||||
udpSockTest();
|
||||
|
||||
osiSockRelease();
|
||||
return testDone();
|
||||
}
|
||||
Reference in New Issue
Block a user