/*
This file is part of GNUnet.
- (C) 2001, 2002, 2003, 2004, 2005, 2006 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
#include "winproc.h"
#include "platform.h"
+#include "gnunet_crypto_lib.h"
#include "gnunet_common.h"
#include "gnunet_connection_lib.h"
#include <ntdef.h>
-
#ifndef INHERITED_ACE
#define INHERITED_ACE 0x10
#endif
ULONG Length; \
DWORD Flags; \
}; \
- };
+ };
#define _IP_ADAPTER_UNICAST_ADDRESS_BASE \
SOCKET_ADDRESS Address; \
_IP_ADAPTER_UNICAST_ADDRESS_DEFINE(_VISTA,_IP_ADAPTER_UNICAST_ADDRESS_ADD_VISTA)
+#ifndef __MINGW64_VERSION_MAJOR
typedef struct _IP_ADAPTER_WINS_SERVER_ADDRESS {
union {
ULONGLONG Alignment;
struct _IP_ADAPTER_GATEWAY_ADDRESS *Next;
SOCKET_ADDRESS Address;
} IP_ADAPTER_GATEWAY_ADDRESS, *PIP_ADAPTER_GATEWAY_ADDRESS, *PIP_ADAPTER_GATEWAY_ADDRESS_LH;
+#endif
typedef UINT32 NET_IF_COMPARTMENT_ID;
typedef GUID NET_IF_NETWORK_GUID;
+#ifndef __MINGW64_VERSION_MAJOR
typedef enum _NET_IF_CONNECTION_TYPE {
NET_IF_CONNECTION_DEDICATED = 1,
NET_IF_CONNECTION_PASSIVE,
NET_IF_CONNECTION_DEMAND,
- NET_IF_CONNECTION_MAXIMUM
+ NET_IF_CONNECTION_MAXIMUM
} NET_IF_CONNECTION_TYPE, *PNET_IF_CONNECTION_TYPE;
typedef enum {
TUNNEL_TYPE_6TO4,
TUNNEL_TYPE_ISATAP,
TUNNEL_TYPE_TEREDO,
- TUNNEL_TYPE_IPHTTPS
+ TUNNEL_TYPE_IPHTTPS
} TUNNEL_TYPE, *PTUNNEL_TYPE;
+#endif
/*
A DUID consists of a two-octet type code represented in network byte
*/
#define MAX_DHCPV6_DUID_LENGTH 130
+#ifndef __MINGW64_VERSION_MAJOR
typedef union _NET_LUID {
ULONG64 Value;
struct {
struct _IP_ADAPTER_DNS_SUFFIX *Next;
WCHAR String[MAX_DNS_SUFFIX_STRING_LENGTH];
} IP_ADAPTER_DNS_SUFFIX, *PIP_ADAPTER_DNS_SUFFIX;
+#endif
_IP_ADAPTER_ADDRESSES_BASE \
addition \
} IP_ADAPTER_ADDRESSES##suffix, *PIP_ADAPTER_ADDRESSES##suffix;
-
+
/* _IP_ADAPTER_ADDRESSES_DEFINE(,) defined in w32api headers */
_IP_ADAPTER_ADDRESSES_DEFINE(_XPSP1,_IP_ADAPTER_ADDRESSES_ADD_XPSP1)
EnumNICs2 (INTERFACE_INFO **ifs4, int *ifs4_len, SOCKET_ADDRESS_LIST **ifs6)
{
int result = 0;
- SOCKET s4 = INVALID_SOCKET, s6 = INVALID_SOCKET;
- DWORD dwret1 = 0, dwret2;
- DWORD err1, err2;
- int ifs4len = 0, ifs6len = 0;
+ SOCKET s4;
+ SOCKET s6;
+ int ifs4len = 0;
+ int ifs6len = 0;
INTERFACE_INFO *interfaces4 = NULL;
SOCKET_ADDRESS_LIST *interfaces6 = NULL;
+
SetLastError (0);
s4 = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
- err1 = GetLastError ();
+ (void) GetLastError ();
SetLastError (0);
s6 = socket (AF_INET6, SOCK_STREAM, IPPROTO_TCP);
- err2 = GetLastError ();
+ (void) GetLastError ();
if (s6 != INVALID_SOCKET)
{
ifs6len = EnumNICs_IPv6_get_ifs_count (s6);
return GNUNET_SYSERR;
}
+
/**
- * Returns GNUNET_OK on OK, GNUNET_SYSERR on error
+ * @returns #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
int
EnumNICs3 (struct EnumNICs3_results **results, int *results_count)
if (!use_enum2)
{
- memcpy (&r->address, unicast->Address.lpSockaddr,
+ GNUNET_memcpy (&r->address, unicast->Address.lpSockaddr,
unicast->Address.iSockaddrLength);
memset (&r->mask, 0, sizeof (struct sockaddr));
mask_length = ((IP_ADAPTER_UNICAST_ADDRESS_VISTA *) unicast)->
struct sockaddr_in6 *b = (struct sockaddr_in6 *) &r->broadcast;
for (i = 0; i < mask_length; i++)
((unsigned char *) &m->sin6_addr)[i / 8] |= 0x80 >> (i % 8);
- memcpy (&r->broadcast, &r->address, unicast->Address.iSockaddrLength);
+ GNUNET_memcpy (&r->broadcast, &r->address, unicast->Address.iSockaddrLength);
for (i = mask_length; i < 128; i++)
((unsigned char *) &b->sin6_addr)[i / 8] |= 0x80 >> (i % 8);
}
for (i = 0; !found && i < interfaces4_len / sizeof (INTERFACE_INFO); i++)
{
struct sockaddr_in *m = (struct sockaddr_in *) &r->mask;
- if (memcpy (&interfaces4[i].iiAddress.Address,
+ if (GNUNET_memcpy (&interfaces4[i].iiAddress.Address,
unicast->Address.lpSockaddr,
unicast->Address.iSockaddrLength) != 0)
continue;
found = 1;
- memcpy (&r->address, &interfaces4[i].iiAddress.Address,
+ GNUNET_memcpy (&r->address, &interfaces4[i].iiAddress.Address,
sizeof (struct sockaddr_in));
- memcpy (&r->mask, &interfaces4[i].iiNetmask.Address,
+ GNUNET_memcpy (&r->mask, &interfaces4[i].iiNetmask.Address,
sizeof (struct sockaddr_in));
for (mask_length = 0;
((unsigned char *) &m->sin_addr)[mask_length / 8] &
interfaces6 != NULL && !found && i < interfaces6->iAddressCount;
i++)
{
- if (memcpy (interfaces6->Address[i].lpSockaddr,
+ if (GNUNET_memcpy (interfaces6->Address[i].lpSockaddr,
unicast->Address.lpSockaddr,
unicast->Address.iSockaddrLength) != 0)
continue;
found = 1;
- memcpy (&r->address, interfaces6->Address[i].lpSockaddr,
+ GNUNET_memcpy (&r->address, interfaces6->Address[i].lpSockaddr,
sizeof (struct sockaddr_in6));
/* TODO: Find a way to reliably get network mask for IPv6 on XP */
memset (&r->mask, 0, sizeof (struct sockaddr));
* falling under netmask to 1,
* so we get, 192.168.0.255 from, say, 192.168.0.43 with mask == 24.
*/
- memcpy (&r->broadcast, &r->address, unicast->Address.iSockaddrLength);
+ GNUNET_memcpy (&r->broadcast, &r->address, unicast->Address.iSockaddrLength);
for (i = mask_length; i < 32; i++)
((unsigned char *) &m->sin_addr)[i / 8] |= 0x80 >> (i % 8);
r->flags |= ENUMNICS3_BCAST_OK;
return 0;
}
+
/**
* @brief Uninstall Windows service
* @param servicename name of the service to delete
* 3 if the service cannot be accessed
* 4 if the service cannot be deleted
*/
-int UninstallService(char *servicename)
+int
+UninstallService(char *servicename)
{
SC_HANDLE hManager, hService;
return 2;
if (! (hService = GNOpenService(hManager, (LPCTSTR) servicename, DELETE)))
+ {
if (GetLastError() != ERROR_SERVICE_DOES_NOT_EXIST)
return 3;
- else
- goto closeSCM;
+ else
+ goto closeSCM;
+ }
if (! GNDeleteService(hService))
if (GetLastError() != ERROR_SERVICE_MARKED_FOR_DELETE)
* @see http://support.microsoft.com/?scid=kb;en-us;132958
* @date 12-Jul-95
*/
-void _InitLsaString(PLSA_UNICODE_STRING LsaString, LPWSTR String)
+void
+_InitLsaString(PLSA_UNICODE_STRING LsaString, LPWSTR String)
{
DWORD StringLength;
* @see http://support.microsoft.com/?scid=kb;en-us;132958
* @date 12-Jul-95
*/
-NTSTATUS _OpenPolicy(LPWSTR ServerName, DWORD DesiredAccess, PLSA_HANDLE PolicyHandle)
+NTSTATUS
+_OpenPolicy(LPWSTR ServerName, DWORD DesiredAccess, PLSA_HANDLE PolicyHandle)
{
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
LSA_UNICODE_STRING ServerString;
* @remarks Call GetLastError() to obtain extended error information.
* @see http://support.microsoft.com/?scid=kb;en-us;132958
*/
-BOOL _GetAccountSid(LPCTSTR SystemName, LPCTSTR AccountName, PSID * Sid)
+BOOL
+_GetAccountSid(LPCTSTR SystemName, LPCTSTR AccountName, PSID * Sid)
{
LPTSTR ReferencedDomain = NULL;
DWORD cbSid = 128; /* initial allocation attempt */
* @see http://support.microsoft.com/?scid=kb;en-us;132958
* @date 12-Jul-95
*/
-NTSTATUS _SetPrivilegeOnAccount(LSA_HANDLE PolicyHandle,/* open policy handle */
- PSID AccountSid, /* SID to grant privilege to */
- LPWSTR PrivilegeName, /* privilege to grant (Unicode) */
- BOOL bEnable /* enable or disable */
+NTSTATUS
+_SetPrivilegeOnAccount(LSA_HANDLE PolicyHandle,/* open policy handle */
+ PSID AccountSid, /* SID to grant privilege to */
+ LPWSTR PrivilegeName, /* privilege to grant (Unicode) */
+ BOOL bEnable /* enable or disable */
)
{
LSA_UNICODE_STRING PrivilegeString;
&PrivilegeString, /* privileges */
1 /* privilege count */
);
+ return i;
}
else
{
* @param pszName the name of the account
* @param pszDesc description of the account
*/
-int CreateServiceAccount(const char *pszName, const char *pszDesc)
+int
+CreateServiceAccount(const char *pszName,
+ const char *pszDesc)
{
USER_INFO_1 ui;
USER_INFO_1008 ui2;
NET_API_STATUS nStatus;
wchar_t wszName[MAX_NAME_LENGTH], wszDesc[MAX_NAME_LENGTH];
- DWORD dwErr;
LSA_HANDLE hPolicy;
PSID pSID;
ui2.usri1008_flags = UF_PASSWD_CANT_CHANGE | UF_DONT_EXPIRE_PASSWD;
GNNetUserSetInfo(NULL, wszName, 1008, (LPBYTE)&ui2, NULL);
- if (_OpenPolicy(NULL, POLICY_ALL_ACCESS, &hPolicy) !=
- STATUS_SUCCESS)
+ if (!NT_SUCCESS(_OpenPolicy(NULL, POLICY_ALL_ACCESS, &hPolicy)))
return 3;
_GetAccountSid(NULL, (LPCTSTR) pszName, &pSID);
- if (_SetPrivilegeOnAccount(hPolicy, pSID, (LPWSTR) L"SeServiceLogonRight", TRUE) != STATUS_SUCCESS)
+ if (!NT_SUCCESS(_SetPrivilegeOnAccount(hPolicy, pSID, (LPWSTR) L"SeServiceLogonRight", TRUE)))
return 4;
_SetPrivilegeOnAccount(hPolicy, pSID, (LPWSTR) L"SeDenyInteractiveLogonRight", TRUE);