ReactOS 0.4.17-dev-966-gf06eace
port.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "string.h"
#include "initguid.h"
#include "assert.h"
#include "winsock2.h"
#include "winhttp.h"
#include "shlwapi.h"
#include "xmllite.h"
#include "ole2.h"
#include "netfw.h"
#include "natupnp.h"
#include "wine/debug.h"
#include "hnetcfg_private.h"
Include dependency graph for port.c:

Go to the source code of this file.

Classes

struct  port_mapping
 
struct  xml_value_desc
 
struct  static_port_mapping
 
struct  port_mapping_enum
 
struct  static_port_mapping_collection
 
struct  fw_port
 
struct  fw_ports
 
struct  _upnpnat
 

Macros

#define COBJMACROS
 
#define COPY_BSTR_CHECK(name)
 

Typedefs

typedef struct fw_port fw_port
 
typedef struct fw_ports fw_ports
 
typedef struct _upnpnat upnpnat
 

Enumerations

enum  port_mapping_parameter {
  PM_EXTERNAL_IP , PM_EXTERNAL , PM_PROTOCOL , PM_INTERNAL ,
  PM_CLIENT , PM_ENABLED , PM_DESC , PM_LEASE_DURATION ,
  PM_LAST , PM_REMOVE_PORT_LAST = PM_INTERNAL
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (hnetcfg)
 
static void free_port_mapping (struct port_mapping *mapping)
 
static void free_mappings (void)
 
static BOOL copy_port_mapping (struct port_mapping *dst, const struct port_mapping *src)
 
static BOOL parse_search_response (char *response, WCHAR *locationW, unsigned int location_size)
 
static BOOL parse_desc_xml (const char *desc_xml)
 
static BOOL get_xml_elements (const char *desc_xml, struct xml_value_desc *values, unsigned int value_count)
 
static BOOL open_gateway_connection (void)
 
static BOOL get_control_url (void)
 
static void gateway_connection_cleanup (void)
 
static BOOL request_service (const WCHAR *function, const struct xml_value_desc *request_param, unsigned int request_param_count, struct xml_value_desc *result, unsigned int result_count, DWORD *http_status, BSTR *server_error_code_str)
 
static LONG long_from_bstr (BSTR s)
 
static BSTR mapping_move_bstr (BSTR *s)
 
static void update_mapping_list (void)
 
static BOOL remove_port_mapping (LONG port, BSTR protocol)
 
static BOOL add_port_mapping (LONG external, BSTR protocol, LONG internal, BSTR client, VARIANT_BOOL enabled, BSTR description)
 
static BOOL init_gateway_connection (void)
 
static BOOL grab_gateway_connection (void)
 
static void release_gateway_connection (void)
 
static BOOL find_port_mapping (LONG port, BSTR protocol, struct port_mapping *ret)
 
static unsigned int get_port_mapping_range (unsigned int index, unsigned int count, struct port_mapping *ret)
 
static unsigned int get_port_mapping_count (void)
 
static BOOL is_valid_protocol (BSTR protocol)
 
static struct static_port_mapping * impl_from_IStaticPortMapping (IStaticPortMapping *iface)
 
static ULONG WINAPI static_port_mapping_AddRef (IStaticPortMapping *iface)
 
static ULONG WINAPI static_port_mapping_Release (IStaticPortMapping *iface)
 
static HRESULT WINAPI static_port_mapping_QueryInterface (IStaticPortMapping *iface, REFIID riid, void **ppvObject)
 
static HRESULT WINAPI static_port_mapping_GetTypeInfoCount (IStaticPortMapping *iface, UINT *pctinfo)
 
static HRESULT WINAPI static_port_mapping_GetTypeInfo (IStaticPortMapping *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
 
static HRESULT WINAPI static_port_mapping_GetIDsOfNames (IStaticPortMapping *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
 
static HRESULT WINAPI static_port_mapping_Invoke (IStaticPortMapping *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
 
static HRESULT WINAPI static_port_mapping_get_ExternalIPAddress (IStaticPortMapping *iface, BSTR *value)
 
static HRESULT WINAPI static_port_mapping_get_ExternalPort (IStaticPortMapping *iface, LONG *value)
 
static HRESULT WINAPI static_port_mapping_get_InternalPort (IStaticPortMapping *iface, LONG *value)
 
static HRESULT WINAPI static_port_mapping_get_Protocol (IStaticPortMapping *iface, BSTR *value)
 
static HRESULT WINAPI static_port_mapping_get_InternalClient (IStaticPortMapping *iface, BSTR *value)
 
static HRESULT WINAPI static_port_mapping_get_Enabled (IStaticPortMapping *iface, VARIANT_BOOL *value)
 
static HRESULT WINAPI static_port_mapping_get_Description (IStaticPortMapping *iface, BSTR *value)
 
static HRESULT WINAPI static_port_mapping_EditInternalClient (IStaticPortMapping *iface, BSTR value)
 
static HRESULT WINAPI static_port_mapping_Enable (IStaticPortMapping *iface, VARIANT_BOOL value)
 
static HRESULT WINAPI static_port_mapping_EditDescription (IStaticPortMapping *iface, BSTR value)
 
static HRESULT WINAPI static_port_mapping_EditInternalPort (IStaticPortMapping *iface, LONG value)
 
static HRESULT static_port_mapping_create (const struct port_mapping *mapping_data, IStaticPortMapping **ret)
 
static struct port_mapping_enum * impl_from_IEnumVARIANT (IEnumVARIANT *iface)
 
static ULONG WINAPI port_mapping_enum_AddRef (IEnumVARIANT *iface)
 
static ULONG WINAPI port_mapping_enum_Release (IEnumVARIANT *iface)
 
static HRESULT WINAPI port_mapping_enum_QueryInterface (IEnumVARIANT *iface, REFIID riid, void **ppvObject)
 
static HRESULT WINAPI port_mapping_enum_Next (IEnumVARIANT *iface, ULONG celt, VARIANT *var, ULONG *fetched)
 
static HRESULT WINAPI port_mapping_enum_Skip (IEnumVARIANT *iface, ULONG celt)
 
static HRESULT WINAPI port_mapping_enum_Reset (IEnumVARIANT *iface)
 
static HRESULT create_port_mapping_enum (IUnknown **ret)
 
static HRESULT WINAPI port_mapping_enum_Clone (IEnumVARIANT *iface, IEnumVARIANT **ret)
 
static struct static_port_mapping_collection * impl_from_IStaticPortMappingCollection (IStaticPortMappingCollection *iface)
 
static ULONG WINAPI static_ports_AddRef (IStaticPortMappingCollection *iface)
 
static ULONG WINAPI static_ports_Release (IStaticPortMappingCollection *iface)
 
static HRESULT WINAPI static_ports_QueryInterface (IStaticPortMappingCollection *iface, REFIID riid, void **ppvObject)
 
static HRESULT WINAPI static_ports_GetTypeInfoCount (IStaticPortMappingCollection *iface, UINT *pctinfo)
 
static HRESULT WINAPI static_ports_GetTypeInfo (IStaticPortMappingCollection *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
 
static HRESULT WINAPI static_ports_GetIDsOfNames (IStaticPortMappingCollection *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
 
static HRESULT WINAPI static_ports_Invoke (IStaticPortMappingCollection *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
 
static HRESULT WINAPI static_ports__NewEnum (IStaticPortMappingCollection *iface, IUnknown **ret)
 
static HRESULT WINAPI static_ports_get_Item (IStaticPortMappingCollection *iface, LONG port, BSTR protocol, IStaticPortMapping **mapping)
 
static HRESULT WINAPI static_ports_get_Count (IStaticPortMappingCollection *iface, LONG *count)
 
static HRESULT WINAPI static_ports_Remove (IStaticPortMappingCollection *iface, LONG port, BSTR protocol)
 
static HRESULT WINAPI static_ports_Add (IStaticPortMappingCollection *iface, LONG external, BSTR protocol, LONG internal, BSTR client, VARIANT_BOOL enabled, BSTR description, IStaticPortMapping **mapping)
 
static HRESULT static_port_mapping_collection_create (IStaticPortMappingCollection **object)
 
static fw_port * impl_from_INetFwOpenPort (INetFwOpenPort *iface)
 
static ULONG WINAPI fw_port_AddRef (INetFwOpenPort *iface)
 
static ULONG WINAPI fw_port_Release (INetFwOpenPort *iface)
 
static HRESULT WINAPI fw_port_QueryInterface (INetFwOpenPort *iface, REFIID riid, void **ppvObject)
 
static HRESULT WINAPI fw_port_GetTypeInfoCount (INetFwOpenPort *iface, UINT *pctinfo)
 
static HRESULT WINAPI fw_port_GetTypeInfo (INetFwOpenPort *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
 
static HRESULT WINAPI fw_port_GetIDsOfNames (INetFwOpenPort *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
 
static HRESULT WINAPI fw_port_Invoke (INetFwOpenPort *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
 
static HRESULT WINAPI fw_port_get_Name (INetFwOpenPort *iface, BSTR *name)
 
static HRESULT WINAPI fw_port_put_Name (INetFwOpenPort *iface, BSTR name)
 
static HRESULT WINAPI fw_port_get_IpVersion (INetFwOpenPort *iface, NET_FW_IP_VERSION *ipVersion)
 
static HRESULT WINAPI fw_port_put_IpVersion (INetFwOpenPort *iface, NET_FW_IP_VERSION ipVersion)
 
static HRESULT WINAPI fw_port_get_Protocol (INetFwOpenPort *iface, NET_FW_IP_PROTOCOL *ipProtocol)
 
static HRESULT WINAPI fw_port_put_Protocol (INetFwOpenPort *iface, NET_FW_IP_PROTOCOL ipProtocol)
 
static HRESULT WINAPI fw_port_get_Port (INetFwOpenPort *iface, LONG *portNumber)
 
static HRESULT WINAPI fw_port_put_Port (INetFwOpenPort *iface, LONG portNumber)
 
static HRESULT WINAPI fw_port_get_Scope (INetFwOpenPort *iface, NET_FW_SCOPE *scope)
 
static HRESULT WINAPI fw_port_put_Scope (INetFwOpenPort *iface, NET_FW_SCOPE scope)
 
static HRESULT WINAPI fw_port_get_RemoteAddresses (INetFwOpenPort *iface, BSTR *remoteAddrs)
 
static HRESULT WINAPI fw_port_put_RemoteAddresses (INetFwOpenPort *iface, BSTR remoteAddrs)
 
static HRESULT WINAPI fw_port_get_Enabled (INetFwOpenPort *iface, VARIANT_BOOL *enabled)
 
static HRESULT WINAPI fw_port_put_Enabled (INetFwOpenPort *iface, VARIANT_BOOL enabled)
 
static HRESULT WINAPI fw_port_get_BuiltIn (INetFwOpenPort *iface, VARIANT_BOOL *builtIn)
 
HRESULT NetFwOpenPort_create (IUnknown *pUnkOuter, LPVOID *ppObj)
 
static fw_ports * impl_from_INetFwOpenPorts (INetFwOpenPorts *iface)
 
static ULONG WINAPI fw_ports_AddRef (INetFwOpenPorts *iface)
 
static ULONG WINAPI fw_ports_Release (INetFwOpenPorts *iface)
 
static HRESULT WINAPI fw_ports_QueryInterface (INetFwOpenPorts *iface, REFIID riid, void **ppvObject)
 
static HRESULT WINAPI fw_ports_GetTypeInfoCount (INetFwOpenPorts *iface, UINT *pctinfo)
 
static HRESULT WINAPI fw_ports_GetTypeInfo (INetFwOpenPorts *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
 
static HRESULT WINAPI fw_ports_GetIDsOfNames (INetFwOpenPorts *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
 
static HRESULT WINAPI fw_ports_Invoke (INetFwOpenPorts *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
 
static HRESULT WINAPI fw_ports_get_Count (INetFwOpenPorts *iface, LONG *count)
 
static HRESULT WINAPI fw_ports_Add (INetFwOpenPorts *iface, INetFwOpenPort *port)
 
static HRESULT WINAPI fw_ports_Remove (INetFwOpenPorts *iface, LONG portNumber, NET_FW_IP_PROTOCOL ipProtocol)
 
static HRESULT WINAPI fw_ports_Item (INetFwOpenPorts *iface, LONG portNumber, NET_FW_IP_PROTOCOL ipProtocol, INetFwOpenPort **openPort)
 
static HRESULT WINAPI fw_ports_get__NewEnum (INetFwOpenPorts *iface, IUnknown **newEnum)
 
HRESULT NetFwOpenPorts_create (IUnknown *pUnkOuter, LPVOID *ppObj)
 
static upnpnat * impl_from_IUPnPNAT (IUPnPNAT *iface)
 
static HRESULT WINAPI upnpnat_QueryInterface (IUPnPNAT *iface, REFIID riid, void **object)
 
static ULONG WINAPI upnpnat_AddRef (IUPnPNAT *iface)
 
static ULONG WINAPI upnpnat_Release (IUPnPNAT *iface)
 
static HRESULT WINAPI upnpnat_GetTypeInfoCount (IUPnPNAT *iface, UINT *pctinfo)
 
static HRESULT WINAPI upnpnat_GetTypeInfo (IUPnPNAT *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
 
static HRESULT WINAPI upnpnat_GetIDsOfNames (IUPnPNAT *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
 
static HRESULT WINAPI upnpnat_Invoke (IUPnPNAT *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
 
static HRESULT WINAPI upnpnat_get_StaticPortMappingCollection (IUPnPNAT *iface, IStaticPortMappingCollection **collection)
 
static HRESULT WINAPI upnpnat_get_DynamicPortMappingCollection (IUPnPNAT *iface, IDynamicPortMappingCollection **collection)
 
static HRESULT WINAPI upnpnat_get_NATEventManager (IUPnPNAT *iface, INATEventManager **manager)
 
HRESULT IUPnPNAT_create (IUnknown *outer, void **object)
 

Variables

struct {
   LONG   refs
 
   BOOL   winsock_initialized
 
   WCHAR   locationW [256]
 
   HINTERNET   session
 
   HINTERNET   connection
 
   WCHAR   desc_urlpath [128]
 
   WCHAR   control_url [256]
 
   unsigned int   version
 
   struct port_mapping *   mappings
 
   unsigned int   mapping_count
 
} upnp_gateway_connection
 
static SRWLOCK upnp_gateway_connection_lock = SRWLOCK_INIT
 
static struct xml_value_desc port_mapping_template []
 
static const IStaticPortMappingVtbl static_port_mapping_vtbl
 
static const IEnumVARIANTVtbl port_mapping_enum_vtbl
 
static const IStaticPortMappingCollectionVtbl static_ports_vtbl
 
static const struct INetFwOpenPortVtbl fw_port_vtbl
 
static const struct INetFwOpenPortsVtbl fw_ports_vtbl
 
static const IUPnPNATVtbl upnpnat_vtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 22 of file port.c.

◆ COPY_BSTR_CHECK

#define COPY_BSTR_CHECK (   name)
Value:
if (src->name && !(dst->name = SysAllocString( src->name ))) \
{ \
free_port_mapping( dst ); \
return FALSE; \
}
#define FALSE
Definition: types.h:117
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:240

Typedef Documentation

◆ fw_port

◆ fw_ports

◆ upnpnat

Enumeration Type Documentation

◆ port_mapping_parameter

Enumerator
PM_EXTERNAL_IP 
PM_EXTERNAL 
PM_PROTOCOL 
PM_INTERNAL 
PM_CLIENT 
PM_ENABLED 
PM_DESC 
PM_LEASE_DURATION 
PM_LAST 
PM_REMOVE_PORT_LAST 

Definition at line 511 of file port.c.

512{
517 PM_CLIENT,
519 PM_DESC,
521 PM_LAST,
523};
@ PM_LEASE_DURATION
Definition: port.c:520
@ PM_CLIENT
Definition: port.c:517
@ PM_EXTERNAL_IP
Definition: port.c:513
@ PM_INTERNAL
Definition: port.c:516
@ PM_ENABLED
Definition: port.c:518
@ PM_LAST
Definition: port.c:521
@ PM_EXTERNAL
Definition: port.c:514
@ PM_REMOVE_PORT_LAST
Definition: port.c:522
@ PM_DESC
Definition: port.c:519
@ PM_PROTOCOL
Definition: port.c:515

Function Documentation

◆ add_port_mapping()

static BOOL add_port_mapping ( LONG  external,
BSTR  protocol,
LONG  internal,
BSTR  client,
VARIANT_BOOL  enabled,
BSTR  description 
)
static

Definition at line 657 of file port.c.

659{
660 struct xml_value_desc mapping_desc[PM_LAST];
661 WCHAR externalW[6], internalW[6];
662 DWORD status = 0;
663 BSTR error_str;
664 BOOL ret;
665
667 memcpy( mapping_desc, port_mapping_template, sizeof(mapping_desc) );
668 swprintf( externalW, ARRAY_SIZE(externalW), L"%u", external );
669 swprintf( internalW, ARRAY_SIZE(internalW), L"%u", internal );
670 mapping_desc[PM_EXTERNAL_IP].value = SysAllocString( L"" );
671 mapping_desc[PM_EXTERNAL].value = SysAllocString( externalW );
672 mapping_desc[PM_PROTOCOL].value = protocol;
673 mapping_desc[PM_INTERNAL].value = SysAllocString( internalW );
674 mapping_desc[PM_CLIENT].value = client;
675 mapping_desc[PM_ENABLED].value = SysAllocString( enabled ? L"1" : L"0" );
676 mapping_desc[PM_DESC].value = description;
677 mapping_desc[PM_LEASE_DURATION].value = SysAllocString( L"0" );
678
679 ret = request_service( L"AddPortMapping", mapping_desc, PM_LAST,
680 NULL, 0, &status, &error_str );
681 if (ret && status != HTTP_STATUS_OK)
682 {
683 WARN( "status %lu, server returned error %s.\n", status, debugstr_w(error_str) );
684 SysFreeString( error_str );
685 ret = FALSE;
686 }
687 else if (!ret)
688 {
689 WARN( "Request failed.\n" );
690 }
693
694 SysFreeString( mapping_desc[PM_EXTERNAL_IP].value );
695 SysFreeString( mapping_desc[PM_EXTERNAL].value );
696 SysFreeString( mapping_desc[PM_INTERNAL].value );
697 SysFreeString( mapping_desc[PM_ENABLED].value );
698 SysFreeString( mapping_desc[PM_LEASE_DURATION].value );
699 return ret;
700}
ios_base &_STLP_CALL internal(ios_base &__s)
Definition: _ios_base.h:311
#define ARRAY_SIZE(A)
Definition: main.h:20
#define WARN(fmt,...)
Definition: precomp.h:61
void * description
#define NULL
Definition: types.h:112
OLECHAR * BSTR
Definition: compat.h:2293
static struct xml_value_desc port_mapping_template[]
Definition: port.c:525
static BOOL request_service(const WCHAR *function, const struct xml_value_desc *request_param, unsigned int request_param_count, struct xml_value_desc *result, unsigned int result_count, DWORD *http_status, BSTR *server_error_code_str)
Definition: port.c:401
static void update_mapping_list(void)
Definition: port.c:559
static SRWLOCK upnp_gateway_connection_lock
Definition: port.c:74
VOID WINAPI AcquireSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:8
VOID WINAPI ReleaseSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:36
#define swprintf
Definition: precomp.h:40
return ret
Definition: mutex.c:147
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glext.h:7750
#define debugstr_w
Definition: kernel32.h:32
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:273
short WCHAR
Definition: pedump.c:58
static FILE * client
Definition: client.c:37
Definition: ps.c:97
Definition: pdh_main.c:64
#define HTTP_STATUS_OK
Definition: winhttp.h:301

Referenced by static_ports_Add().

◆ copy_port_mapping()

static BOOL copy_port_mapping ( struct port_mapping *  dst,
const struct port_mapping *  src 
)
static

Definition at line 95 of file port.c.

96{
97 memset( dst, 0, sizeof(*dst) );
98
99#define COPY_BSTR_CHECK(name) if (src->name && !(dst->name = SysAllocString( src->name ))) \
100 { \
101 free_port_mapping( dst ); \
102 return FALSE; \
103 }
104
105 COPY_BSTR_CHECK( external_ip );
109#undef COPY_BSTR_CHECK
110
111 dst->external = src->external;
112 dst->internal = src->internal;
113 dst->enabled = src->enabled;
114 return TRUE;
115}
#define TRUE
Definition: types.h:120
#define COPY_BSTR_CHECK(name)
const char * descr
Definition: boot.c:45
#define memset(x, y, z)
Definition: compat.h:39

Referenced by find_port_mapping(), and get_port_mapping_range().

◆ create_port_mapping_enum()

static HRESULT create_port_mapping_enum ( IUnknown **  ret)
static

Definition at line 1307 of file port.c.

1308{
1309 struct port_mapping_enum *mapping_enum;
1310
1311 if (!(mapping_enum = calloc( 1, sizeof(*mapping_enum) ))) return E_OUTOFMEMORY;
1312
1314
1315 mapping_enum->refs = 1;
1316 mapping_enum->IEnumVARIANT_iface.lpVtbl = &port_mapping_enum_vtbl;
1317 mapping_enum->index = 0;
1318 *ret = (IUnknown *)&mapping_enum->IEnumVARIANT_iface;
1319 return S_OK;
1320}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static const IEnumVARIANTVtbl port_mapping_enum_vtbl
Definition: port.c:1296
static BOOL grab_gateway_connection(void)
Definition: port.c:794
#define S_OK
Definition: intsafe.h:52
#define calloc
Definition: rosglue.h:14
IEnumVARIANT IEnumVARIANT_iface
Definition: port.c:1166
unsigned int index
Definition: port.c:1168

Referenced by port_mapping_enum_Clone(), and static_ports__NewEnum().

◆ find_port_mapping()

static BOOL find_port_mapping ( LONG  port,
BSTR  protocol,
struct port_mapping *  ret 
)
static

Definition at line 817 of file port.c.

818{
819 unsigned int i;
820 BOOL found;
821
823 for (i = 0; i < upnp_gateway_connection.mapping_count; ++i)
824 {
825 if (upnp_gateway_connection.mappings[i].external == port
826 && !wcscmp( upnp_gateway_connection.mappings[i].protocol, protocol ))
827 break;
828 }
829 found = i < upnp_gateway_connection.mapping_count;
830 if (found) copy_port_mapping( ret, &upnp_gateway_connection.mappings[i] );
832 return found;
833}
static BOOL copy_port_mapping(struct port_mapping *dst, const struct port_mapping *src)
Definition: port.c:95
static struct @525 upnp_gateway_connection
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1977
USHORT port
Definition: uri.c:210
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by static_ports_get_Item().

◆ free_mappings()

static void free_mappings ( void  )
static

Definition at line 84 of file port.c.

85{
86 unsigned int i;
87
88 for (i = 0; i < upnp_gateway_connection.mapping_count; ++i)
90 free( upnp_gateway_connection.mappings );
92 upnp_gateway_connection.mapping_count = 0;
93}
#define free
Definition: debug_ros.c:5
static void free_port_mapping(struct port_mapping *mapping)
Definition: port.c:76

Referenced by gateway_connection_cleanup(), and update_mapping_list().

◆ free_port_mapping()

static void free_port_mapping ( struct port_mapping *  mapping)
static

Definition at line 76 of file port.c.

77{
78 SysFreeString( mapping->external_ip );
79 SysFreeString( mapping->protocol );
80 SysFreeString( mapping->client );
81 SysFreeString( mapping->descr );
82}
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031

Referenced by free_mappings(), port_mapping_enum_Next(), static_port_mapping_Release(), static_ports_Add(), and static_ports_get_Item().

◆ fw_port_AddRef()

static ULONG WINAPI fw_port_AddRef ( INetFwOpenPort *  iface)
static

Definition at line 1606 of file port.c.

1608{
1610 return InterlockedIncrement( &fw_port->refs );
1611}
#define InterlockedIncrement
Definition: armddk.h:53
static fw_port * impl_from_INetFwOpenPort(INetFwOpenPort *iface)
Definition: port.c:1601
Definition: port.c:1593
LONG refs
Definition: port.c:1595

◆ fw_port_get_BuiltIn()

static HRESULT WINAPI fw_port_get_BuiltIn ( INetFwOpenPort *  iface,
VARIANT_BOOL *  builtIn 
)
static

Definition at line 1879 of file port.c.

1882{
1884
1885 FIXME("%p %p\n", This, builtIn);
1886 return E_NOTIMPL;
1887}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ fw_port_get_Enabled()

static HRESULT WINAPI fw_port_get_Enabled ( INetFwOpenPort *  iface,
VARIANT_BOOL *  enabled 
)
static

Definition at line 1857 of file port.c.

1860{
1862
1863 FIXME("%p %p\n", This, enabled);
1864
1865 *enabled = VARIANT_TRUE;
1866 return S_OK;
1867}

◆ fw_port_get_IpVersion()

static HRESULT WINAPI fw_port_get_IpVersion ( INetFwOpenPort *  iface,
NET_FW_IP_VERSION *  ipVersion 
)
static

Definition at line 1751 of file port.c.

1754{
1756
1757 FIXME("%p %p\n", This, ipVersion);
1758 return E_NOTIMPL;
1759}

◆ fw_port_get_Name()

static HRESULT WINAPI fw_port_get_Name ( INetFwOpenPort *  iface,
BSTR *  name 
)
static

Definition at line 1725 of file port.c.

1728{
1730
1731 FIXME("%p %p\n", This, name);
1732 return E_NOTIMPL;
1733}
Definition: name.c:39

◆ fw_port_get_Port()

static HRESULT WINAPI fw_port_get_Port ( INetFwOpenPort *  iface,
LONG *  portNumber 
)
static

Definition at line 1796 of file port.c.

1799{
1801
1802 FIXME("%p %p\n", This, portNumber);
1803 return E_NOTIMPL;
1804}

◆ fw_port_get_Protocol()

static HRESULT WINAPI fw_port_get_Protocol ( INetFwOpenPort *  iface,
NET_FW_IP_PROTOCOL *  ipProtocol 
)
static

Definition at line 1771 of file port.c.

1774{
1776
1777 FIXME("%p %p\n", This, ipProtocol);
1778 return E_NOTIMPL;
1779}

◆ fw_port_get_RemoteAddresses()

static HRESULT WINAPI fw_port_get_RemoteAddresses ( INetFwOpenPort *  iface,
BSTR *  remoteAddrs 
)
static

Definition at line 1837 of file port.c.

1840{
1842
1843 FIXME("%p %p\n", This, remoteAddrs);
1844 return E_NOTIMPL;
1845}

◆ fw_port_get_Scope()

static HRESULT WINAPI fw_port_get_Scope ( INetFwOpenPort *  iface,
NET_FW_SCOPE *  scope 
)
static

Definition at line 1817 of file port.c.

1820{
1822
1823 FIXME("%p %p\n", This, scope);
1824 return E_NOTIMPL;
1825}

◆ fw_port_GetIDsOfNames()

static HRESULT WINAPI fw_port_GetIDsOfNames ( INetFwOpenPort *  iface,
REFIID  riid,
LPOLESTR *  rgszNames,
UINT  cNames,
LCID  lcid,
DISPID *  rgDispId 
)
static

Definition at line 1674 of file port.c.

1681{
1684 HRESULT hr;
1685
1686 TRACE("%p %s %p %u %lu %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
1687
1689 if (SUCCEEDED(hr))
1690 {
1691 hr = ITypeInfo_GetIDsOfNames( typeinfo, rgszNames, cNames, rgDispId );
1692 ITypeInfo_Release( typeinfo );
1693 }
1694 return hr;
1695}
HRESULT get_typeinfo(enum type_id tid, ITypeInfo **ret)
Definition: apps.c:125
HRESULT hr
Definition: delayimp.cpp:582
LCID lcid
Definition: locale.c:5660
@ INetFwOpenPort_tid
REFIID riid
Definition: atlbase.h:39
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4

◆ fw_port_GetTypeInfo()

static HRESULT WINAPI fw_port_GetTypeInfo ( INetFwOpenPort *  iface,
UINT  iTInfo,
LCID  lcid,
ITypeInfo **  ppTInfo 
)
static

Definition at line 1662 of file port.c.

1667{
1669
1670 TRACE("%p %u %lu %p\n", This, iTInfo, lcid, ppTInfo);
1671 return get_typeinfo( INetFwOpenPort_tid, ppTInfo );
1672}

◆ fw_port_GetTypeInfoCount()

static HRESULT WINAPI fw_port_GetTypeInfoCount ( INetFwOpenPort *  iface,
UINT *  pctinfo 
)
static

Definition at line 1651 of file port.c.

1654{
1656
1657 TRACE("%p %p\n", This, pctinfo);
1658 *pctinfo = 1;
1659 return S_OK;
1660}

◆ fw_port_Invoke()

static HRESULT WINAPI fw_port_Invoke ( INetFwOpenPort *  iface,
DISPID  dispIdMember,
REFIID  riid,
LCID  lcid,
WORD  wFlags,
DISPPARAMS *  pDispParams,
VARIANT *  pVarResult,
EXCEPINFO *  pExcepInfo,
UINT *  puArgErr 
)
static

Definition at line 1697 of file port.c.

1707{
1710 HRESULT hr;
1711
1712 TRACE("%p %ld %s %ld %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
1713 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1714
1716 if (SUCCEEDED(hr))
1717 {
1718 hr = ITypeInfo_Invoke( typeinfo, &This->INetFwOpenPort_iface, dispIdMember,
1719 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr );
1720 ITypeInfo_Release( typeinfo );
1721 }
1722 return hr;
1723}
WINBASEAPI _In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon_undoc.h:337

◆ fw_port_put_Enabled()

static HRESULT WINAPI fw_port_put_Enabled ( INetFwOpenPort *  iface,
VARIANT_BOOL  enabled 
)
static

Definition at line 1869 of file port.c.

1872{
1874
1875 FIXME("%p %d\n", This, enabled);
1876 return S_OK;
1877}

◆ fw_port_put_IpVersion()

static HRESULT WINAPI fw_port_put_IpVersion ( INetFwOpenPort *  iface,
NET_FW_IP_VERSION  ipVersion 
)
static

Definition at line 1761 of file port.c.

1764{
1766
1767 FIXME("%p %u\n", This, ipVersion);
1768 return E_NOTIMPL;
1769}

◆ fw_port_put_Name()

static HRESULT WINAPI fw_port_put_Name ( INetFwOpenPort *  iface,
BSTR  name 
)
static

Definition at line 1735 of file port.c.

1738{
1740
1741 TRACE("%p %s\n", This, debugstr_w(name));
1742
1743 if (!(name = SysAllocString( name )))
1744 return E_OUTOFMEMORY;
1745
1746 SysFreeString( This->name );
1747 This->name = name;
1748 return S_OK;
1749}

◆ fw_port_put_Port()

static HRESULT WINAPI fw_port_put_Port ( INetFwOpenPort *  iface,
LONG  portNumber 
)
static

Definition at line 1806 of file port.c.

1809{
1811
1812 TRACE("%p %ld\n", This, portNumber);
1813 This->port = portNumber;
1814 return S_OK;
1815}

◆ fw_port_put_Protocol()

static HRESULT WINAPI fw_port_put_Protocol ( INetFwOpenPort *  iface,
NET_FW_IP_PROTOCOL  ipProtocol 
)
static

Definition at line 1781 of file port.c.

1784{
1786
1787 TRACE("%p %u\n", This, ipProtocol);
1788
1789 if (ipProtocol != NET_FW_IP_PROTOCOL_TCP && ipProtocol != NET_FW_IP_PROTOCOL_UDP)
1790 return E_INVALIDARG;
1791
1792 This->protocol = ipProtocol;
1793 return S_OK;
1794}
#define E_INVALIDARG
Definition: ddrawi.h:101
@ NET_FW_IP_PROTOCOL_TCP
Definition: icftypes.idl:75
@ NET_FW_IP_PROTOCOL_UDP
Definition: icftypes.idl:76

◆ fw_port_put_RemoteAddresses()

static HRESULT WINAPI fw_port_put_RemoteAddresses ( INetFwOpenPort *  iface,
BSTR  remoteAddrs 
)
static

Definition at line 1847 of file port.c.

1850{
1852
1853 FIXME("%p %s\n", This, debugstr_w(remoteAddrs));
1854 return E_NOTIMPL;
1855}

◆ fw_port_put_Scope()

static HRESULT WINAPI fw_port_put_Scope ( INetFwOpenPort *  iface,
NET_FW_SCOPE  scope 
)
static

Definition at line 1827 of file port.c.

1830{
1832
1833 FIXME("%p %u\n", This, scope);
1834 return E_NOTIMPL;
1835}

◆ fw_port_QueryInterface()

static HRESULT WINAPI fw_port_QueryInterface ( INetFwOpenPort *  iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 1627 of file port.c.

1631{
1633
1634 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
1635
1636 if ( IsEqualGUID( riid, &IID_INetFwOpenPort ) ||
1639 {
1640 *ppvObject = iface;
1641 }
1642 else
1643 {
1644 FIXME("interface %s not implemented\n", debugstr_guid(riid));
1645 return E_NOINTERFACE;
1646 }
1647 INetFwOpenPort_AddRef( iface );
1648 return S_OK;
1649}
const GUID IID_IUnknown
const GUID IID_IDispatch
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ fw_port_Release()

static ULONG WINAPI fw_port_Release ( INetFwOpenPort *  iface)
static

Definition at line 1613 of file port.c.

1615{
1618 if (!refs)
1619 {
1620 TRACE("destroying %p\n", fw_port);
1622 free( fw_port );
1623 }
1624 return refs;
1625}
#define InterlockedDecrement
Definition: armddk.h:52
LONG refs
Definition: port.c:62
long LONG
Definition: pedump.c:60
BSTR name
Definition: port.c:1596

◆ fw_ports_Add()

static HRESULT WINAPI fw_ports_Add ( INetFwOpenPorts *  iface,
INetFwOpenPort *  port 
)
static

Definition at line 2077 of file port.c.

2080{
2082
2083 FIXME("%p, %p\n", This, port);
2084 return S_OK;
2085}
static fw_ports * impl_from_INetFwOpenPorts(INetFwOpenPorts *iface)
Definition: port.c:1942

◆ fw_ports_AddRef()

static ULONG WINAPI fw_ports_AddRef ( INetFwOpenPorts *  iface)
static

Definition at line 1947 of file port.c.

1949{
1952}
LONG refs
Definition: port.c:1939

◆ fw_ports_get__NewEnum()

static HRESULT WINAPI fw_ports_get__NewEnum ( INetFwOpenPorts *  iface,
IUnknown **  newEnum 
)
static

Definition at line 2118 of file port.c.

2121{
2123
2124 FIXME("%p, %p\n", This, newEnum);
2125 return E_NOTIMPL;
2126}

◆ fw_ports_get_Count()

static HRESULT WINAPI fw_ports_get_Count ( INetFwOpenPorts *  iface,
LONG *  count 
)
static

Definition at line 2065 of file port.c.

2068{
2070
2071 FIXME("%p, %p\n", This, count);
2072
2073 *count = 0;
2074 return S_OK;
2075}
GLuint GLuint GLsizei count
Definition: gl.h:1545

◆ fw_ports_GetIDsOfNames()

static HRESULT WINAPI fw_ports_GetIDsOfNames ( INetFwOpenPorts *  iface,
REFIID  riid,
LPOLESTR *  rgszNames,
UINT  cNames,
LCID  lcid,
DISPID *  rgDispId 
)
static

Definition at line 2014 of file port.c.

2021{
2024 HRESULT hr;
2025
2026 TRACE("%p %s %p %u %lu %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
2027
2029 if (SUCCEEDED(hr))
2030 {
2031 hr = ITypeInfo_GetIDsOfNames( typeinfo, rgszNames, cNames, rgDispId );
2032 ITypeInfo_Release( typeinfo );
2033 }
2034 return hr;
2035}
@ INetFwOpenPorts_tid

◆ fw_ports_GetTypeInfo()

static HRESULT WINAPI fw_ports_GetTypeInfo ( INetFwOpenPorts *  iface,
UINT  iTInfo,
LCID  lcid,
ITypeInfo **  ppTInfo 
)
static

Definition at line 2002 of file port.c.

2007{
2009
2010 TRACE("%p %u %lu %p\n", This, iTInfo, lcid, ppTInfo);
2011 return get_typeinfo( INetFwOpenPorts_tid, ppTInfo );
2012}

◆ fw_ports_GetTypeInfoCount()

static HRESULT WINAPI fw_ports_GetTypeInfoCount ( INetFwOpenPorts *  iface,
UINT *  pctinfo 
)
static

Definition at line 1991 of file port.c.

1994{
1996
1997 TRACE("%p %p\n", This, pctinfo);
1998 *pctinfo = 1;
1999 return S_OK;
2000}

◆ fw_ports_Invoke()

static HRESULT WINAPI fw_ports_Invoke ( INetFwOpenPorts *  iface,
DISPID  dispIdMember,
REFIID  riid,
LCID  lcid,
WORD  wFlags,
DISPPARAMS *  pDispParams,
VARIANT *  pVarResult,
EXCEPINFO *  pExcepInfo,
UINT *  puArgErr 
)
static

Definition at line 2037 of file port.c.

2047{
2050 HRESULT hr;
2051
2052 TRACE("%p %ld %s %ld %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
2053 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2054
2056 if (SUCCEEDED(hr))
2057 {
2058 hr = ITypeInfo_Invoke( typeinfo, &This->INetFwOpenPorts_iface, dispIdMember,
2059 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr );
2060 ITypeInfo_Release( typeinfo );
2061 }
2062 return hr;
2063}

◆ fw_ports_Item()

static HRESULT WINAPI fw_ports_Item ( INetFwOpenPorts *  iface,
LONG  portNumber,
NET_FW_IP_PROTOCOL  ipProtocol,
INetFwOpenPort **  openPort 
)
static

Definition at line 2098 of file port.c.

2103{
2104 HRESULT hr;
2106
2107 FIXME("%p, %ld, %u, %p\n", This, portNumber, ipProtocol, openPort);
2108
2109 hr = NetFwOpenPort_create( NULL, (void **)openPort );
2110 if (SUCCEEDED(hr))
2111 {
2112 INetFwOpenPort_put_Protocol( *openPort, ipProtocol );
2113 INetFwOpenPort_put_Port( *openPort, portNumber );
2114 }
2115 return hr;
2116}
HRESULT NetFwOpenPort_create(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: port.c:1915

◆ fw_ports_QueryInterface()

static HRESULT WINAPI fw_ports_QueryInterface ( INetFwOpenPorts *  iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 1967 of file port.c.

1971{
1973
1974 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
1975
1976 if ( IsEqualGUID( riid, &IID_INetFwOpenPorts ) ||
1979 {
1980 *ppvObject = iface;
1981 }
1982 else
1983 {
1984 FIXME("interface %s not implemented\n", debugstr_guid(riid));
1985 return E_NOINTERFACE;
1986 }
1987 INetFwOpenPorts_AddRef( iface );
1988 return S_OK;
1989}

◆ fw_ports_Release()

static ULONG WINAPI fw_ports_Release ( INetFwOpenPorts *  iface)
static

Definition at line 1954 of file port.c.

1956{
1959 if (!refs)
1960 {
1961 TRACE("destroying %p\n", fw_ports);
1962 free( fw_ports );
1963 }
1964 return refs;
1965}

◆ fw_ports_Remove()

static HRESULT WINAPI fw_ports_Remove ( INetFwOpenPorts *  iface,
LONG  portNumber,
NET_FW_IP_PROTOCOL  ipProtocol 
)
static

Definition at line 2087 of file port.c.

2091{
2093
2094 FIXME("%p, %ld, %u\n", This, portNumber, ipProtocol);
2095 return E_NOTIMPL;
2096}

◆ gateway_connection_cleanup()

static void gateway_connection_cleanup ( void  )
static

Definition at line 391 of file port.c.

392{
393 TRACE( ".\n" );
397 if (upnp_gateway_connection.winsock_initialized) WSACleanup();
399}
static void free_mappings(void)
Definition: port.c:84
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1358
int PASCAL FAR WSACleanup(void)
Definition: startup.c:60

Referenced by grab_gateway_connection(), init_gateway_connection(), and release_gateway_connection().

◆ get_control_url()

static BOOL get_control_url ( void  )
static

Definition at line 328 of file port.c.

329{
330 static const WCHAR *accept_types[] =
331 {
332 L"text/xml",
333 NULL
334 };
335 unsigned int desc_xml_size, offset;
336 DWORD size, status = 0;
338 char *desc_xml;
339 BOOL ret;
340
342 WINHTTP_NO_REFERER, accept_types, 0 );
343 if (!request) return FALSE;
344
346 {
347 WARN( "Error sending request %lu.\n", GetLastError() );
349 return FALSE;
350 }
352 {
353 WARN( "Error receiving response %lu.\n", GetLastError() );
355 return FALSE;
356 }
357 size = sizeof(status);
360 {
361 WARN( "Error response from server, error %lu, http status %lu.\n", GetLastError(), status );
363 return FALSE;
364 }
365 desc_xml_size = 1024;
366 desc_xml = malloc( desc_xml_size );
367 offset = 0;
368 while (WinHttpReadData( request, desc_xml + offset, desc_xml_size - offset - 1, &size ) && size)
369 {
370 offset += size;
371 if (offset + 1 == desc_xml_size)
372 {
373 char *new;
374
375 desc_xml_size *= 2;
376 if (!(new = realloc( desc_xml, desc_xml_size )))
377 {
378 ERR( "No memory.\n" );
379 break;
380 }
381 desc_xml = new;
382 }
383 }
384 desc_xml[offset] = 0;
386 ret = parse_desc_xml( desc_xml );
387 free( desc_xml );
388 return ret;
389}
#define ERR(fmt,...)
Definition: precomp.h:57
#define realloc
Definition: debug_ros.c:6
#define malloc
Definition: debug_ros.c:4
static BOOL parse_desc_xml(const char *desc_xml)
Definition: port.c:154
HINTERNET WINAPI WinHttpOpenRequest(HINTERNET hconnect, const WCHAR *verb, const WCHAR *object, const WCHAR *version, const WCHAR *referrer, const WCHAR **types, DWORD flags)
Definition: session.c:1277
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
BOOL WINAPI WinHttpQueryHeaders(HINTERNET hrequest, DWORD level, const WCHAR *name, void *buffer, DWORD *buflen, DWORD *index)
Definition: request.c:814
BOOL WINAPI WinHttpReadData(HINTERNET hrequest, void *buffer, DWORD to_read, DWORD *read)
Definition: request.c:3252
BOOL WINAPI WinHttpSendRequest(HINTERNET hrequest, const WCHAR *headers, DWORD headers_len, void *optional, DWORD optional_len, DWORD total_len, DWORD_PTR context)
Definition: request.c:2397
BOOL WINAPI WinHttpReceiveResponse(HINTERNET hrequest, LPVOID reserved)
Definition: request.c:3068
Definition: tftpd.h:86
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define WINHTTP_NO_ADDITIONAL_HEADERS
Definition: winhttp.h:229
#define WINHTTP_QUERY_STATUS_CODE
Definition: winhttp.h:379
#define WINHTTP_QUERY_FLAG_NUMBER
Definition: winhttp.h:439
#define WINHTTP_NO_REFERER
Definition: winhttp.h:225

Referenced by init_gateway_connection().

◆ get_port_mapping_count()

static unsigned int get_port_mapping_count ( void  )
static

Definition at line 851 of file port.c.

852{
853 unsigned int ret;
854
856 ret = upnp_gateway_connection.mapping_count;
858 return ret;
859}

Referenced by port_mapping_enum_Skip(), and static_ports_get_Count().

◆ get_port_mapping_range()

static unsigned int get_port_mapping_range ( unsigned int  index,
unsigned int  count,
struct port_mapping *  ret 
)
static

Definition at line 835 of file port.c.

836{
837 unsigned int i;
838
840 for (i = 0; i < count && index + i < upnp_gateway_connection.mapping_count; ++i)
841 if (!copy_port_mapping( &ret[i], &upnp_gateway_connection.mappings[index + i] ))
842 {
843 ERR( "No memory.\n" );
844 break;
845 }
847
848 return i;
849}
GLuint index
Definition: glext.h:6031

Referenced by port_mapping_enum_Next().

◆ get_xml_elements()

static BOOL get_xml_elements ( const char *  desc_xml,
struct xml_value_desc *  values,
unsigned int  value_count 
)
static

Definition at line 234 of file port.c.

235{
236 XmlNodeType node_type;
238 const WCHAR *value;
239 BOOL ret = FALSE;
241 unsigned int i;
242 HRESULT hr;
243
244 for (i = 0; i < value_count; ++i) assert( !values[i].value );
245
246 if (!(stream = SHCreateMemStream( (BYTE *)desc_xml, strlen( desc_xml ) + 1 ))) return FALSE;
247 if (FAILED(hr = CreateXmlReader( &IID_IXmlReader, (void **)&reader, NULL )))
248 {
249 IStream_Release( stream );
250 return FALSE;
251 }
252 if (FAILED(hr = IXmlReader_SetInput( reader, (IUnknown*)stream ))) goto done;
253
254 while (SUCCEEDED(IXmlReader_Read( reader, &node_type )) && node_type != XmlNodeType_None)
255 {
256 if (node_type != XmlNodeType_Element) continue;
257
258 if (FAILED(IXmlReader_GetQualifiedName( reader, &value, NULL ))) goto done;
259 for (i = 0; i < value_count; ++i)
260 if (!wcsicmp( value, values[i].name )) break;
261 if (i == value_count) continue;
262 if (FAILED(IXmlReader_Read(reader, &node_type ))) goto done;
263 if (node_type != XmlNodeType_Text)
264 {
265 if (node_type == XmlNodeType_EndElement) value = L"";
266 else goto done;
267 }
268 else
269 {
270 if (FAILED(IXmlReader_GetValue( reader, &value, NULL ))) goto done;
271 }
272 if (values[i].value)
273 {
274 WARN( "Duplicate value %s.\n", debugstr_w(values[i].name) );
275 goto done;
276 }
277 if (!(values[i].value = SysAllocString( value ))) goto done;
278 }
279 ret = TRUE;
280
281done:
282 if (!ret)
283 {
284 for (i = 0; i < value_count; ++i)
285 {
287 values[i].value = NULL;
288 }
289 }
290 IXmlReader_Release( reader );
291 IStream_Release( stream );
292 return ret;
293}
#define wcsicmp
Definition: compat.h:15
#define assert(_expr)
Definition: assert.h:32
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
IStream *WINAPI SHCreateMemStream(const BYTE *data, UINT data_len)
Definition: main.c:873
HRESULT WINAPI CreateXmlReader(REFIID riid, void **obj, IMalloc *imalloc)
Definition: reader.c:3616
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666
#define FAILED(hr)
Definition: intsafe.h:51
Definition: reader.h:84
Definition: parse.h:23
XmlNodeType
Definition: xmllite.idl:23
@ XmlNodeType_EndElement
Definition: xmllite.idl:33
@ XmlNodeType_None
Definition: xmllite.idl:24
@ XmlNodeType_Element
Definition: xmllite.idl:25
@ XmlNodeType_Text
Definition: xmllite.idl:27
unsigned char BYTE
Definition: xxhash.c:193

Referenced by request_service().

◆ grab_gateway_connection()

static BOOL grab_gateway_connection ( void  )
static

Definition at line 794 of file port.c.

795{
798 {
801 return FALSE;
802 }
805 return TRUE;
806}
static void gateway_connection_cleanup(void)
Definition: port.c:391
static BOOL init_gateway_connection(void)
Definition: port.c:702

Referenced by create_port_mapping_enum(), and static_port_mapping_collection_create().

◆ impl_from_IEnumVARIANT()

static struct port_mapping_enum * impl_from_IEnumVARIANT ( IEnumVARIANT *  iface)
inlinestatic

Definition at line 1171 of file port.c.

1172{
1173 return CONTAINING_RECORD(iface, struct port_mapping_enum, IEnumVARIANT_iface);
1174}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by port_mapping_enum_AddRef(), port_mapping_enum_Clone(), port_mapping_enum_Next(), port_mapping_enum_QueryInterface(), port_mapping_enum_Release(), port_mapping_enum_Reset(), and port_mapping_enum_Skip().

◆ impl_from_INetFwOpenPort()

◆ impl_from_INetFwOpenPorts()

◆ impl_from_IStaticPortMapping()

◆ impl_from_IStaticPortMappingCollection()

static struct static_port_mapping_collection * impl_from_IStaticPortMappingCollection ( IStaticPortMappingCollection *  iface)
inlinestatic

◆ impl_from_IUPnPNAT()

◆ init_gateway_connection()

static BOOL init_gateway_connection ( void  )
static

Definition at line 702 of file port.c.

703{
704 static const char upnp_search_request[] =
705 "M-SEARCH * HTTP/1.1\r\n"
706 "HOST:239.255.255.250:1900\r\n"
707 "ST:upnp:rootdevice\r\n"
708 "MX:2\r\n"
709 "MAN:\"ssdp:discover\"\r\n"
710 "\r\n";
711
712 const DWORD timeout = 1000;
713 int len, address_len;
714 char buffer[2048];
716 WSADATA wsa_data;
717 unsigned int i;
718 SOCKET s;
719
720 upnp_gateway_connection.winsock_initialized = WSAStartup( MAKEWORD( 2, 2 ), &wsa_data );
721 if ((s = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP )) == -1)
722 {
723 ERR( "Failed to create socket, error %u.\n", WSAGetLastError() );
724 return FALSE;
725 }
726 if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (const char *)&timeout, sizeof(timeout)) == SOCKET_ERROR)
727 {
728 ERR( "setsockopt(SO_RCVTIME0) failed, error %u.\n", WSAGetLastError() );
729 closesocket( s );
730 return FALSE;
731 }
732 addr.sin_family = AF_INET;
733 addr.sin_port = htons( 1900 );
734 addr.sin_addr.S_un.S_addr = inet_addr( "239.255.255.250" );
735 if (sendto( s, upnp_search_request, strlen( upnp_search_request ), 0, (SOCKADDR *)&addr, sizeof(addr) )
736 == SOCKET_ERROR)
737 {
738 ERR( "sendto failed, error %u\n", WSAGetLastError() );
739 closesocket( s );
740 return FALSE;
741 }
742 /* Windows has a dedicated SSDP discovery service which maintains gateway device info and does
743 * not usually delay in get_StaticPortMappingCollection(). Although it may still delay depending
744 * on network connection state and always delays in IUPnPNAT_get_NATEventManager(). */
745 FIXME( "Waiting for reply from router.\n" );
746 for (i = 0; i < 2; ++i)
747 {
748 address_len = sizeof(addr);
749 len = recvfrom( s, buffer, sizeof(buffer) - 1, 0, (SOCKADDR *)&addr, &address_len );
750 if (len == -1)
751 {
753 {
754 WARN( "recvfrom error %u.\n", WSAGetLastError() );
755 closesocket( s );
756 return FALSE;
757 }
758 }
759 else break;
760 }
761 closesocket( s );
762 if (i == 2)
763 {
764 TRACE( "No reply from router.\n" );
765 return FALSE;
766 }
767 TRACE( "Received reply from gateway, len %d.\n", len );
768 buffer[len] = 0;
770 {
771 WARN( "Error parsing response.\n" );
772 return FALSE;
773 }
774 TRACE( "Gateway description location %s.\n", debugstr_w(upnp_gateway_connection.locationW) );
776 {
777 WARN( "Error opening gateway connection.\n" );
778 return FALSE;
779 }
780 TRACE( "Opened gateway connection.\n" );
781 if (!get_control_url())
782 {
783 WARN( "Could not get_control URL.\n" );
785 return FALSE;
786 }
787 TRACE( "control_url %s, version %u.\n", debugstr_w(upnp_gateway_connection.control_url),
788 upnp_gateway_connection.version );
789
791 return TRUE;
792}
static BOOL open_gateway_connection(void)
Definition: port.c:295
static BOOL get_control_url(void)
Definition: port.c:328
static BOOL parse_search_response(char *response, WCHAR *locationW, unsigned int location_size)
Definition: port.c:117
INT WSAAPI recvfrom(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags, OUT LPSOCKADDR from, IN OUT INT FAR *fromlen)
Definition: recv.c:87
INT WSAAPI sendto(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags, IN CONST struct sockaddr *to, IN INT tolen)
Definition: send.c:82
#define IPPROTO_UDP
Definition: ip.h:198
#define AF_INET
Definition: tcpip.h:117
GLdouble s
Definition: gl.h:2039
GLuint buffer
Definition: glext.h:5915
GLenum const GLvoid * addr
Definition: glext.h:9621
GLenum GLsizei len
Definition: glext.h:6722
#define htons(x)
Definition: module.h:215
#define closesocket
Definition: ncftp.h:477
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
Definition: sockctrl.c:421
Definition: dhcpd.h:248
#define MAKEWORD(a, b)
Definition: typedefs.h:248
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
u_long WINAPI inet_addr(const char *str)
Definition: wine.c:35
#define WSAETIMEDOUT
Definition: winerror.h:2876
int PASCAL FAR WSAGetLastError(void)
Definition: dllmain.c:131
#define SOCK_DGRAM
Definition: winsock.h:330
UINT_PTR SOCKET
Definition: winsock.h:41
#define SOCKET_ERROR
Definition: winsock.h:327
#define SOL_SOCKET
Definition: winsock.h:392
#define SO_RCVTIMEO
Definition: winsock.h:187

Referenced by grab_gateway_connection().

◆ is_valid_protocol()

static BOOL is_valid_protocol ( BSTR  protocol)
static

Definition at line 861 of file port.c.

862{
863 if (!protocol) return FALSE;
864 return !wcscmp( protocol, L"UDP" ) || !wcscmp( protocol, L"TCP" );
865}

Referenced by static_ports_Add(), static_ports_get_Item(), and static_ports_Remove().

◆ IUPnPNAT_create()

HRESULT IUPnPNAT_create ( IUnknown *  outer,
void **  object 
)

Definition at line 2314 of file port.c.

2315{
2316 upnpnat *nat;
2317
2318 TRACE("(%p,%p)\n", outer, object);
2319
2320 nat = malloc( sizeof(*nat) );
2321 if (!nat) return E_OUTOFMEMORY;
2322
2323 nat->IUPnPNAT_iface.lpVtbl = &upnpnat_vtbl;
2324 nat->ref = 1;
2325
2326 *object = &nat->IUPnPNAT_iface;
2327
2328 TRACE("returning iface %p\n", *object);
2329 return S_OK;
2330}
static const IUPnPNATVtbl upnpnat_vtbl
Definition: port.c:2299
static IUnknown * outer
Definition: compobj.c:82
LONG ref
Definition: port.c:2165
IUPnPNAT IUPnPNAT_iface
Definition: port.c:2164

◆ long_from_bstr()

static LONG long_from_bstr ( BSTR  s)
static

Definition at line 537 of file port.c.

538{
539 if (!s) return 0;
540 return _wtoi( s );
541}
_ACRTIMP int __cdecl _wtoi(const wchar_t *)
Definition: wcs.c:2778

Referenced by update_mapping_list().

◆ mapping_move_bstr()

static BSTR mapping_move_bstr ( BSTR *  s)
static

Definition at line 543 of file port.c.

544{
545 BSTR ret;
546
547 if (*s)
548 {
549 ret = *s;
550 *s = NULL;
551 }
552 else if (!(ret = SysAllocString( L"" )))
553 {
554 ERR( "No memory.\n" );
555 }
556 return ret;
557}

Referenced by update_mapping_list().

◆ NetFwOpenPort_create()

HRESULT NetFwOpenPort_create ( IUnknown *  pUnkOuter,
LPVOID *  ppObj 
)

Definition at line 1915 of file port.c.

1916{
1917 fw_port *fp;
1918
1919 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
1920
1921 fp = malloc( sizeof(*fp) );
1922 if (!fp) return E_OUTOFMEMORY;
1923
1924 fp->INetFwOpenPort_iface.lpVtbl = &fw_port_vtbl;
1925 fp->refs = 1;
1926 fp->name = NULL;
1928 fp->port = 0;
1929
1930 *ppObj = &fp->INetFwOpenPort_iface;
1931
1932 TRACE("returning iface %p\n", *ppObj);
1933 return S_OK;
1934}
static const struct INetFwOpenPortVtbl fw_port_vtbl
Definition: port.c:1889
INetFwOpenPort INetFwOpenPort_iface
Definition: port.c:1594
LONG port
Definition: port.c:1598
NET_FW_IP_PROTOCOL protocol
Definition: port.c:1597

Referenced by fw_ports_Item().

◆ NetFwOpenPorts_create()

HRESULT NetFwOpenPorts_create ( IUnknown *  pUnkOuter,
LPVOID *  ppObj 
)

Definition at line 2144 of file port.c.

2145{
2146 fw_ports *fp;
2147
2148 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
2149
2150 fp = malloc( sizeof(*fp) );
2151 if (!fp) return E_OUTOFMEMORY;
2152
2154 fp->refs = 1;
2155
2156 *ppObj = &fp->INetFwOpenPorts_iface;
2157
2158 TRACE("returning iface %p\n", *ppObj);
2159 return S_OK;
2160}
static const struct INetFwOpenPortsVtbl fw_ports_vtbl
Definition: port.c:2128
INetFwOpenPorts INetFwOpenPorts_iface
Definition: port.c:1938

Referenced by fw_profile_get_GloballyOpenPorts(), and fw_service_get_GloballyOpenPorts().

◆ open_gateway_connection()

static BOOL open_gateway_connection ( void  )
static

Definition at line 295 of file port.c.

296{
297 static const int timeout = 3000;
298
299 WCHAR hostname[64];
301
302 memset( &url, 0, sizeof(url) );
303 url.dwStructSize = sizeof(url);
304 url.lpszHostName = hostname;
305 url.dwHostNameLength = ARRAY_SIZE(hostname);
306 url.lpszUrlPath = upnp_gateway_connection.desc_urlpath;
307 url.dwUrlPathLength = ARRAY_SIZE(upnp_gateway_connection.desc_urlpath);
308
309 if (!WinHttpCrackUrl( upnp_gateway_connection.locationW, 0, 0, &url )) return FALSE;
310
313 if (!upnp_gateway_connection.session) return FALSE;
315 return FALSE;
316
317 TRACE( "hostname %s, urlpath %s, port %u.\n",
320 if (!upnp_gateway_connection.connection)
321 {
322 WARN( "WinHttpConnect error %lu.\n", GetLastError() );
323 return FALSE;
324 }
325 return TRUE;
326}
char * hostname
Definition: ftp.c:88
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:304
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, const WCHAR *server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:594
BOOL WINAPI WinHttpSetTimeouts(HINTERNET handle, int resolve, int connect, int send, int receive)
Definition: session.c:2460
BOOL WINAPI WinHttpCrackUrl(const WCHAR *url, DWORD len, DWORD flags, URL_COMPONENTSW *uc)
Definition: url.c:173
static const WCHAR url[]
Definition: encode.c:1384
#define WINHTTP_NO_PROXY_NAME
Definition: winhttp.h:74
#define WINHTTP_ACCESS_TYPE_NO_PROXY
Definition: winhttp.h:70
#define WINHTTP_NO_PROXY_BYPASS
Definition: winhttp.h:75

Referenced by init_gateway_connection().

◆ parse_desc_xml()

static BOOL parse_desc_xml ( const char *  desc_xml)
static

Definition at line 154 of file port.c.

155{
156 static const WCHAR urn_wanipconnection[] = L"urn:schemas-upnp-org:service:WANIPConnection:";
158 BOOL service_type_matches, control_url_found, found = FALSE;
159 unsigned int version = 0;
160 XmlNodeType node_type;
162 const WCHAR *value;
163 BOOL ret = FALSE;
165 HRESULT hr;
166
167 if (!(stream = SHCreateMemStream( (BYTE *)desc_xml, strlen( desc_xml ) + 1 ))) return FALSE;
168 if (FAILED(hr = CreateXmlReader( &IID_IXmlReader, (void **)&reader, NULL )))
169 {
170 IStream_Release( stream );
171 return FALSE;
172 }
173 if (FAILED(hr = IXmlReader_SetInput( reader, (IUnknown*)stream ))) goto done;
174
175 while (SUCCEEDED(IXmlReader_Read( reader, &node_type )) && node_type != XmlNodeType_None)
176 {
177 if (node_type != XmlNodeType_Element) continue;
178
179 if (FAILED(IXmlReader_GetLocalName( reader, &value, NULL ))) goto done;
180 if (wcsicmp( value, L"service" )) continue;
181 control_url_found = service_type_matches = FALSE;
182 while (SUCCEEDED(IXmlReader_Read( reader, &node_type )))
183 {
184 if (node_type != XmlNodeType_Element && node_type != XmlNodeType_EndElement) continue;
185 if (FAILED(IXmlReader_GetLocalName( reader, &value, NULL )))
186 {
187 WARN( "IXmlReader_GetLocalName failed.\n" );
188 goto done;
189 }
190 if (node_type == XmlNodeType_EndElement)
191 {
192 if (!wcsicmp( value, L"service" )) break;
193 continue;
194 }
195 if (!wcsicmp( value, L"serviceType" ))
196 {
197 if (FAILED(IXmlReader_Read(reader, &node_type ))) goto done;
198 if (node_type != XmlNodeType_Text) goto done;
199 if (FAILED(IXmlReader_GetValue( reader, &value, NULL ))) goto done;
200 if (wcsnicmp( value, urn_wanipconnection, ARRAY_SIZE(urn_wanipconnection) - 1 )) break;
201 version = _wtoi( value + ARRAY_SIZE(urn_wanipconnection) - 1 );
202 service_type_matches = version >= 1;
203 }
204 else if (!wcsicmp( value, L"controlURL" ))
205 {
206 if (FAILED(IXmlReader_Read(reader, &node_type ))) goto done;
207 if (node_type != XmlNodeType_Text) goto done;
208 if (FAILED(IXmlReader_GetValue( reader, &value, NULL ))) goto done;
209 if (wcslen( value ) + 1 > ARRAY_SIZE(control_url)) goto done;
211 control_url_found = TRUE;
212 }
213 }
214 if (service_type_matches && control_url_found)
215 {
216 if (found)
217 {
218 FIXME( "Found another WANIPConnection service, ignoring.\n" );
219 continue;
220 }
221 found = TRUE;
224 }
225 }
226
227 ret = found;
228done:
229 IXmlReader_Release( reader );
230 IStream_Release( stream );
231 return ret;
232}
#define wcsnicmp
Definition: compat.h:14
WCHAR control_url[256]
Definition: port.c:67
unsigned int version
Definition: port.c:68
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
wcscpy

Referenced by get_control_url().

◆ parse_search_response()

static BOOL parse_search_response ( char *  response,
WCHAR *  locationW,
unsigned int  location_size 
)
static

Definition at line 117 of file port.c.

118{
119 char *saveptr = NULL, *tok, *tok2;
120 unsigned int status;
121
122 tok = strtok_s( response, "\n", &saveptr );
123 if (!tok) return FALSE;
124
125 /* HTTP/1.1 200 OK */
126 tok2 = strtok( tok, " " );
127 if (!tok2) return FALSE;
128 tok2 = strtok( NULL, " " );
129 if (!tok2) return FALSE;
130 status = atoi( tok2 );
131 if (status != HTTP_STATUS_OK)
132 {
133 WARN( "status %u.\n", status );
134 return FALSE;
135 }
136 while ((tok = strtok_s( NULL, "\n", &saveptr )))
137 {
138 tok2 = strtok( tok, " " );
139 if (!tok2) continue;
140 if (!stricmp( tok2, "LOCATION:" ))
141 {
142 tok2 = strtok( NULL, " \r" );
143 if (!tok2)
144 {
145 WARN( "Error parsing location.\n" );
146 return FALSE;
147 }
148 return !!MultiByteToWideChar( CP_UTF8, 0, tok2, -1, locationW, location_size / 2 );
149 }
150 }
151 return FALSE;
152}
#define stricmp(_String1, _String2)
Definition: compat.h:24
#define MultiByteToWideChar
Definition: compat.h:110
WCHAR locationW[256]
Definition: port.c:64
_ACRTIMP int __cdecl atoi(const char *)
Definition: string.c:1720
_ACRTIMP char *__cdecl strtok_s(char *, const char *, char **)
Definition: string.c:314
_ACRTIMP char *__cdecl strtok(char *, const char *)
Definition: string.c:290
#define CP_UTF8
Definition: nls.h:20

Referenced by init_gateway_connection().

◆ port_mapping_enum_AddRef()

static ULONG WINAPI port_mapping_enum_AddRef ( IEnumVARIANT *  iface)
static

Definition at line 1176 of file port.c.

1178{
1179 struct port_mapping_enum *mapping_enum = impl_from_IEnumVARIANT( iface );
1180 return InterlockedIncrement( &mapping_enum->refs );
1181}
static struct port_mapping_enum * impl_from_IEnumVARIANT(IEnumVARIANT *iface)
Definition: port.c:1171

◆ port_mapping_enum_Clone()

static HRESULT WINAPI port_mapping_enum_Clone ( IEnumVARIANT *  iface,
IEnumVARIANT **  ret 
)
static

Definition at line 1282 of file port.c.

1283{
1284 struct port_mapping_enum *mapping_enum = impl_from_IEnumVARIANT( iface );
1285 HRESULT hr;
1286
1287 TRACE( "iface %p, ret %p.\n", iface, ret );
1288
1289 if (!ret) return E_POINTER;
1290 *ret = NULL;
1291 if (FAILED(hr = create_port_mapping_enum( (IUnknown **)ret ))) return hr;
1292 impl_from_IEnumVARIANT( *ret )->index = mapping_enum->index;
1293 return S_OK;
1294}
static HRESULT create_port_mapping_enum(IUnknown **ret)
Definition: port.c:1307
#define E_POINTER
Definition: winerror.h:3480

◆ port_mapping_enum_Next()

static HRESULT WINAPI port_mapping_enum_Next ( IEnumVARIANT *  iface,
ULONG  celt,
VARIANT *  var,
ULONG *  fetched 
)
static

Definition at line 1220 of file port.c.

1221{
1222 struct port_mapping_enum *mapping_enum = impl_from_IEnumVARIANT( iface );
1223 struct port_mapping *data;
1225 unsigned int i, count;
1226 HRESULT ret;
1227
1228 TRACE( "iface %p, celt %lu, var %p, fetched %p.\n", iface, celt, var, fetched );
1229
1230 if (fetched) *fetched = 0;
1231 if (!celt) return S_OK;
1232 if (!var) return E_POINTER;
1233
1234 if (!(data = calloc( 1, celt * sizeof(*data) ))) return E_OUTOFMEMORY;
1235 count = get_port_mapping_range( mapping_enum->index, celt, data );
1236 TRACE( "count %u.\n", count );
1237 for (i = 0; i < count; ++i)
1238 {
1239 if (FAILED(static_port_mapping_create( &data[i], &pm ))) break;
1240
1241 V_VT(&var[i]) = VT_DISPATCH;
1242 V_DISPATCH(&var[i]) = (IDispatch *)pm;
1243 }
1244 mapping_enum->index += i;
1245 if (fetched) *fetched = i;
1246 ret = (i < celt) ? S_FALSE : S_OK;
1247 for ( ; i < count; ++i)
1248 {
1250 VariantInit( &var[i] );
1251 }
1252 for ( ; i < celt; ++i)
1253 VariantInit( &var[i] );
1254
1255 free( data );
1256 return ret;
1257}
@ VT_DISPATCH
Definition: compat.h:2304
static HRESULT static_port_mapping_create(const struct port_mapping *mapping_data, IStaticPortMapping **ret)
Definition: port.c:1151
static unsigned int get_port_mapping_range(unsigned int index, unsigned int count, struct port_mapping *ret)
Definition: port.c:835
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static LPMONITOREX pm
Definition: localmon.c:45
const char * var
Definition: shader.c:5879
#define V_VT(A)
Definition: oleauto.h:211
#define V_DISPATCH(A)
Definition: oleauto.h:239
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:547
#define S_FALSE
Definition: winerror.h:3451

◆ port_mapping_enum_QueryInterface()

static HRESULT WINAPI port_mapping_enum_QueryInterface ( IEnumVARIANT *  iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 1197 of file port.c.

1201{
1202 struct port_mapping_enum *mapping_enum = impl_from_IEnumVARIANT( iface );
1203
1204 TRACE("%p %s %p\n", mapping_enum, debugstr_guid( riid ), ppvObject );
1205
1206 if ( IsEqualGUID( riid, &IID_IEnumVARIANT ) ||
1208 {
1209 *ppvObject = iface;
1210 }
1211 else
1212 {
1213 FIXME("interface %s not implemented\n", debugstr_guid(riid));
1214 return E_NOINTERFACE;
1215 }
1216 IEnumVARIANT_AddRef( iface );
1217 return S_OK;
1218}

◆ port_mapping_enum_Release()

static ULONG WINAPI port_mapping_enum_Release ( IEnumVARIANT *  iface)
static

Definition at line 1183 of file port.c.

1185{
1186 struct port_mapping_enum *mapping_enum = impl_from_IEnumVARIANT( iface );
1187 LONG refs = InterlockedDecrement( &mapping_enum->refs );
1188 if (!refs)
1189 {
1190 TRACE("destroying %p\n", mapping_enum);
1191 free( mapping_enum );
1193 }
1194 return refs;
1195}
static void release_gateway_connection(void)
Definition: port.c:808

◆ port_mapping_enum_Reset()

static HRESULT WINAPI port_mapping_enum_Reset ( IEnumVARIANT *  iface)
static

Definition at line 1270 of file port.c.

1271{
1272 struct port_mapping_enum *mapping_enum = impl_from_IEnumVARIANT( iface );
1273
1274 TRACE( "iface %p.\n", iface );
1275
1276 mapping_enum->index = 0;
1277 return S_OK;
1278}

◆ port_mapping_enum_Skip()

static HRESULT WINAPI port_mapping_enum_Skip ( IEnumVARIANT *  iface,
ULONG  celt 
)
static

Definition at line 1259 of file port.c.

1260{
1261 struct port_mapping_enum *mapping_enum = impl_from_IEnumVARIANT( iface );
1262 unsigned int count = get_port_mapping_count();
1263
1264 TRACE( "iface %p, celt %lu.\n", iface, celt );
1265
1266 mapping_enum->index += celt;
1267 return mapping_enum->index <= count ? S_OK : S_FALSE;
1268}
static unsigned int get_port_mapping_count(void)
Definition: port.c:851

◆ release_gateway_connection()

◆ remove_port_mapping()

static BOOL remove_port_mapping ( LONG  port,
BSTR  protocol 
)
static

Definition at line 622 of file port.c.

623{
624 struct xml_value_desc mapping_desc[PM_REMOVE_PORT_LAST];
625 DWORD status = 0;
626 BSTR error_str;
627 WCHAR portW[6];
628 BOOL ret;
629
631 memcpy( mapping_desc, port_mapping_template, sizeof(mapping_desc) );
632 swprintf( portW, ARRAY_SIZE(portW), L"%u", port );
633 mapping_desc[PM_EXTERNAL_IP].value = SysAllocString( L"" );
634 mapping_desc[PM_EXTERNAL].value = SysAllocString( portW );
635 mapping_desc[PM_PROTOCOL].value = protocol;
636
637 ret = request_service( L"DeletePortMapping", mapping_desc, PM_REMOVE_PORT_LAST,
638 NULL, 0, &status, &error_str );
639 if (ret && status != HTTP_STATUS_OK)
640 {
641 WARN( "status %lu, server returned error %s.\n", status, debugstr_w(error_str) );
642 SysFreeString( error_str );
643 ret = FALSE;
644 }
645 else if (!ret)
646 {
647 WARN( "Request failed.\n" );
648 }
651
652 SysFreeString( mapping_desc[PM_EXTERNAL_IP].value );
653 SysFreeString( mapping_desc[PM_EXTERNAL].value );
654 return ret;
655}

Referenced by static_ports_Remove().

◆ request_service()

static BOOL request_service ( const WCHAR *  function,
const struct xml_value_desc *  request_param,
unsigned int  request_param_count,
struct xml_value_desc *  result,
unsigned int  result_count,
DWORD *  http_status,
BSTR *  server_error_code_str 
)
static

Definition at line 401 of file port.c.

404{
405 static const char request_template_header[] =
406 "<?xml version=\"1.0\"?>\r\n"
407 "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" "
408 "SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n"
409 " <SOAP-ENV:Body>\r\n"
410 " <m:%S xmlns:m=\"urn:schemas-upnp-org:service:WANIPConnection:%u\">\r\n";
411 static const char request_template_footer[] =
412 " </m:%S>\r\n"
413 " </SOAP-ENV:Body>\r\n"
414 "</SOAP-ENV:Envelope>\r\n";
415
416 unsigned int request_data_size, request_len, offset, i, reply_buffer_size;
417 char *request_data, *reply_buffer = NULL, *ptr;
418 struct xml_value_desc error_value_desc;
419 WCHAR request_headers[1024];
421 BOOL ret = FALSE;
422 DWORD size;
423
424 *server_error_code_str = NULL;
425 request_data_size = strlen(request_template_header) + strlen(request_template_footer) + 2 * wcslen( function )
426 + 9 /* version + zero terminator */;
427 for (i = 0; i < request_param_count; ++i)
428 {
429 request_data_size += 13 + 2 * wcslen( request_param[i].name ) + wcslen( request_param[i].value );
430 }
431 if (!(request_data = malloc( request_data_size ))) return FALSE;
432
435 if (!request) goto done;
436
437 ptr = request_data;
438 snprintf( ptr, request_data_size, request_template_header, function, upnp_gateway_connection.version );
439 offset = strlen( ptr );
440 ptr += offset;
441 request_data_size -= offset;
442 for (i = 0; i < request_param_count; ++i)
443 {
444 snprintf( ptr, request_data_size, " <%S>%S</%S>\r\n",
445 request_param[i].name, request_param[i].value, request_param[i].name);
446 offset = strlen( ptr );
447 ptr += offset;
448 request_data_size -= offset;
449 }
450 snprintf( ptr, request_data_size, request_template_footer, function );
451
452 request_len = strlen( request_data );
453 swprintf( request_headers, ARRAY_SIZE(request_headers),
454 L"SOAPAction: \"urn:schemas-upnp-org:service:WANIPConnection:%u#%s\"\r\n"
455 L"Content-Type: text/xml",
456 upnp_gateway_connection.version, function );
457 if (!WinHttpSendRequest( request, request_headers, -1, request_data, request_len, request_len, 0 ))
458 {
459 WARN( "Error sending request %lu.\n", GetLastError() );
460 goto done;
461 }
463 {
464 WARN( "Error receiving response %lu.\n", GetLastError() );
465 goto done;
466 }
467 size = sizeof(*http_status);
469 NULL, http_status, &size, NULL) || *http_status != HTTP_STATUS_OK )
470 {
471 if (*http_status != HTTP_STATUS_SERVER_ERROR)
472 {
473 ret = TRUE;
474 goto done;
475 }
476 }
477
478 offset = 0;
479 reply_buffer_size = 1024;
480 if (!(reply_buffer = malloc( reply_buffer_size ))) goto done;
481 while ((ret = WinHttpReadData( request, reply_buffer + offset, reply_buffer_size - offset - 1, &size )) && size)
482 {
483 offset += size;
484 if (offset + 1 == reply_buffer_size)
485 {
486 char *new;
487
488 reply_buffer_size *= 2;
489 if (!(new = realloc( reply_buffer, reply_buffer_size ))) goto done;
490 reply_buffer = new;
491 }
492 }
493 reply_buffer[offset] = 0;
494
495 if (*http_status == HTTP_STATUS_OK) ret = get_xml_elements( reply_buffer, result, result_count );
496 else
497 {
498 error_value_desc.name = L"errorCode";
499 error_value_desc.value = NULL;
500 if ((ret = get_xml_elements( reply_buffer, &error_value_desc, 1 )))
501 *server_error_code_str = error_value_desc.value;
502 }
503
504done:
505 free( reply_buffer );
506 free( request_data );
508 return ret;
509}
static BOOL get_xml_elements(const char *desc_xml, struct xml_value_desc *values, unsigned int value_count)
Definition: port.c:234
GLuint64EXT * result
Definition: glext.h:11304
static PVOID ptr
Definition: dispmode.c:27
char * value
Definition: wpp.c:53
#define WINHTTP_DEFAULT_ACCEPT_TYPES
Definition: winhttp.h:226
#define HTTP_STATUS_SERVER_ERROR
Definition: winhttp.h:334
#define snprintf
Definition: wintirpc.h:48

Referenced by add_port_mapping(), remove_port_mapping(), and update_mapping_list().

◆ static_port_mapping_AddRef()

static ULONG WINAPI static_port_mapping_AddRef ( IStaticPortMapping *  iface)
static

Definition at line 879 of file port.c.

881{
883 return InterlockedIncrement( &mapping->refs );
884}
static struct static_port_mapping * impl_from_IStaticPortMapping(IStaticPortMapping *iface)
Definition: port.c:874

◆ static_port_mapping_collection_create()

static HRESULT static_port_mapping_collection_create ( IStaticPortMappingCollection **  object)
static

Definition at line 1571 of file port.c.

1572{
1573 struct static_port_mapping_collection *ports;
1574
1575 if (!object) return E_POINTER;
1577 {
1578 *object = NULL;
1579 return S_OK;
1580 }
1581 if (!(ports = calloc( 1, sizeof(*ports) )))
1582 {
1584 return E_OUTOFMEMORY;
1585 }
1586 ports->refs = 1;
1588 *object = &ports->IStaticPortMappingCollection_iface;
1589 return S_OK;
1590}
static const IStaticPortMappingCollectionVtbl static_ports_vtbl
Definition: port.c:1555
IStaticPortMappingCollection IStaticPortMappingCollection_iface
Definition: port.c:1324

Referenced by upnpnat_get_StaticPortMappingCollection().

◆ static_port_mapping_create()

static HRESULT static_port_mapping_create ( const struct port_mapping *  mapping_data,
IStaticPortMapping **  ret 
)
static

Definition at line 1151 of file port.c.

1152{
1154
1155 if (!(mapping = calloc( 1, sizeof(*mapping) ))) return E_OUTOFMEMORY;
1156
1157 mapping->refs = 1;
1158 mapping->IStaticPortMapping_iface.lpVtbl = &static_port_mapping_vtbl;
1159 mapping->data = *mapping_data;
1160 *ret = &mapping->IStaticPortMapping_iface;
1161 return S_OK;
1162}
static const IStaticPortMappingVtbl static_port_mapping_vtbl
Definition: port.c:1129

Referenced by port_mapping_enum_Next(), static_ports_Add(), and static_ports_get_Item().

◆ static_port_mapping_EditDescription()

static HRESULT WINAPI static_port_mapping_EditDescription ( IStaticPortMapping *  iface,
BSTR  value 
)
static

Definition at line 1111 of file port.c.

1114{
1115 FIXME( "iface %p, value %s stub.\n", iface, debugstr_w(value) );
1116
1117 return E_NOTIMPL;
1118}

◆ static_port_mapping_EditInternalClient()

static HRESULT WINAPI static_port_mapping_EditInternalClient ( IStaticPortMapping *  iface,
BSTR  value 
)
static

Definition at line 1093 of file port.c.

1096{
1097 FIXME( "iface %p, value %s stub.\n", iface, debugstr_w(value) );
1098
1099 return E_NOTIMPL;
1100}

◆ static_port_mapping_EditInternalPort()

static HRESULT WINAPI static_port_mapping_EditInternalPort ( IStaticPortMapping *  iface,
LONG  value 
)
static

Definition at line 1120 of file port.c.

1123{
1124 FIXME( "iface %p, value %ld stub.\n", iface, value );
1125
1126 return E_NOTIMPL;
1127}

◆ static_port_mapping_Enable()

static HRESULT WINAPI static_port_mapping_Enable ( IStaticPortMapping *  iface,
VARIANT_BOOL  value 
)
static

Definition at line 1102 of file port.c.

1105{
1106 FIXME( "iface %p, value %d stub.\n", iface, value );
1107
1108 return E_NOTIMPL;
1109}

◆ static_port_mapping_get_Description()

static HRESULT WINAPI static_port_mapping_get_Description ( IStaticPortMapping *  iface,
BSTR *  value 
)
static

Definition at line 1079 of file port.c.

1082{
1084
1085 TRACE( "iface %p, value %p.\n", iface, value );
1086
1087 if (!value) return E_POINTER;
1088 *value = SysAllocString( mapping->data.descr );
1089 if (mapping->data.descr && !*value) return E_OUTOFMEMORY;
1090 return S_OK;
1091}

◆ static_port_mapping_get_Enabled()

static HRESULT WINAPI static_port_mapping_get_Enabled ( IStaticPortMapping *  iface,
VARIANT_BOOL *  value 
)
static

Definition at line 1066 of file port.c.

1069{
1071
1072 TRACE( "iface %p, value %p.\n", iface, value );
1073
1074 if (!value) return E_POINTER;
1075 *value = mapping->data.enabled;
1076 return S_OK;
1077}

◆ static_port_mapping_get_ExternalIPAddress()

static HRESULT WINAPI static_port_mapping_get_ExternalIPAddress ( IStaticPortMapping *  iface,
BSTR *  value 
)
static

Definition at line 998 of file port.c.

1001{
1003
1004 TRACE( "iface %p, value %p.\n", iface, value );
1005
1006 if (!value) return E_POINTER;
1007 *value = SysAllocString( mapping->data.external_ip );
1008 if (mapping->data.external_ip && !*value) return E_OUTOFMEMORY;
1009 return S_OK;
1010}

◆ static_port_mapping_get_ExternalPort()

static HRESULT WINAPI static_port_mapping_get_ExternalPort ( IStaticPortMapping *  iface,
LONG *  value 
)
static

Definition at line 1012 of file port.c.

1015{
1017
1018 TRACE( "iface %p, value %p.\n", iface, value );
1019
1020 if (!value) return E_POINTER;
1021 *value = mapping->data.external;
1022 return S_OK;
1023}

◆ static_port_mapping_get_InternalClient()

static HRESULT WINAPI static_port_mapping_get_InternalClient ( IStaticPortMapping *  iface,
BSTR *  value 
)
static

Definition at line 1052 of file port.c.

1055{
1057
1058 TRACE( "iface %p, value %p.\n", iface, value );
1059
1060 if (!value) return E_POINTER;
1061 *value = SysAllocString( mapping->data.client );
1062 if (mapping->data.client && !*value) return E_OUTOFMEMORY;
1063 return S_OK;
1064}

◆ static_port_mapping_get_InternalPort()

static HRESULT WINAPI static_port_mapping_get_InternalPort ( IStaticPortMapping *  iface,
LONG *  value 
)
static

Definition at line 1025 of file port.c.

1028{
1030
1031 TRACE( "iface %p, value %p.\n", iface, value );
1032
1033 if (!value) return E_POINTER;
1034 *value = mapping->data.internal;
1035 return S_OK;
1036}

◆ static_port_mapping_get_Protocol()

static HRESULT WINAPI static_port_mapping_get_Protocol ( IStaticPortMapping *  iface,
BSTR *  value 
)
static

Definition at line 1038 of file port.c.

1041{
1043
1044 TRACE( "iface %p, value %p.\n", iface, value );
1045
1046 if (!value) return E_POINTER;
1047 *value = SysAllocString( mapping->data.protocol );
1048 if (mapping->data.protocol && !*value) return E_OUTOFMEMORY;
1049 return S_OK;
1050}

◆ static_port_mapping_GetIDsOfNames()

static HRESULT WINAPI static_port_mapping_GetIDsOfNames ( IStaticPortMapping *  iface,
REFIID  riid,
LPOLESTR *  rgszNames,
UINT  cNames,
LCID  lcid,
DISPID *  rgDispId 
)
static

Definition at line 947 of file port.c.

954{
957 HRESULT hr;
958
959 TRACE("%p %s %p %u %lu %p\n", mapping, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
960
962 if (SUCCEEDED(hr))
963 {
964 hr = ITypeInfo_GetIDsOfNames( typeinfo, rgszNames, cNames, rgDispId );
965 ITypeInfo_Release( typeinfo );
966 }
967 return hr;
968}
@ IStaticPortMapping_tid

◆ static_port_mapping_GetTypeInfo()

static HRESULT WINAPI static_port_mapping_GetTypeInfo ( IStaticPortMapping *  iface,
UINT  iTInfo,
LCID  lcid,
ITypeInfo **  ppTInfo 
)
static

Definition at line 935 of file port.c.

940{
942
943 TRACE("%p %u %lu %p\n", mapping, iTInfo, lcid, ppTInfo);
944 return get_typeinfo( IStaticPortMapping_tid, ppTInfo );
945}

◆ static_port_mapping_GetTypeInfoCount()

static HRESULT WINAPI static_port_mapping_GetTypeInfoCount ( IStaticPortMapping *  iface,
UINT *  pctinfo 
)
static

Definition at line 924 of file port.c.

927{
929
930 TRACE("%p %p\n", mapping, pctinfo);
931 *pctinfo = 1;
932 return S_OK;
933}

◆ static_port_mapping_Invoke()

static HRESULT WINAPI static_port_mapping_Invoke ( IStaticPortMapping *  iface,
DISPID  dispIdMember,
REFIID  riid,
LCID  lcid,
WORD  wFlags,
DISPPARAMS *  pDispParams,
VARIANT *  pVarResult,
EXCEPINFO *  pExcepInfo,
UINT *  puArgErr 
)
static

Definition at line 970 of file port.c.

980{
983 HRESULT hr;
984
985 TRACE("%p %ld %s %ld %d %p %p %p %p\n", mapping, dispIdMember, debugstr_guid(riid),
986 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
987
989 if (SUCCEEDED(hr))
990 {
991 hr = ITypeInfo_Invoke( typeinfo, &mapping->IStaticPortMapping_iface, dispIdMember,
992 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr );
993 ITypeInfo_Release( typeinfo );
994 }
995 return hr;
996}

◆ static_port_mapping_QueryInterface()

static HRESULT WINAPI static_port_mapping_QueryInterface ( IStaticPortMapping *  iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 900 of file port.c.

904{
906
907 TRACE("%p %s %p\n", mapping, debugstr_guid( riid ), ppvObject );
908
909 if ( IsEqualGUID( riid, &IID_IStaticPortMapping ) ||
912 {
913 *ppvObject = iface;
914 }
915 else
916 {
917 FIXME("interface %s not implemented\n", debugstr_guid(riid));
918 return E_NOINTERFACE;
919 }
920 IStaticPortMapping_AddRef( iface );
921 return S_OK;
922}

◆ static_port_mapping_Release()

static ULONG WINAPI static_port_mapping_Release ( IStaticPortMapping *  iface)
static

Definition at line 886 of file port.c.

888{
891 if (!refs)
892 {
893 TRACE("destroying %p\n", mapping);
894 free_port_mapping( &mapping->data );
895 free( mapping );
896 }
897 return refs;
898}

◆ static_ports__NewEnum()

static HRESULT WINAPI static_ports__NewEnum ( IStaticPortMappingCollection *  iface,
IUnknown **  ret 
)
static

Definition at line 1453 of file port.c.

1456{
1457 TRACE( "iface %p, ret %p.\n", iface, ret );
1458
1459 if (!ret) return E_POINTER;
1460
1461 *ret = NULL;
1462 return create_port_mapping_enum( ret );
1463}

◆ static_ports_Add()

static HRESULT WINAPI static_ports_Add ( IStaticPortMappingCollection *  iface,
LONG  external,
BSTR  protocol,
LONG  internal,
BSTR  client,
VARIANT_BOOL  enabled,
BSTR  description,
IStaticPortMapping **  mapping 
)
static

Definition at line 1512 of file port.c.

1521{
1522 struct port_mapping mapping_data;
1523 HRESULT ret;
1524
1525 TRACE( "iface %p, external %ld, protocol %s, internal %ld, client %s, enabled %d, description %s, mapping %p.\n",
1527 mapping );
1528
1529 if (!mapping) return E_POINTER;
1530 *mapping = NULL;
1531
1532 if (!is_valid_protocol( protocol )) return E_INVALIDARG;
1533 if (external < 0 || external > 65535) return E_INVALIDARG;
1534 if (internal < 0 || internal > 65535) return E_INVALIDARG;
1535 if (!client || !description) return E_INVALIDARG;
1536
1538
1539 mapping_data.external_ip = NULL;
1540 mapping_data.external = external;
1541 mapping_data.protocol = SysAllocString( protocol );
1542 mapping_data.internal = internal;
1543 mapping_data.client = SysAllocString( client );
1544 mapping_data.enabled = enabled;
1545 mapping_data.descr = SysAllocString( description );
1546 if (!mapping_data.protocol || !mapping_data.client || !mapping_data.descr)
1547 {
1548 free_port_mapping( &mapping_data );
1549 return E_OUTOFMEMORY;
1550 }
1551 if (FAILED(ret = static_port_mapping_create( &mapping_data, mapping ))) free_port_mapping( &mapping_data );
1552 return ret;
1553}
#define E_FAIL
Definition: ddrawi.h:102
static BOOL is_valid_protocol(BSTR protocol)
Definition: port.c:861
static BOOL add_port_mapping(LONG external, BSTR protocol, LONG internal, BSTR client, VARIANT_BOOL enabled, BSTR description)
Definition: port.c:657
LONG external
Definition: port.c:46

◆ static_ports_AddRef()

static ULONG WINAPI static_ports_AddRef ( IStaticPortMappingCollection *  iface)
static

Definition at line 1334 of file port.c.

1336{
1338 return InterlockedIncrement( &ports->refs );
1339}
static struct static_port_mapping_collection * impl_from_IStaticPortMappingCollection(IStaticPortMappingCollection *iface)
Definition: port.c:1329

◆ static_ports_get_Count()

static HRESULT WINAPI static_ports_get_Count ( IStaticPortMappingCollection *  iface,
LONG *  count 
)
static

Definition at line 1486 of file port.c.

1489{
1490 TRACE( "iface %p, count %p.\n", iface, count );
1491
1492 if (!count) return E_POINTER;
1494 return S_OK;
1495}

◆ static_ports_get_Item()

static HRESULT WINAPI static_ports_get_Item ( IStaticPortMappingCollection *  iface,
LONG  port,
BSTR  protocol,
IStaticPortMapping **  mapping 
)
static

Definition at line 1465 of file port.c.

1470{
1471 struct port_mapping mapping_data;
1472 HRESULT ret;
1473
1474 TRACE( "iface %p, port %ld, protocol %s.\n", iface, port, debugstr_w(protocol) );
1475
1476 if (!mapping) return E_POINTER;
1477 *mapping = NULL;
1478 if (!is_valid_protocol( protocol )) return E_INVALIDARG;
1479 if (port < 0 || port > 65535) return E_INVALIDARG;
1480
1482 if (FAILED(ret = static_port_mapping_create( &mapping_data, mapping ))) free_port_mapping( &mapping_data );
1483 return ret;
1484}
static BOOL find_port_mapping(LONG port, BSTR protocol, struct port_mapping *ret)
Definition: port.c:817
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210

◆ static_ports_GetIDsOfNames()

static HRESULT WINAPI static_ports_GetIDsOfNames ( IStaticPortMappingCollection *  iface,
REFIID  riid,
LPOLESTR *  rgszNames,
UINT  cNames,
LCID  lcid,
DISPID *  rgDispId 
)
static

Definition at line 1402 of file port.c.

1409{
1412 HRESULT hr;
1413
1414 TRACE("%p %s %p %u %lu %p\n", ports, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
1415
1417 if (SUCCEEDED(hr))
1418 {
1419 hr = ITypeInfo_GetIDsOfNames( typeinfo, rgszNames, cNames, rgDispId );
1420 ITypeInfo_Release( typeinfo );
1421 }
1422 return hr;
1423}
@ IStaticPortMappingCollection_tid

◆ static_ports_GetTypeInfo()

static HRESULT WINAPI static_ports_GetTypeInfo ( IStaticPortMappingCollection *  iface,
UINT  iTInfo,
LCID  lcid,
ITypeInfo **  ppTInfo 
)
static

Definition at line 1390 of file port.c.

1395{
1397
1398 TRACE("%p %u %lu %p\n", ports, iTInfo, lcid, ppTInfo);
1400}

◆ static_ports_GetTypeInfoCount()

static HRESULT WINAPI static_ports_GetTypeInfoCount ( IStaticPortMappingCollection *  iface,
UINT *  pctinfo 
)
static

Definition at line 1379 of file port.c.

1382{
1384
1385 TRACE("%p %p\n", ports, pctinfo);
1386 *pctinfo = 1;
1387 return S_OK;
1388}

◆ static_ports_Invoke()

static HRESULT WINAPI static_ports_Invoke ( IStaticPortMappingCollection *  iface,
DISPID  dispIdMember,
REFIID  riid,
LCID  lcid,
WORD  wFlags,
DISPPARAMS *  pDispParams,
VARIANT *  pVarResult,
EXCEPINFO *  pExcepInfo,
UINT *  puArgErr 
)
static

Definition at line 1425 of file port.c.

1435{
1438 HRESULT hr;
1439
1440 TRACE("%p %ld %s %ld %d %p %p %p %p\n", ports, dispIdMember, debugstr_guid(riid),
1441 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1442
1444 if (SUCCEEDED(hr))
1445 {
1446 hr = ITypeInfo_Invoke( typeinfo, &ports->IStaticPortMappingCollection_iface, dispIdMember,
1447 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr );
1448 ITypeInfo_Release( typeinfo );
1449 }
1450 return hr;
1451}

◆ static_ports_QueryInterface()

static HRESULT WINAPI static_ports_QueryInterface ( IStaticPortMappingCollection *  iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 1355 of file port.c.

1359{
1361
1362 TRACE("%p %s %p\n", ports, debugstr_guid( riid ), ppvObject );
1363
1364 if ( IsEqualGUID( riid, &IID_IStaticPortMappingCollection ) ||
1367 {
1368 *ppvObject = iface;
1369 }
1370 else
1371 {
1372 FIXME("interface %s not implemented\n", debugstr_guid(riid));
1373 return E_NOINTERFACE;
1374 }
1375 IStaticPortMappingCollection_AddRef( iface );
1376 return S_OK;
1377}

◆ static_ports_Release()

static ULONG WINAPI static_ports_Release ( IStaticPortMappingCollection *  iface)
static

Definition at line 1341 of file port.c.

1343{
1345 LONG refs = InterlockedDecrement( &ports->refs );
1346 if (!refs)
1347 {
1348 TRACE("destroying %p\n", ports);
1350 free( ports );
1351 }
1352 return refs;
1353}

◆ static_ports_Remove()

static HRESULT WINAPI static_ports_Remove ( IStaticPortMappingCollection *  iface,
LONG  port,
BSTR  protocol 
)
static

Definition at line 1497 of file port.c.

1501{
1502 TRACE( "iface %p, port %ld, protocol %s.\n", iface, port, debugstr_w(protocol) );
1503
1504 if (!is_valid_protocol( protocol )) return E_INVALIDARG;
1505 if (port < 0 || port > 65535) return E_INVALIDARG;
1506
1507 if (!remove_port_mapping( port, protocol )) return E_FAIL;
1508
1509 return S_OK;
1510}
static BOOL remove_port_mapping(LONG port, BSTR protocol)
Definition: port.c:622

◆ update_mapping_list()

static void update_mapping_list ( void  )
static

Definition at line 559 of file port.c.

560{
561 struct xml_value_desc mapping_desc[ARRAY_SIZE(port_mapping_template)];
562 struct xml_value_desc index_param;
563 struct port_mapping *new_mappings;
564 unsigned int i, index;
565 WCHAR index_str[9];
566 BSTR error_str;
568 BOOL ret;
569
571
572 index_param.name = L"NewPortMappingIndex";
573
574 index = 0;
575 while (1)
576 {
577 new_mappings = realloc( upnp_gateway_connection.mappings, (index + 1) * sizeof(*new_mappings) );
578 if (!new_mappings) break;
579 upnp_gateway_connection.mappings = new_mappings;
580
581 memcpy( mapping_desc, port_mapping_template, sizeof(mapping_desc) );
582 swprintf( index_str, ARRAY_SIZE(index_str), L"%u", index );
583 index_param.value = SysAllocString( index_str );
584 ret = request_service( L"GetGenericPortMappingEntry", &index_param, 1,
585 mapping_desc, ARRAY_SIZE(mapping_desc), &status, &error_str );
586 SysFreeString( index_param.value );
587 if (!ret) break;
588 if (status != HTTP_STATUS_OK)
589 {
590 if (error_str)
591 {
592 if (long_from_bstr( error_str ) != 713)
593 WARN( "Server returned error %s.\n", debugstr_w(error_str) );
594 SysFreeString( error_str );
595 }
596 break;
597 }
598 new_mappings[index].external_ip = mapping_move_bstr( &mapping_desc[PM_EXTERNAL_IP].value );
599 new_mappings[index].external = long_from_bstr( mapping_desc[PM_EXTERNAL].value );
600 new_mappings[index].protocol = mapping_move_bstr( &mapping_desc[PM_PROTOCOL].value );
601 new_mappings[index].internal = long_from_bstr( mapping_desc[PM_INTERNAL].value );
602 new_mappings[index].client = mapping_move_bstr( &mapping_desc[PM_CLIENT].value );
603 if (mapping_desc[PM_ENABLED].value && (!wcsicmp( mapping_desc[PM_ENABLED].value, L"true" )
604 || long_from_bstr( mapping_desc[PM_ENABLED].value )))
605 new_mappings[index].enabled = VARIANT_TRUE;
606 else
607 new_mappings[index].enabled = VARIANT_FALSE;
608 new_mappings[index].descr = mapping_move_bstr( &mapping_desc[PM_DESC].value );
609
610 TRACE( "%s %s %s:%lu -> %s:%lu, enabled %d.\n", debugstr_w(new_mappings[index].descr),
611 debugstr_w(new_mappings[index].protocol), debugstr_w(new_mappings[index].external_ip),
612 new_mappings[index].external, debugstr_w(new_mappings[index].client),
613 new_mappings[index].internal, new_mappings[index].enabled );
614
615 for (i = 0; i < ARRAY_SIZE(mapping_desc); ++i)
616 SysFreeString( mapping_desc[i].value );
617 upnp_gateway_connection.mappings = new_mappings;
618 upnp_gateway_connection.mapping_count = ++index;
619 }
620}
#define index(s, c)
Definition: various.h:29
static BSTR mapping_move_bstr(BSTR *s)
Definition: port.c:543
static LONG long_from_bstr(BSTR s)
Definition: port.c:537
LONG internal
Definition: port.c:48
BSTR descr
Definition: port.c:51
BSTR external_ip
Definition: port.c:45
VARIANT_BOOL enabled
Definition: port.c:50
BSTR protocol
Definition: port.c:47
BSTR client
Definition: port.c:49

Referenced by add_port_mapping(), init_gateway_connection(), and remove_port_mapping().

◆ upnpnat_AddRef()

static ULONG WINAPI upnpnat_AddRef ( IUPnPNAT *  iface)
static

Definition at line 2199 of file port.c.

2200{
2201 upnpnat *This = impl_from_IUPnPNAT( iface );
2202 return InterlockedIncrement( &This->ref );
2203}
static upnpnat * impl_from_IUPnPNAT(IUPnPNAT *iface)
Definition: port.c:2168

◆ upnpnat_get_DynamicPortMappingCollection()

static HRESULT WINAPI upnpnat_get_DynamicPortMappingCollection ( IUPnPNAT *  iface,
IDynamicPortMappingCollection **  collection 
)
static

Definition at line 2281 of file port.c.

2282{
2283 upnpnat *This = impl_from_IUPnPNAT( iface );
2284 FIXME("%p, %p\n", This, collection);
2285 if(collection)
2286 *collection = NULL;
2287 return E_NOTIMPL;
2288}

◆ upnpnat_get_NATEventManager()

static HRESULT WINAPI upnpnat_get_NATEventManager ( IUPnPNAT *  iface,
INATEventManager **  manager 
)
static

Definition at line 2290 of file port.c.

2291{
2292 upnpnat *This = impl_from_IUPnPNAT( iface );
2293 FIXME("%p, %p\n", This, manager);
2294 if(manager)
2295 *manager = NULL;
2296 return E_NOTIMPL;
2297}

◆ upnpnat_get_StaticPortMappingCollection()

static HRESULT WINAPI upnpnat_get_StaticPortMappingCollection ( IUPnPNAT *  iface,
IStaticPortMappingCollection **  collection 
)
static

Definition at line 2272 of file port.c.

2273{
2274 upnpnat *This = impl_from_IUPnPNAT( iface );
2275
2276 TRACE("%p, %p\n", This, collection);
2277
2279}
static HRESULT static_port_mapping_collection_create(IStaticPortMappingCollection **object)
Definition: port.c:1571

◆ upnpnat_GetIDsOfNames()

static HRESULT WINAPI upnpnat_GetIDsOfNames ( IUPnPNAT *  iface,
REFIID  riid,
LPOLESTR *  rgszNames,
UINT  cNames,
LCID  lcid,
DISPID *  rgDispId 
)
static

Definition at line 2233 of file port.c.

2235{
2236 upnpnat *This = impl_from_IUPnPNAT( iface );
2238 HRESULT hr;
2239
2240 TRACE("%p %s %p %u %lu %p\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
2241
2243 if (SUCCEEDED(hr))
2244 {
2245 hr = ITypeInfo_GetIDsOfNames( typeinfo, rgszNames, cNames, rgDispId );
2246 ITypeInfo_Release( typeinfo );
2247 }
2248 return hr;
2249}
@ IUPnPNAT_tid

◆ upnpnat_GetTypeInfo()

static HRESULT WINAPI upnpnat_GetTypeInfo ( IUPnPNAT *  iface,
UINT  iTInfo,
LCID  lcid,
ITypeInfo **  ppTInfo 
)
static

Definition at line 2225 of file port.c.

2226{
2227 upnpnat *This = impl_from_IUPnPNAT( iface );
2228
2229 TRACE("%p %u %lu %p\n", This, iTInfo, lcid, ppTInfo);
2230 return get_typeinfo( IUPnPNAT_tid, ppTInfo );
2231}

◆ upnpnat_GetTypeInfoCount()

static HRESULT WINAPI upnpnat_GetTypeInfoCount ( IUPnPNAT *  iface,
UINT *  pctinfo 
)
static

Definition at line 2216 of file port.c.

2217{
2218 upnpnat *This = impl_from_IUPnPNAT( iface );
2219
2220 TRACE("%p %p\n", This, pctinfo);
2221 *pctinfo = 1;
2222 return S_OK;
2223}

◆ upnpnat_Invoke()

static HRESULT WINAPI upnpnat_Invoke ( IUPnPNAT *  iface,
DISPID  dispIdMember,
REFIID  riid,
LCID  lcid,
WORD  wFlags,
DISPPARAMS *  pDispParams,
VARIANT *  pVarResult,
EXCEPINFO *  pExcepInfo,
UINT *  puArgErr 
)
static

Definition at line 2251 of file port.c.

2254{
2255 upnpnat *This = impl_from_IUPnPNAT( iface );
2257 HRESULT hr;
2258
2259 TRACE("%p %ld %s %ld %d %p %p %p %p\n", This, dispIdMember, debugstr_guid(riid),
2260 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2261
2263 if (SUCCEEDED(hr))
2264 {
2265 hr = ITypeInfo_Invoke( typeinfo, &This->IUPnPNAT_iface, dispIdMember,
2266 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr );
2267 ITypeInfo_Release( typeinfo );
2268 }
2269 return hr;
2270}

◆ upnpnat_QueryInterface()

static HRESULT WINAPI upnpnat_QueryInterface ( IUPnPNAT *  iface,
REFIID  riid,
void **  object 
)
static

Definition at line 2173 of file port.c.

2174{
2175 upnpnat *This = impl_from_IUPnPNAT( iface );
2176
2177 TRACE("%p %s %p\n", This, debugstr_guid( riid ), object );
2178
2179 if ( IsEqualGUID( riid, &IID_IUPnPNAT ) ||
2182 {
2183 *object = iface;
2184 }
2186 {
2187 TRACE("IProvideClassInfo not supported.\n");
2188 return E_NOINTERFACE;
2189 }
2190 else
2191 {
2192 FIXME("interface %s not implemented\n", debugstr_guid(riid));
2193 return E_NOINTERFACE;
2194 }
2195 IUPnPNAT_AddRef( iface );
2196 return S_OK;
2197}
const GUID IID_IProvideClassInfo

◆ upnpnat_Release()

static ULONG WINAPI upnpnat_Release ( IUPnPNAT *  iface)
static

Definition at line 2205 of file port.c.

2206{
2207 upnpnat *This = impl_from_IUPnPNAT( iface );
2209 if (!refs)
2210 {
2211 free( This );
2212 }
2213 return refs;
2214}

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( hnetcfg  )

Variable Documentation

◆ connection

HINTERNET connection

Definition at line 65 of file port.c.

Referenced by _enumeratorRememberedW(), DirectPlayEnumerateAW(), DP_FreeConnections(), DP_IF_EnumConnections(), DP_IF_EnumSessions(), DP_LoadSP(), DP_ReadConnections(), DPWS_CompareConnections(), DPWS_GetConnection(), DPWS_HeaderReceiveCompleted(), DPWS_MessageBodyReceiveCompleted(), DPWS_RemoveInConnection(), DPWS_SendImpl(), DPWS_TcpReceive(), DPWS_TcpReceiveCompleted(), DPWS_ThreadProc(), finished_reading(), get_np_event(), I_RpcBindingInqLocalClientPID(), IDirectPlay3AImpl_InitializeConnection(), IDirectPlay3AImpl_SetGroupConnectionSettings(), IDirectPlay3Impl_InitializeConnection(), IDirectPlay3Impl_SetGroupConnectionSettings(), IDirectPlay4AImpl_InitializeConnection(), IDirectPlay4AImpl_SetGroupConnectionSettings(), IDirectPlay4Impl_InitializeConnection(), IDirectPlay4Impl_SetGroupConnectionSettings(), lobbyclient_GetConnectionSettings(), lobbyclient_ReleaseApplication(), lobbyclient_Send(), lobbyclient_SetConnectionSettings(), NETCON_GetCert(), NETCON_GetCipherStrength(), NETCON_recv(), NETCON_secure_connect(), netcon_secure_connect_setup(), NETCON_send(), NETCON_set_timeout(), OleCreateStaticFromData(), RasGetConnectionStatistics(), RasGetLinkStatistics(), release_np_event(), rpcrt4_conn_close_read(), rpcrt4_conn_create_pipe(), rpcrt4_conn_np_cancel_call(), rpcrt4_conn_np_close(), rpcrt4_conn_np_close_read(), rpcrt4_conn_np_read(), rpcrt4_conn_np_write(), rpcrt4_conn_release_and_wait(), rpcrt4_conn_tcp_cancel_call(), rpcrt4_conn_tcp_close(), rpcrt4_conn_tcp_close_read(), RPCRT4_GrabConnection(), rpcrt4_ncalrpc_inquire_client_pid(), RPCRT4_ReleaseConnection(), rpcrt4_spawn_connection(), test_cache_read(), test_conn_close(), test_connect_error(), test_connection_closing(), test_header_handling_order(), test_IWinHttpRequest(), test_max_http_automatic_redirects(), test_no_content(), test_not_modified(), test_recursion(), test_successive_HttpSendRequest(), test_websocket(), test_WinHttpAddHeaders(), test_WinHttpOpenRequest(), test_WinHttpQueryOption(), test_WinHttpSendRequest(), testoleobj_IOleObject_Advise(), testoleobj_IOleObject_Unadvise(), WinHttpReadProxySettings(), WNetClearConnections(), and wnetInit().

◆ control_url

WCHAR control_url[256]

Definition at line 67 of file port.c.

Referenced by parse_desc_xml().

◆ desc_urlpath

WCHAR desc_urlpath[128]

Definition at line 66 of file port.c.

◆ fw_port_vtbl

const struct INetFwOpenPortVtbl fw_port_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI fw_port_put_Name(INetFwOpenPort *iface, BSTR name)
Definition: port.c:1735
static HRESULT WINAPI fw_port_put_Port(INetFwOpenPort *iface, LONG portNumber)
Definition: port.c:1806
static HRESULT WINAPI fw_port_get_BuiltIn(INetFwOpenPort *iface, VARIANT_BOOL *builtIn)
Definition: port.c:1879
static HRESULT WINAPI fw_port_put_IpVersion(INetFwOpenPort *iface, NET_FW_IP_VERSION ipVersion)
Definition: port.c:1761
static HRESULT WINAPI fw_port_get_Port(INetFwOpenPort *iface, LONG *portNumber)
Definition: port.c:1796
static HRESULT WINAPI fw_port_get_IpVersion(INetFwOpenPort *iface, NET_FW_IP_VERSION *ipVersion)
Definition: port.c:1751
static HRESULT WINAPI fw_port_get_Name(INetFwOpenPort *iface, BSTR *name)
Definition: port.c:1725
static HRESULT WINAPI fw_port_GetTypeInfo(INetFwOpenPort *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: port.c:1662
static HRESULT WINAPI fw_port_GetIDsOfNames(INetFwOpenPort *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: port.c:1674
static HRESULT WINAPI fw_port_QueryInterface(INetFwOpenPort *iface, REFIID riid, void **ppvObject)
Definition: port.c:1627
static HRESULT WINAPI fw_port_GetTypeInfoCount(INetFwOpenPort *iface, UINT *pctinfo)
Definition: port.c:1651
static ULONG WINAPI fw_port_Release(INetFwOpenPort *iface)
Definition: port.c:1613
static HRESULT WINAPI fw_port_get_Scope(INetFwOpenPort *iface, NET_FW_SCOPE *scope)
Definition: port.c:1817
static ULONG WINAPI fw_port_AddRef(INetFwOpenPort *iface)
Definition: port.c:1606
static HRESULT WINAPI fw_port_get_Enabled(INetFwOpenPort *iface, VARIANT_BOOL *enabled)
Definition: port.c:1857
static HRESULT WINAPI fw_port_put_Enabled(INetFwOpenPort *iface, VARIANT_BOOL enabled)
Definition: port.c:1869
static HRESULT WINAPI fw_port_get_RemoteAddresses(INetFwOpenPort *iface, BSTR *remoteAddrs)
Definition: port.c:1837
static HRESULT WINAPI fw_port_put_Scope(INetFwOpenPort *iface, NET_FW_SCOPE scope)
Definition: port.c:1827
static HRESULT WINAPI fw_port_Invoke(INetFwOpenPort *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: port.c:1697
static HRESULT WINAPI fw_port_put_Protocol(INetFwOpenPort *iface, NET_FW_IP_PROTOCOL ipProtocol)
Definition: port.c:1781
static HRESULT WINAPI fw_port_get_Protocol(INetFwOpenPort *iface, NET_FW_IP_PROTOCOL *ipProtocol)
Definition: port.c:1771
static HRESULT WINAPI fw_port_put_RemoteAddresses(INetFwOpenPort *iface, BSTR remoteAddrs)
Definition: port.c:1847

Definition at line 1889 of file port.c.

Referenced by NetFwOpenPort_create().

◆ fw_ports_vtbl

const struct INetFwOpenPortsVtbl fw_ports_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI fw_ports_Remove(INetFwOpenPorts *iface, LONG portNumber, NET_FW_IP_PROTOCOL ipProtocol)
Definition: port.c:2087
static HRESULT WINAPI fw_ports_Add(INetFwOpenPorts *iface, INetFwOpenPort *port)
Definition: port.c:2077
static HRESULT WINAPI fw_ports_get__NewEnum(INetFwOpenPorts *iface, IUnknown **newEnum)
Definition: port.c:2118
static HRESULT WINAPI fw_ports_Item(INetFwOpenPorts *iface, LONG portNumber, NET_FW_IP_PROTOCOL ipProtocol, INetFwOpenPort **openPort)
Definition: port.c:2098
static HRESULT WINAPI fw_ports_GetTypeInfo(INetFwOpenPorts *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: port.c:2002
static HRESULT WINAPI fw_ports_get_Count(INetFwOpenPorts *iface, LONG *count)
Definition: port.c:2065
static HRESULT WINAPI fw_ports_GetTypeInfoCount(INetFwOpenPorts *iface, UINT *pctinfo)
Definition: port.c:1991
static HRESULT WINAPI fw_ports_GetIDsOfNames(INetFwOpenPorts *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: port.c:2014
static ULONG WINAPI fw_ports_AddRef(INetFwOpenPorts *iface)
Definition: port.c:1947
static HRESULT WINAPI fw_ports_QueryInterface(INetFwOpenPorts *iface, REFIID riid, void **ppvObject)
Definition: port.c:1967
static HRESULT WINAPI fw_ports_Invoke(INetFwOpenPorts *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: port.c:2037
static ULONG WINAPI fw_ports_Release(INetFwOpenPorts *iface)
Definition: port.c:1954

Definition at line 2128 of file port.c.

Referenced by NetFwOpenPorts_create().

◆ locationW

WCHAR locationW[256]

Definition at line 64 of file port.c.

Referenced by parse_search_response(), tapiGetLocationInfoW(), and test_Win32_Printer().

◆ mapping_count

unsigned int mapping_count

Definition at line 70 of file port.c.

◆ mappings

struct port_mapping* mappings

Definition at line 69 of file port.c.

Referenced by read_group_mappings(), and read_mappings().

◆ port_mapping_enum_vtbl

const IEnumVARIANTVtbl port_mapping_enum_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI port_mapping_enum_Next(IEnumVARIANT *iface, ULONG celt, VARIANT *var, ULONG *fetched)
Definition: port.c:1220
static HRESULT WINAPI port_mapping_enum_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppvObject)
Definition: port.c:1197
static ULONG WINAPI port_mapping_enum_Release(IEnumVARIANT *iface)
Definition: port.c:1183
static ULONG WINAPI port_mapping_enum_AddRef(IEnumVARIANT *iface)
Definition: port.c:1176
static HRESULT WINAPI port_mapping_enum_Clone(IEnumVARIANT *iface, IEnumVARIANT **ret)
Definition: port.c:1282
static HRESULT WINAPI port_mapping_enum_Skip(IEnumVARIANT *iface, ULONG celt)
Definition: port.c:1259
static HRESULT WINAPI port_mapping_enum_Reset(IEnumVARIANT *iface)
Definition: port.c:1270

Definition at line 1296 of file port.c.

Referenced by create_port_mapping_enum().

◆ port_mapping_template

struct xml_value_desc port_mapping_template[]
static
Initial value:
=
{
{ L"NewRemoteHost" },
{ L"NewExternalPort" },
{ L"NewProtocol" },
{ L"NewInternalPort" },
{ L"NewInternalClient" },
{ L"NewEnabled" },
{ L"NewPortMappingDescription" },
{ L"NewLeaseDuration" },
}

Definition at line 525 of file port.c.

Referenced by add_port_mapping(), remove_port_mapping(), and update_mapping_list().

◆ refs

LONG refs

Definition at line 62 of file port.c.

Referenced by addref_object(), apartment_addref(), automatic_updates_Release(), cache_Release(), CDevSettings_Release(), class_object_Release(), ClassReleaseClientReference(), ClientIdentity_Release(), CoAddRefServerProcess(), copy_error_AddRef(), copy_error_Release(), CoReleaseServerProcess(), DropTargetWrapper_Release(), enum_class_object_Release(), EnumOLEVERB_Release(), EnumSTATDATA_Release(), enumvar_Release(), fw_app_Release(), fw_apps_Release(), fw_manager_Release(), fw_policy_Release(), fw_port_Release(), fw_ports_Release(), fw_profile_Release(), fw_service_Release(), fw_services_Release(), fwpolicy2_Release(), HandlerCF_Release(), HeapUnknown_Release(), IMAPTransport_Release(), keylist_Release(), KindaEnum_Release(), LibraryClientDereference(), locator_Release(), MimeInternat_Release(), moniker_Release(), msi_load_string_table(), name_Release(), NdrCStdStubBuffer2_Release(), NdrCStdStubBuffer_Release(), netfw_rule_Release(), netfw_rules_Release(), object_Release(), objectset_Release(), path_Release(), POP3Transport_Release(), port_mapping_enum_Release(), property_Release(), propertyset_Release(), proxy_manager_addref_if_alive(), qualifier_set_Release(), release_object(), RemUnknown_AddRef(), RemUnknown_Release(), RpcAssoc_Release(), RpcAuthInfo_Release(), RpcHttpAsyncData_Release(), RpcQualityOfService_Release(), RpcServerAssoc_ReleaseContextHandle(), security_Release(), services_Release(), SMTPTransport_Release(), static_port_mapping_Release(), static_ports_Release(), status_code_Release(), StdProxy_Release(), stream_Release(), stub_manager_ext_addref(), stub_manager_ext_release(), stub_manager_int_addref(), stub_manager_int_release(), stub_manager_release_marshal_data(), systeminfo_Release(), test_bind_context(), Test_CallContext_Release(), test_ChannelBufferRefCount(), test_CoGetCallContext(), test_CoGetContextToken(), test_CoGetObjectContext(), test_consumer_refs(), test_ConvertStringSidToSid(), test_get_file_info_iconlist(), test_IClientSecurity(), test_marshal_LPSAFEARRAY(), test_proxybuffer(), test_render_run(), test_SHGetImageList(), test_stubbuffer(), TLB_Mapping_Release(), TLB_NEFile_Release(), TLB_PEFile_Release(), update_downloader_Release(), update_installer_Release(), update_searcher_Release(), update_session_Release(), upnpnat_Release(), wbem_locator_Release(), wbem_services_Release(), Widget_Release(), winhttp_request_Release(), WININET_AddRef(), WININET_Release(), xmldoc_add_refs(), and xmldoc_release_refs().

◆ session

Definition at line 65 of file port.c.

◆ static_port_mapping_vtbl

const IStaticPortMappingVtbl static_port_mapping_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI static_port_mapping_AddRef(IStaticPortMapping *iface)
Definition: port.c:879
static HRESULT WINAPI static_port_mapping_GetTypeInfoCount(IStaticPortMapping *iface, UINT *pctinfo)
Definition: port.c:924
static HRESULT WINAPI static_port_mapping_Enable(IStaticPortMapping *iface, VARIANT_BOOL value)
Definition: port.c:1102
static HRESULT WINAPI static_port_mapping_get_ExternalPort(IStaticPortMapping *iface, LONG *value)
Definition: port.c:1012
static HRESULT WINAPI static_port_mapping_get_InternalPort(IStaticPortMapping *iface, LONG *value)
Definition: port.c:1025
static HRESULT WINAPI static_port_mapping_get_ExternalIPAddress(IStaticPortMapping *iface, BSTR *value)
Definition: port.c:998
static HRESULT WINAPI static_port_mapping_QueryInterface(IStaticPortMapping *iface, REFIID riid, void **ppvObject)
Definition: port.c:900
static HRESULT WINAPI static_port_mapping_Invoke(IStaticPortMapping *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: port.c:970
static HRESULT WINAPI static_port_mapping_GetTypeInfo(IStaticPortMapping *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: port.c:935
static ULONG WINAPI static_port_mapping_Release(IStaticPortMapping *iface)
Definition: port.c:886
static HRESULT WINAPI static_port_mapping_get_Enabled(IStaticPortMapping *iface, VARIANT_BOOL *value)
Definition: port.c:1066
static HRESULT WINAPI static_port_mapping_GetIDsOfNames(IStaticPortMapping *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: port.c:947
static HRESULT WINAPI static_port_mapping_EditInternalPort(IStaticPortMapping *iface, LONG value)
Definition: port.c:1120
static HRESULT WINAPI static_port_mapping_get_InternalClient(IStaticPortMapping *iface, BSTR *value)
Definition: port.c:1052
static HRESULT WINAPI static_port_mapping_EditDescription(IStaticPortMapping *iface, BSTR value)
Definition: port.c:1111
static HRESULT WINAPI static_port_mapping_get_Protocol(IStaticPortMapping *iface, BSTR *value)
Definition: port.c:1038
static HRESULT WINAPI static_port_mapping_EditInternalClient(IStaticPortMapping *iface, BSTR value)
Definition: port.c:1093
static HRESULT WINAPI static_port_mapping_get_Description(IStaticPortMapping *iface, BSTR *value)
Definition: port.c:1079

Definition at line 1129 of file port.c.

Referenced by static_port_mapping_create().

◆ static_ports_vtbl

const IStaticPortMappingCollectionVtbl static_ports_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI static_ports_Release(IStaticPortMappingCollection *iface)
Definition: port.c:1341
static HRESULT WINAPI static_ports_Add(IStaticPortMappingCollection *iface, LONG external, BSTR protocol, LONG internal, BSTR client, VARIANT_BOOL enabled, BSTR description, IStaticPortMapping **mapping)
Definition: port.c:1512
static HRESULT WINAPI static_ports_GetIDsOfNames(IStaticPortMappingCollection *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: port.c:1402
static HRESULT WINAPI static_ports_Invoke(IStaticPortMappingCollection *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: port.c:1425
static ULONG WINAPI static_ports_AddRef(IStaticPortMappingCollection *iface)
Definition: port.c:1334
static HRESULT WINAPI static_ports_Remove(IStaticPortMappingCollection *iface, LONG port, BSTR protocol)
Definition: port.c:1497
static HRESULT WINAPI static_ports_GetTypeInfo(IStaticPortMappingCollection *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: port.c:1390
static HRESULT WINAPI static_ports_QueryInterface(IStaticPortMappingCollection *iface, REFIID riid, void **ppvObject)
Definition: port.c:1355
static HRESULT WINAPI static_ports_get_Count(IStaticPortMappingCollection *iface, LONG *count)
Definition: port.c:1486
static HRESULT WINAPI static_ports_GetTypeInfoCount(IStaticPortMappingCollection *iface, UINT *pctinfo)
Definition: port.c:1379
static HRESULT WINAPI static_ports__NewEnum(IStaticPortMappingCollection *iface, IUnknown **ret)
Definition: port.c:1453
static HRESULT WINAPI static_ports_get_Item(IStaticPortMappingCollection *iface, LONG port, BSTR protocol, IStaticPortMapping **mapping)
Definition: port.c:1465

Definition at line 1555 of file port.c.

Referenced by static_port_mapping_collection_create().

◆ 

◆ upnp_gateway_connection_lock

SRWLOCK upnp_gateway_connection_lock = SRWLOCK_INIT
static

◆ upnpnat_vtbl

const IUPnPNATVtbl upnpnat_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI upnpnat_GetTypeInfo(IUPnPNAT *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: port.c:2225
static HRESULT WINAPI upnpnat_Invoke(IUPnPNAT *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: port.c:2251
static HRESULT WINAPI upnpnat_GetTypeInfoCount(IUPnPNAT *iface, UINT *pctinfo)
Definition: port.c:2216
static HRESULT WINAPI upnpnat_get_StaticPortMappingCollection(IUPnPNAT *iface, IStaticPortMappingCollection **collection)
Definition: port.c:2272
static ULONG WINAPI upnpnat_Release(IUPnPNAT *iface)
Definition: port.c:2205
static ULONG WINAPI upnpnat_AddRef(IUPnPNAT *iface)
Definition: port.c:2199
static HRESULT WINAPI upnpnat_GetIDsOfNames(IUPnPNAT *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: port.c:2233
static HRESULT WINAPI upnpnat_get_NATEventManager(IUPnPNAT *iface, INATEventManager **manager)
Definition: port.c:2290
static HRESULT WINAPI upnpnat_get_DynamicPortMappingCollection(IUPnPNAT *iface, IDynamicPortMappingCollection **collection)
Definition: port.c:2281
static HRESULT WINAPI upnpnat_QueryInterface(IUPnPNAT *iface, REFIID riid, void **object)
Definition: port.c:2173

Definition at line 2299 of file port.c.

Referenced by IUPnPNAT_create().

◆ version

int version

Definition at line 68 of file port.c.

Referenced by parse_desc_xml().

◆ winsock_initialized

BOOL winsock_initialized

Definition at line 63 of file port.c.