Code portability cleanup.
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / ethernet_adapter / linux / caethernetserver.c
index cd5fcc8..0b248f2 100644 (file)
 * limitations under the License.
 *
 ******************************************************************/
+
+// Defining _POSIX_C_SOURCE macro with 200809L (or greater) as value
+// causes header files to expose definitions
+// corresponding to the POSIX.1-2008 base
+// specification (excluding the XSI extension).
+// For POSIX.1-2008 base specification,
+// Refer http://pubs.opengroup.org/stage7tc1/
+//
+// For this specific file, see use of strndup,
+// Refer http://man7.org/linux/man-pages/man3/strdup.3.html
+#ifndef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 200809L
+#endif
+
+// Defining _BSD_SOURCE or _DEFAULT_SOURCE causes header files to expose
+// definitions that may otherwise be skipped. Skipping can cause implicit
+// declaration warnings and/or bugs and subtle problems in code execution.
+// For glibc information on feature test macros,
+// Refer http://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
+//
+// This file requires #define use due to struct ip_mreq
+#define _DEFAULT_SOURCE
+#define _BSD_SOURCE
+#include <netinet/in.h>
+
 #include "caethernetinterface.h"
 
 #include <sys/types.h>
@@ -25,7 +50,8 @@
 #include <fcntl.h>
 #include <sys/select.h>
 #include <arpa/inet.h>
-#include <netinet/in.h>
+#include <string.h>
+
 #include <errno.h>
 
 #include "pdu.h"