rsrv: failed to set mcast ttl 1
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
EPICS Base | Status tracked in 7.0 | |||||
3.16 |
Fix Released
|
Medium
|
mdavidsaver | |||
7.0 |
Fix Released
|
Medium
|
Andrew Johnson |
Bug Description
EPICS V7 added
#ifdef IP_MULTICAST_TTL
{
int ttl;
long val;
val =1;
ttl = val;
if ( setsockopt(
char sockErrBuf[64];
}
}
#endif
to modules/
Unfortunately this is not portable. The type of the IP_MULTICAST_TTL option is 'int' under linux but 'unsigned char' under BSDs (including solarix, OSX, rtems). DWORD under windows (and probably cygwin) and unknown (to me) under iOS. vxWorks is interesting as 5.5 seems to use 'char' and another (older?) version an 'int' (https:/
Supplying the wrong type results in EINVAL (as experienced under RTEMS).
Suggested solutions:
a) Christmas-tree of 'ifdef's
b) try 'int' (at run-time) and if we run into EINVAL then try 'unsigned char'. Limit range to 0..127 (if you want so support vxWorks 5.5 and avoid issues with signed vs. unsigned char).
c) Remove altogether. The OSes I have looked at use '1' as a default anyways.
SIDENOTE: The code also misses passing the 'sockErrBuf' string to the errlogPrintf(). BTW: The same applies (obviously a copy/paste propagation) to the IP_ADD_MEMBERSHIP section just above (udpiiu.cpp).
We have a standard solution for differing setsockopt argument sizes, see the typedefs in libcom/ src/osi/ os/*/osdSock. h and the section above in client/udpiiu.cpp
It might be Okay to re-use osiSockOptMcast Loop_t since it probably has the same size on all targets, but for safety's sake I would probably define a new typedef.