Mark all our (new) differences.
* - Using the winsock functions has not been tested.
*/
* - Using the winsock functions has not been tested.
*/
#include "iphlpapi_private.h"
#include "iphlpapi_private.h"
+#else // ! __REACTOS__
+#include "config.h"
+#include "wine/port.h"
+
+#include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#ifdef HAVE_NETDB_H
+# include <netdb.h>
+#endif
+#ifdef HAVE_NETINET_IN_SYSTM_H
+# include <netinet/in_systm.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#include <stdarg.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include <fcntl.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
+# include <arpa/inet.h>
+#endif
+#ifdef HAVE_SYS_POLL_H
+# include <sys/poll.h>
+#endif
+#ifdef HAVE_SYS_WAIT_H
+# include <sys/wait.h>
+#endif
+
+#define USE_WS_PREFIX
+
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+#include "winternl.h"
+#include "ipexport.h"
+#include "icmpapi.h"
+#include "wine/debug.h"
+#endif // ! __REACTOS__
/* Set up endianness macros for the ip and ip_icmp BSD headers */
#ifndef BIG_ENDIAN
/* Set up endianness macros for the ip and ip_icmp BSD headers */
#ifndef BIG_ENDIAN
HANDLE WINAPI Icmp6CreateFile(VOID)
{
icmp_t* icp;
HANDLE WINAPI Icmp6CreateFile(VOID)
{
icmp_t* icp;
WSADATA wsaData;
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != ERROR_SUCCESS)
WSADATA wsaData;
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != ERROR_SUCCESS)
ERR_(winediag)("Failed to use ICMPV6 (network ping), this requires special permissions.\n");
return INVALID_HANDLE_VALUE;
}
ERR_(winediag)("Failed to use ICMPV6 (network ping), this requires special permissions.\n");
return INVALID_HANDLE_VALUE;
}
sid=socket(AF_INET6,SOCK_RAW,IPPROTO_ICMPV6);
sid=socket(AF_INET6,SOCK_RAW,IPPROTO_ICMPV6);
+#else
+
+ int sid=socket(AF_INET6,SOCK_RAW,IPPROTO_ICMPV6);
if (sid < 0)
{
/* Mac OS X supports non-privileged ICMP via SOCK_DGRAM type. */
if (sid < 0)
{
/* Mac OS X supports non-privileged ICMP via SOCK_DGRAM type. */
static int once;
#endif
icmp_t* icp;
static int once;
#endif
icmp_t* icp;
WSADATA wsaData;
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != ERROR_SUCCESS)
WSADATA wsaData;
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != ERROR_SUCCESS)
ERR_(winediag)("Failed to use ICMPV6 (network ping), this requires special permissions.\n");
return INVALID_HANDLE_VALUE;
}
ERR_(winediag)("Failed to use ICMPV6 (network ping), this requires special permissions.\n");
return INVALID_HANDLE_VALUE;
}
sid=socket(AF_INET,SOCK_RAW,IPPROTO_ICMP);
sid=socket(AF_INET,SOCK_RAW,IPPROTO_ICMP);
if (sid < 0) {
ERR_(winediag)("Failed to use ICMP (network ping), this requires special permissions.\n");
SetLastError(ERROR_ACCESS_DENIED);
return INVALID_HANDLE_VALUE;
}
#else
if (sid < 0) {
ERR_(winediag)("Failed to use ICMP (network ping), this requires special permissions.\n");
SetLastError(ERROR_ACCESS_DENIED);
return INVALID_HANDLE_VALUE;
}
#else
+
+ int sid=socket(AF_INET,SOCK_RAW,IPPROTO_ICMP);
if (sid < 0)
{
/* Mac OS X supports non-privileged ICMP via SOCK_DGRAM type. */
if (sid < 0)
{
/* Mac OS X supports non-privileged ICMP via SOCK_DGRAM type. */
BOOL WINAPI IcmpCloseHandle(HANDLE IcmpHandle)
{
icmp_t* icp=(icmp_t*)IcmpHandle;
BOOL WINAPI IcmpCloseHandle(HANDLE IcmpHandle)
{
icmp_t* icp=(icmp_t*)IcmpHandle;
// REACTOS: Added a check for NULL handle, CORE-10707
if (IcmpHandle==INVALID_HANDLE_VALUE || IcmpHandle==NULL) {
// REACTOS: Added a check for NULL handle, CORE-10707
if (IcmpHandle==INVALID_HANDLE_VALUE || IcmpHandle==NULL) {
+#else
+ if (IcmpHandle==INVALID_HANDLE_VALUE) {
+#endif
/* FIXME: in fact win98 seems to ignore the handle value !!! */
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
/* FIXME: in fact win98 seems to ignore the handle value !!! */
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
BOOL
GetIPv4ByIndex(
_In_ DWORD Index,
BOOL
GetIPv4ByIndex(
_In_ DWORD Index,
HeapFree(GetProcessHeap(), 0, pIpAddrTable);
return result;
}
HeapFree(GetProcessHeap(), 0, pIpAddrTable);
return result;
}
/***********************************************************************
* IcmpSendEcho (IPHLPAPI.@)
/***********************************************************************
* IcmpSendEcho (IPHLPAPI.@)
if (ReplySize<sizeof(ICMP_ECHO_REPLY)) {
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
if (ReplySize<sizeof(ICMP_ECHO_REPLY)) {
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
if (Timeout == 0 || Timeout == -1) {
SetLastError(ERROR_INVALID_PARAMETER);
if (Timeout == 0 || Timeout == -1) {
SetLastError(ERROR_INVALID_PARAMETER);
+#else
+ if (ReplySize<sizeof(ICMP_ECHO_REPLY)+ICMP_MINLEN) {
+ SetLastError(IP_BUF_TOO_SMALL);
+#endif
return 0;
}
/* check the request size against SO_MAX_MSG_SIZE using getsockopt */
return 0;
}
/* check the request size against SO_MAX_MSG_SIZE using getsockopt */
#endif
seq=InterlockedIncrement(&icmp_sequence) & 0xFFFF;
#endif
seq=InterlockedIncrement(&icmp_sequence) & 0xFFFF;
reqsize=ICMP_MINLEN;
if (RequestData && RequestSize > 0)
reqsize += RequestSize;
reqsize=ICMP_MINLEN;
if (RequestData && RequestSize > 0)
reqsize += RequestSize;
+#else
+ reqsize=ICMP_MINLEN+RequestSize;
+#endif
reqbuf=HeapAlloc(GetProcessHeap(), 0, reqsize);
if (reqbuf==NULL) {
SetLastError(ERROR_OUTOFMEMORY);
reqbuf=HeapAlloc(GetProcessHeap(), 0, reqsize);
if (reqbuf==NULL) {
SetLastError(ERROR_OUTOFMEMORY);
icmp_header->icmp_cksum=0;
icmp_header->icmp_id=id;
icmp_header->icmp_seq=seq;
icmp_header->icmp_cksum=0;
icmp_header->icmp_id=id;
icmp_header->icmp_seq=seq;
if (RequestData && RequestSize > 0)
memcpy(reqbuf+ICMP_MINLEN, RequestData, RequestSize);
if (RequestData && RequestSize > 0)
memcpy(reqbuf+ICMP_MINLEN, RequestData, RequestSize);
+#else
+ memcpy(reqbuf+ICMP_MINLEN, RequestData, RequestSize);
+#endif
icmp_header->icmp_cksum=cksum=in_cksum((u_short*)reqbuf,reqsize);
addr.sin_family=AF_INET;
icmp_header->icmp_cksum=cksum=in_cksum((u_short*)reqbuf,reqsize);
addr.sin_family=AF_INET;
#endif
addrlen=sizeof(addr);
ier=ReplyBuffer;
#endif
addrlen=sizeof(addr);
ier=ReplyBuffer;
endbuf=((char *) ReplyBuffer)+ReplySize;
maxlen=sizeof(struct ip)+ICMP_MINLEN+RequestSize;
endbuf=((char *) ReplyBuffer)+ReplySize;
maxlen=sizeof(struct ip)+ICMP_MINLEN+RequestSize;
+#else
+ ip_header=(struct ip *) ((char *) ReplyBuffer+sizeof(ICMP_ECHO_REPLY));
+ endbuf=(char *) ReplyBuffer+ReplySize;
+ maxlen=ReplySize-sizeof(ICMP_ECHO_REPLY);
+#endif
/* Send the packet */
TRACE("Sending %d bytes (RequestSize=%d) to %s\n", reqsize, RequestSize, inet_ntoa(addr.sin_addr));
/* Send the packet */
TRACE("Sending %d bytes (RequestSize=%d) to %s\n", reqsize, RequestSize, inet_ntoa(addr.sin_addr));
#endif
HeapFree(GetProcessHeap (), 0, reqbuf);
if (res<0) {
#endif
HeapFree(GetProcessHeap (), 0, reqbuf);
if (res<0) {
DWORD dwBestIfIndex;
IPAddr IP4Addr;
DWORD dwBestIfIndex;
IPAddr IP4Addr;
memcpy(&ier->Address, &IP4Addr, sizeof(IP4Addr));
}
memcpy(&ier->Address, &IP4Addr, sizeof(IP4Addr));
}
if (WSAGetLastError()==WSAEMSGSIZE)
ier->Status = IP_PACKET_TOO_BIG;
else {
if (WSAGetLastError()==WSAEMSGSIZE)
ier->Status = IP_PACKET_TOO_BIG;
else {
ip_header=HeapAlloc(GetProcessHeap(), 0, maxlen);
ip_header=HeapAlloc(GetProcessHeap(), 0, maxlen);
ip_header_len=0; /* because gcc was complaining */
#ifdef __REACTOS__
while ((res=select(icp->sid+1,&fdr,NULL,NULL,&timeout))>0) {
ip_header_len=0; /* because gcc was complaining */
#ifdef __REACTOS__
while ((res=select(icp->sid+1,&fdr,NULL,NULL,&timeout))>0) {
#endif
TRACE("received %d bytes from %s\n",res, inet_ntoa(addr.sin_addr));
ier->Status=IP_REQ_TIMED_OUT;
#endif
TRACE("received %d bytes from %s\n",res, inet_ntoa(addr.sin_addr));
ier->Status=IP_REQ_TIMED_OUT;
/* Check whether we should ignore this packet */
if ((ip_header->ip_p==IPPROTO_ICMP) && (res>=sizeof(struct ip)+ICMP_MINLEN)) {
/* Check whether we should ignore this packet */
if ((ip_header->ip_p==IPPROTO_ICMP) && (res>=sizeof(struct ip)+ICMP_MINLEN)) {
/* Prepare for the next packet */
ier++;
/* Prepare for the next packet */
ier++;
+#ifndef __REACTOS__
+ ip_header=(struct ip*)(((char*)ip_header)+sizeof(ICMP_ECHO_REPLY));
+ maxlen=endbuf-(char*)ip_header;
+#endif
/* Check out whether there is more but don't wait this time */
#ifdef __REACTOS__
/* Check out whether there is more but don't wait this time */
#ifdef __REACTOS__
FD_SET(icp->sid,&fdr);
#endif
}
FD_SET(icp->sid,&fdr);
#endif
}
HeapFree(GetProcessHeap(), 0, ip_header);
HeapFree(GetProcessHeap(), 0, ip_header);
res=ier-(ICMP_ECHO_REPLY*)ReplyBuffer;
if (res==0)
res=ier-(ICMP_ECHO_REPLY*)ReplyBuffer;
if (res==0)
{
ier->Status = IP_REQ_TIMED_OUT;
{
ier->Status = IP_REQ_TIMED_OUT;
SetLastError(IP_REQ_TIMED_OUT);
SetLastError(IP_REQ_TIMED_OUT);
TRACE("received %d replies\n",res);
return res;
}
TRACE("received %d replies\n",res);
return res;
}