ReactOS  0.4.15-dev-1039-gb9754fa
rpc_transport.c File Reference
#include "ntstatus.h"
#include "ws2tcpip.h"
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winerror.h"
#include "wininet.h"
#include "wine/winternl.h"
#include "winioctl.h"
#include "rpc.h"
#include "rpcndr.h"
#include "wine/debug.h"
#include "rpc_binding.h"
#include "rpc_assoc.h"
#include "rpc_message.h"
#include "rpc_server.h"
#include "epm_towers.h"
Include dependency graph for rpc_transport.c:

Go to the source code of this file.

Classes

struct  _RpcConnection_np
 
struct  _RpcServerProtseq_np
 
struct  _RpcConnection_tcp
 
struct  _RpcServerProtseq_sock
 
struct  _RpcHttpAsyncData
 
struct  authinfo
 
struct  _RpcConnection_http
 
struct  _HttpTimerThreadData
 

Macros

#define WIN32_NO_STATUS
 
#define DEFAULT_NCACN_HTTP_TIMEOUT   (60 * 1000)
 
#define HTTP_IDLE_TIME   60000
 

Typedefs

typedef struct _RpcConnection_np RpcConnection_np
 
typedef struct _RpcServerProtseq_np RpcServerProtseq_np
 
typedef struct _RpcConnection_tcp RpcConnection_tcp
 
typedef struct _RpcServerProtseq_sock RpcServerProtseq_sock
 
typedef struct _RpcHttpAsyncData RpcHttpAsyncData
 
typedef struct _RpcConnection_http RpcConnection_http
 
typedef struct _HttpTimerThreadData HttpTimerThreadData
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (rpc)
 
static RpcConnectionrpcrt4_spawn_connection (RpcConnection *old_connection)
 
static RpcConnectionrpcrt4_conn_np_alloc (void)
 
static HANDLE get_np_event (RpcConnection_np *connection)
 
static void release_np_event (RpcConnection_np *connection, HANDLE event)
 
static RPC_STATUS rpcrt4_conn_create_pipe (RpcConnection *conn)
 
static RPC_STATUS rpcrt4_conn_open_pipe (RpcConnection *Connection, LPCSTR pname, BOOL wait)
 
static charncalrpc_pipe_name (const char *endpoint)
 
static RPC_STATUS rpcrt4_ncalrpc_open (RpcConnection *Connection)
 
static RPC_STATUS rpcrt4_protseq_ncalrpc_open_endpoint (RpcServerProtseq *protseq, const char *endpoint)
 
static charncacn_pipe_name (const char *endpoint)
 
static RPC_STATUS rpcrt4_ncacn_np_open (RpcConnection *Connection)
 
static RPC_STATUS rpcrt4_protseq_ncacn_np_open_endpoint (RpcServerProtseq *protseq, const char *endpoint)
 
static void rpcrt4_conn_np_handoff (RpcConnection_np *old_npc, RpcConnection_np *new_npc)
 
static RPC_STATUS rpcrt4_ncacn_np_handoff (RpcConnection *old_conn, RpcConnection *new_conn)
 
static RPC_STATUS is_pipe_listening (const char *pipe_name)
 
static RPC_STATUS rpcrt4_ncacn_np_is_server_listening (const char *endpoint)
 
static RPC_STATUS rpcrt4_ncalrpc_np_is_server_listening (const char *endpoint)
 
static RPC_STATUS rpcrt4_ncalrpc_handoff (RpcConnection *old_conn, RpcConnection *new_conn)
 
static int rpcrt4_conn_np_read (RpcConnection *conn, void *buffer, unsigned int count)
 
static int rpcrt4_conn_np_write (RpcConnection *conn, const void *buffer, unsigned int count)
 
static int rpcrt4_conn_np_close (RpcConnection *conn)
 
static void rpcrt4_conn_np_close_read (RpcConnection *conn)
 
static void rpcrt4_conn_np_cancel_call (RpcConnection *conn)
 
static int rpcrt4_conn_np_wait_for_incoming_data (RpcConnection *conn)
 
static size_t rpcrt4_ncacn_np_get_top_of_tower (unsigned char *tower_data, const char *networkaddr, const char *endpoint)
 
static RPC_STATUS rpcrt4_ncacn_np_parse_top_of_tower (const unsigned char *tower_data, size_t tower_size, char **networkaddr, char **endpoint)
 
static RPC_STATUS rpcrt4_conn_np_impersonate_client (RpcConnection *conn)
 
static RPC_STATUS rpcrt4_conn_np_revert_to_self (RpcConnection *conn)
 
static RpcServerProtseqrpcrt4_protseq_np_alloc (void)
 
static void rpcrt4_protseq_np_signal_state_changed (RpcServerProtseq *protseq)
 
static voidrpcrt4_protseq_np_get_wait_array (RpcServerProtseq *protseq, void *prev_array, unsigned int *count)
 
static void rpcrt4_protseq_np_free_wait_array (RpcServerProtseq *protseq, void *array)
 
static int rpcrt4_protseq_np_wait_for_new_connection (RpcServerProtseq *protseq, unsigned int count, void *wait_array)
 
static size_t rpcrt4_ncalrpc_get_top_of_tower (unsigned char *tower_data, const char *networkaddr, const char *endpoint)
 
static RPC_STATUS rpcrt4_ncalrpc_parse_top_of_tower (const unsigned char *tower_data, size_t tower_size, char **networkaddr, char **endpoint)
 
static BOOL rpcrt4_ncalrpc_is_authorized (RpcConnection *conn)
 
static RPC_STATUS rpcrt4_ncalrpc_authorize (RpcConnection *conn, BOOL first_time, unsigned char *in_buffer, unsigned int in_size, unsigned char *out_buffer, unsigned int *out_size)
 
static RPC_STATUS rpcrt4_ncalrpc_secure_packet (RpcConnection *conn, enum secure_packet_direction dir, RpcPktHdr *hdr, unsigned int hdr_size, unsigned char *stub_data, unsigned int stub_data_size, RpcAuthVerifier *auth_hdr, unsigned char *auth_value, unsigned int auth_value_size)
 
static RPC_STATUS rpcrt4_ncalrpc_inquire_auth_client (RpcConnection *conn, RPC_AUTHZ_HANDLE *privs, RPC_WSTR *server_princ_name, ULONG *authn_level, ULONG *authn_svc, ULONG *authz_svc, ULONG flags)
 
static size_t rpcrt4_ip_tcp_get_top_of_tower (unsigned char *tower_data, const char *networkaddr, unsigned char tcp_protid, const char *endpoint)
 
static RPC_STATUS rpcrt4_ip_tcp_parse_top_of_tower (const unsigned char *tower_data, size_t tower_size, char **networkaddr, unsigned char tcp_protid, char **endpoint)
 
static BOOL rpcrt4_sock_wait_init (RpcConnection_tcp *tcpc)
 
static BOOL rpcrt4_sock_wait_for_recv (RpcConnection_tcp *tcpc)
 
static BOOL rpcrt4_sock_wait_for_send (RpcConnection_tcp *tcpc)
 
static RpcConnectionrpcrt4_conn_tcp_alloc (void)
 
static RPC_STATUS rpcrt4_ncacn_ip_tcp_open (RpcConnection *Connection)
 
static RPC_STATUS rpcrt4_protseq_ncacn_ip_tcp_open_endpoint (RpcServerProtseq *protseq, const char *endpoint)
 
static RPC_STATUS rpcrt4_conn_tcp_handoff (RpcConnection *old_conn, RpcConnection *new_conn)
 
static int rpcrt4_conn_tcp_read (RpcConnection *Connection, void *buffer, unsigned int count)
 
static int rpcrt4_conn_tcp_write (RpcConnection *Connection, const void *buffer, unsigned int count)
 
static int rpcrt4_conn_tcp_close (RpcConnection *conn)
 
static void rpcrt4_conn_tcp_close_read (RpcConnection *conn)
 
static void rpcrt4_conn_tcp_cancel_call (RpcConnection *conn)
 
static RPC_STATUS rpcrt4_conn_tcp_is_server_listening (const char *endpoint)
 
static int rpcrt4_conn_tcp_wait_for_incoming_data (RpcConnection *Connection)
 
static size_t rpcrt4_ncacn_ip_tcp_get_top_of_tower (unsigned char *tower_data, const char *networkaddr, const char *endpoint)
 
static RpcServerProtseqrpcrt4_protseq_sock_alloc (void)
 
static void rpcrt4_protseq_sock_signal_state_changed (RpcServerProtseq *protseq)
 
static voidrpcrt4_protseq_sock_get_wait_array (RpcServerProtseq *protseq, void *prev_array, unsigned int *count)
 
static void rpcrt4_protseq_sock_free_wait_array (RpcServerProtseq *protseq, void *array)
 
static int rpcrt4_protseq_sock_wait_for_new_connection (RpcServerProtseq *protseq, unsigned int count, void *wait_array)
 
static RPC_STATUS rpcrt4_ncacn_ip_tcp_parse_top_of_tower (const unsigned char *tower_data, size_t tower_size, char **networkaddr, char **endpoint)
 
static ULONG RpcHttpAsyncData_AddRef (RpcHttpAsyncData *data)
 
static ULONG RpcHttpAsyncData_Release (RpcHttpAsyncData *data)
 
static void prepare_async_request (RpcHttpAsyncData *async_data)
 
static RPC_STATUS wait_async_request (RpcHttpAsyncData *async_data, BOOL call_ret, HANDLE cancel_event)
 
static RpcConnectionrpcrt4_ncacn_http_alloc (void)
 
static VOID rpcrt4_http_keep_connection_active_timer_proc (PVOID param, BOOLEAN dummy)
 
static DWORD rpcrt4_http_timer_calc_timeout (DWORD *last_sent_time)
 
static DWORD CALLBACK rpcrt4_http_timer_thread (PVOID param)
 
static VOID WINAPI rpcrt4_http_internet_callback (HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength)
 
static RPC_STATUS rpcrt4_http_check_response (HINTERNET hor)
 
static RPC_STATUS rpcrt4_http_internet_connect (RpcConnection_http *httpc)
 
static int rpcrt4_http_async_read (HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event, void *buffer, unsigned int count)
 
static RPC_STATUS send_echo_request (HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event)
 
static RPC_STATUS insert_content_length_header (HINTERNET request, DWORD len)
 
static RPC_STATUS rpcrt4_http_prepare_in_pipe (HINTERNET in_request, RpcHttpAsyncData *async_data, HANDLE cancel_event, const UUID *connection_uuid, const UUID *in_pipe_uuid, const UUID *association_uuid, BOOL authorized)
 
static RPC_STATUS rpcrt4_http_read_http_packet (HINTERNET request, RpcHttpAsyncData *async_data, HANDLE cancel_event, RpcPktHdr *hdr, BYTE **data)
 
static RPC_STATUS rpcrt4_http_prepare_out_pipe (HINTERNET out_request, RpcHttpAsyncData *async_data, HANDLE cancel_event, const UUID *connection_uuid, const UUID *out_pipe_uuid, ULONG *flow_control_increment, BOOL authorized)
 
static UINT encode_base64 (const char *bin, unsigned int len, WCHAR *base64)
 
static char decode_char (WCHAR c)
 
static unsigned int decode_base64 (const WCHAR *base64, unsigned int len, char *buf)
 
static struct authinfoalloc_authinfo (void)
 
static void destroy_authinfo (struct authinfo *info)
 
static DWORD auth_scheme_from_header (const WCHAR *header)
 
static BOOL get_authvalue (HINTERNET request, DWORD scheme, WCHAR *buffer, DWORD buflen)
 
static RPC_STATUS do_authorization (HINTERNET request, SEC_WCHAR *servername, const RPC_HTTP_TRANSPORT_CREDENTIALS_W *creds, struct authinfo **auth_ptr)
 
static RPC_STATUS insert_authorization_header (HINTERNET request, ULONG scheme, char *data, int data_len)
 
static void drain_content (HINTERNET request, RpcHttpAsyncData *async_data, HANDLE cancel_event)
 
static RPC_STATUS authorize_request (RpcConnection_http *httpc, HINTERNET request)
 
static BOOL has_credentials (RpcConnection_http *httpc)
 
static BOOL is_secure (RpcConnection_http *httpc)
 
static RPC_STATUS set_auth_cookie (RpcConnection_http *httpc, const WCHAR *value)
 
static RPC_STATUS rpcrt4_ncacn_http_open (RpcConnection *Connection)
 
static RPC_STATUS rpcrt4_ncacn_http_handoff (RpcConnection *old_conn, RpcConnection *new_conn)
 
static int rpcrt4_ncacn_http_read (RpcConnection *Connection, void *buffer, unsigned int count)
 
static RPC_STATUS rpcrt4_ncacn_http_receive_fragment (RpcConnection *Connection, RpcPktHdr **Header, void **Payload)
 
static int rpcrt4_ncacn_http_write (RpcConnection *Connection, const void *buffer, unsigned int count)
 
static int rpcrt4_ncacn_http_close (RpcConnection *Connection)
 
static void rpcrt4_ncacn_http_close_read (RpcConnection *conn)
 
static void rpcrt4_ncacn_http_cancel_call (RpcConnection *Connection)
 
static RPC_STATUS rpcrt4_ncacn_http_is_server_listening (const char *endpoint)
 
static int rpcrt4_ncacn_http_wait_for_incoming_data (RpcConnection *Connection)
 
static size_t rpcrt4_ncacn_http_get_top_of_tower (unsigned char *tower_data, const char *networkaddr, const char *endpoint)
 
static RPC_STATUS rpcrt4_ncacn_http_parse_top_of_tower (const unsigned char *tower_data, size_t tower_size, char **networkaddr, char **endpoint)
 
const struct protseq_opsrpcrt4_get_protseq_ops (const char *protseq)
 
static const struct connection_opsrpcrt4_get_conn_protseq_ops (const char *protseq)
 
RPC_STATUS RPCRT4_OpenClientConnection (RpcConnection *Connection)
 
RPC_STATUS RPCRT4_CloseConnection (RpcConnection *Connection)
 
RPC_STATUS RPCRT4_CreateConnection (RpcConnection **Connection, BOOL server, LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, RpcAuthInfo *AuthInfo, RpcQualityOfService *QOS, LPCWSTR CookieAuth)
 
void rpcrt4_conn_release_and_wait (RpcConnection *connection)
 
RpcConnectionRPCRT4_GrabConnection (RpcConnection *connection)
 
void RPCRT4_ReleaseConnection (RpcConnection *connection)
 
RPC_STATUS RPCRT4_IsServerListening (const char *protseq, const char *endpoint)
 
RPC_STATUS RpcTransport_GetTopOfTower (unsigned char *tower_data, size_t *tower_size, const char *protseq, const char *networkaddr, const char *endpoint)
 
RPC_STATUS RpcTransport_ParseTopOfTower (const unsigned char *tower_data, size_t tower_size, char **protseq, char **networkaddr, char **endpoint)
 
RPC_STATUS WINAPI RpcNetworkIsProtseqValidW (RPC_WSTR protseq)
 
RPC_STATUS WINAPI RpcNetworkIsProtseqValidA (RPC_CSTR protseq)
 
RPC_STATUS WINAPI RpcProtseqVectorFreeA (RPC_PROTSEQ_VECTORA **protseqs)
 
RPC_STATUS WINAPI RpcProtseqVectorFreeW (RPC_PROTSEQ_VECTORW **protseqs)
 
RPC_STATUS WINAPI RpcNetworkInqProtseqsW (RPC_PROTSEQ_VECTORW **protseqs)
 
RPC_STATUS WINAPI RpcNetworkInqProtseqsA (RPC_PROTSEQ_VECTORA **protseqs)
 

Variables

static const WCHAR basicW [] = {'B','a','s','i','c',0}
 
static const WCHAR ntlmW [] = {'N','T','L','M',0}
 
static const WCHAR passportW [] = {'P','a','s','s','p','o','r','t',0}
 
static const WCHAR digestW [] = {'D','i','g','e','s','t',0}
 
static const WCHAR negotiateW [] = {'N','e','g','o','t','i','a','t','e',0}
 
struct {
   const WCHAR *   str
 
   unsigned int   len
 
   DWORD   scheme
 
auth_schemes []
 
static const struct connection_ops conn_protseq_list []
 
static const struct protseq_ops protseq_list []
 

Macro Definition Documentation

◆ DEFAULT_NCACN_HTTP_TIMEOUT

#define DEFAULT_NCACN_HTTP_TIMEOUT   (60 * 1000)

Definition at line 57 of file rpc_transport.c.

◆ HTTP_IDLE_TIME

#define HTTP_IDLE_TIME   60000

Definition at line 1723 of file rpc_transport.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 27 of file rpc_transport.c.

Typedef Documentation

◆ HttpTimerThreadData

◆ RpcConnection_http

◆ RpcConnection_np

◆ RpcConnection_tcp

◆ RpcHttpAsyncData

◆ RpcServerProtseq_np

◆ RpcServerProtseq_sock

Function Documentation

◆ alloc_authinfo()

static struct authinfo* alloc_authinfo ( void  )
static

Definition at line 2433 of file rpc_transport.c.

2434 {
2435  struct authinfo *ret;
2436 
2437  if (!(ret = HeapAlloc(GetProcessHeap(), 0, sizeof(*ret) ))) return NULL;
2438 
2439  SecInvalidateHandle(&ret->cred);
2440  SecInvalidateHandle(&ret->ctx);
2441  memset(&ret->exp, 0, sizeof(ret->exp));
2442  ret->scheme = 0;
2443  ret->attr = 0;
2444  ret->max_token = 0;
2445  ret->data = NULL;
2446  ret->data_len = 0;
2447  ret->finished = FALSE;
2448  return ret;
2449 }
#define SecInvalidateHandle(x)
Definition: sspi.h:58
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
int ret
#define memset(x, y, z)
Definition: compat.h:39

Referenced by do_authorization().

◆ auth_scheme_from_header()

static DWORD auth_scheme_from_header ( const WCHAR header)
static

Definition at line 2485 of file rpc_transport.c.

2486 {
2487  unsigned int i;
2488  for (i = 0; i < ARRAY_SIZE(auth_schemes); i++)
2489  {
2491  (header[auth_schemes[i].len] == ' ' || !header[auth_schemes[i].len])) return auth_schemes[i].scheme;
2492  }
2493  return 0;
2494 }
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
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
static const struct @533 auth_schemes[]
const WCHAR * str
GLenum GLsizei len
Definition: glext.h:6722
#define ARRAY_SIZE(a)
Definition: main.h:24

Referenced by do_authorization(), and get_authvalue().

◆ authorize_request()

static RPC_STATUS authorize_request ( RpcConnection_http httpc,
HINTERNET  request 
)
static

Definition at line 2717 of file rpc_transport.c.

2718 {
2719  static const WCHAR authW[] = {'A','u','t','h','o','r','i','z','a','t','i','o','n',':','\r','\n',0};
2720  struct authinfo *info = NULL;
2722  BOOL ret;
2723 
2724  for (;;)
2725  {
2727  if (status != RPC_S_OK) break;
2728 
2729  status = insert_authorization_header(request, info->scheme, info->data, info->data_len);
2730  if (status != RPC_S_OK) break;
2731 
2733  ret = HttpSendRequestW(request, NULL, 0, NULL, 0);
2735  if (status != RPC_S_OK || info->finished) break;
2736 
2738  if (status != RPC_S_OK && status != ERROR_ACCESS_DENIED) break;
2739  drain_content(request, httpc->async_data, httpc->cancel_event);
2740  }
2741 
2742  if (info->scheme != RPC_C_HTTP_AUTHN_SCHEME_BASIC)
2744 
2746  return status;
2747 }
static void drain_content(HINTERNET request, RpcHttpAsyncData *async_data, HANDLE cancel_event)
RpcConnection common
#define RPC_C_HTTP_AUTHN_SCHEME_BASIC
Definition: rpcdce.h:205
static RPC_STATUS wait_async_request(RpcHttpAsyncData *async_data, BOOL call_ret, HANDLE cancel_event)
RPC_HTTP_TRANSPORT_CREDENTIALS_W * HttpCredentials
Definition: rpcdce.h:279
#define HTTP_ADDREQ_FLAG_REPLACE
Definition: wininet.h:1711
long RPC_STATUS
Definition: rpc.h:52
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
unsigned int BOOL
Definition: ntddk_ex.h:94
#define HTTP_ADDREQ_FLAG_ADD
Definition: wininet.h:1707
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders, DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength)
Definition: http.c:5631
static RPC_STATUS insert_authorization_header(HINTERNET request, ULONG scheme, char *data, int data_len)
static void prepare_async_request(RpcHttpAsyncData *async_data)
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
static RPC_STATUS do_authorization(HINTERNET request, SEC_WCHAR *servername, const RPC_HTTP_TRANSPORT_CREDENTIALS_W *creds, struct authinfo **auth_ptr)
BOOL WINAPI HttpAddRequestHeadersW(HINTERNET hHttpRequest, LPCWSTR lpszHeader, DWORD dwHeaderLength, DWORD dwModifier)
Definition: http.c:1396
static void destroy_authinfo(struct authinfo *info)
RPC_SECURITY_QOS_V2_W * qos
Definition: rpc_binding.h:57
union _RPC_SECURITY_QOS_V2_W::@3168 u
RpcHttpAsyncData * async_data
Definition: tftpd.h:85
static RPC_STATUS rpcrt4_http_check_response(HINTERNET hor)
RpcQualityOfService * QOS
Definition: rpc_binding.h:81
static SERVICE_STATUS status
Definition: service.c:31
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: ps.c:97

Referenced by rpcrt4_ncacn_http_open().

◆ decode_base64()

static unsigned int decode_base64 ( const WCHAR base64,
unsigned int  len,
char buf 
)
static

Definition at line 2371 of file rpc_transport.c.

2372 {
2373  unsigned int i = 0;
2374  char c0, c1, c2, c3;
2375  const WCHAR *p = base64;
2376 
2377  while (len > 4)
2378  {
2379  if ((c0 = decode_char( p[0] )) > 63) return 0;
2380  if ((c1 = decode_char( p[1] )) > 63) return 0;
2381  if ((c2 = decode_char( p[2] )) > 63) return 0;
2382  if ((c3 = decode_char( p[3] )) > 63) return 0;
2383 
2384  if (buf)
2385  {
2386  buf[i + 0] = (c0 << 2) | (c1 >> 4);
2387  buf[i + 1] = (c1 << 4) | (c2 >> 2);
2388  buf[i + 2] = (c2 << 6) | c3;
2389  }
2390  len -= 4;
2391  i += 3;
2392  p += 4;
2393  }
2394  if (p[2] == '=')
2395  {
2396  if ((c0 = decode_char( p[0] )) > 63) return 0;
2397  if ((c1 = decode_char( p[1] )) > 63) return 0;
2398 
2399  if (buf) buf[i] = (c0 << 2) | (c1 >> 4);
2400  i++;
2401  }
2402  else if (p[3] == '=')
2403  {
2404  if ((c0 = decode_char( p[0] )) > 63) return 0;
2405  if ((c1 = decode_char( p[1] )) > 63) return 0;
2406  if ((c2 = decode_char( p[2] )) > 63) return 0;
2407 
2408  if (buf)
2409  {
2410  buf[i + 0] = (c0 << 2) | (c1 >> 4);
2411  buf[i + 1] = (c1 << 4) | (c2 >> 2);
2412  }
2413  i += 2;
2414  }
2415  else
2416  {
2417  if ((c0 = decode_char( p[0] )) > 63) return 0;
2418  if ((c1 = decode_char( p[1] )) > 63) return 0;
2419  if ((c2 = decode_char( p[2] )) > 63) return 0;
2420  if ((c3 = decode_char( p[3] )) > 63) return 0;
2421 
2422  if (buf)
2423  {
2424  buf[i + 0] = (c0 << 2) | (c1 >> 4);
2425  buf[i + 1] = (c1 << 4) | (c2 >> 2);
2426  buf[i + 2] = (c2 << 6) | c3;
2427  }
2428  i += 3;
2429  }
2430  return i;
2431 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
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
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLsizei len
Definition: glext.h:6722
static char decode_char(WCHAR c)
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by do_authorization().

◆ decode_char()

static char decode_char ( WCHAR  c)
inlinestatic

Definition at line 2361 of file rpc_transport.c.

2362 {
2363  if (c >= 'A' && c <= 'Z') return c - 'A';
2364  if (c >= 'a' && c <= 'z') return c - 'a' + 26;
2365  if (c >= '0' && c <= '9') return c - '0' + 52;
2366  if (c == '+') return 62;
2367  if (c == '/') return 63;
2368  return 64;
2369 }
const GLubyte * c
Definition: glext.h:8905

Referenced by decode_base64().

◆ destroy_authinfo()

static void destroy_authinfo ( struct authinfo info)
static

Definition at line 2451 of file rpc_transport.c.

2452 {
2453  if (!info) return;
2454 
2455  if (SecIsValidHandle(&info->ctx))
2456  DeleteSecurityContext(&info->ctx);
2457  if (SecIsValidHandle(&info->cred))
2458  FreeCredentialsHandle(&info->cred);
2459 
2460  HeapFree(GetProcessHeap(), 0, info->data);
2461  HeapFree(GetProcessHeap(), 0, info);
2462 }
#define SecIsValidHandle(x)
Definition: sspi.h:63
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)
Definition: wrapper.c:151
#define GetProcessHeap()
Definition: compat.h:484
#define HeapFree(x, y, z)
Definition: compat.h:483
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:450

Referenced by authorize_request(), do_authorization(), and request_destroy().

◆ do_authorization()

static RPC_STATUS do_authorization ( HINTERNET  request,
SEC_WCHAR servername,
const RPC_HTTP_TRANSPORT_CREDENTIALS_W creds,
struct authinfo **  auth_ptr 
)
static

Definition at line 2508 of file rpc_transport.c.

2510 {
2511  struct authinfo *info = *auth_ptr;
2514 
2515  if ((!info && !(info = alloc_authinfo()))) return RPC_S_SERVER_UNAVAILABLE;
2516 
2517  switch (creds->AuthnSchemes[0])
2518  {
2520  {
2521  int userlen = WideCharToMultiByte(CP_UTF8, 0, id->User, id->UserLength, NULL, 0, NULL, NULL);
2522  int passlen = WideCharToMultiByte(CP_UTF8, 0, id->Password, id->PasswordLength, NULL, 0, NULL, NULL);
2523 
2524  info->data_len = userlen + passlen + 1;
2525  if (!(info->data = HeapAlloc(GetProcessHeap(), 0, info->data_len)))
2526  {
2528  break;
2529  }
2530  WideCharToMultiByte(CP_UTF8, 0, id->User, id->UserLength, info->data, userlen, NULL, NULL);
2531  info->data[userlen] = ':';
2532  WideCharToMultiByte(CP_UTF8, 0, id->Password, id->PasswordLength, info->data + userlen + 1, passlen, NULL, NULL);
2533 
2535  info->finished = TRUE;
2536  status = RPC_S_OK;
2537  break;
2538  }
2541  {
2542 
2543  static SEC_WCHAR ntlmW[] = {'N','T','L','M',0}, negotiateW[] = {'N','e','g','o','t','i','a','t','e',0};
2545  SecBufferDesc out_desc, in_desc;
2546  SecBuffer out, in;
2548  SEC_WCHAR *scheme;
2549  int scheme_len;
2550  const WCHAR *p;
2551  WCHAR auth_value[2048];
2552  DWORD size = sizeof(auth_value);
2553  BOOL first = FALSE;
2554 
2556  else scheme = negotiateW;
2557  scheme_len = lstrlenW( scheme );
2558 
2559  if (!*auth_ptr)
2560  {
2561  TimeStamp exp;
2562  SecPkgInfoW *pkg_info;
2563 
2565  if (ret != SEC_E_OK) break;
2566 
2567  ret = QuerySecurityPackageInfoW(scheme, &pkg_info);
2568  if (ret != SEC_E_OK) break;
2569 
2570  info->max_token = pkg_info->cbMaxToken;
2571  FreeContextBuffer(pkg_info);
2572  first = TRUE;
2573  }
2574  else
2575  {
2576  if (info->finished || !get_authvalue(request, creds->AuthnSchemes[0], auth_value, size)) break;
2577  if (auth_scheme_from_header(auth_value) != info->scheme)
2578  {
2579  ERR("authentication scheme changed\n");
2580  break;
2581  }
2582  }
2583  in.BufferType = SECBUFFER_TOKEN;
2584  in.cbBuffer = 0;
2585  in.pvBuffer = NULL;
2586 
2587  in_desc.ulVersion = 0;
2588  in_desc.cBuffers = 1;
2589  in_desc.pBuffers = &in;
2590 
2591  p = auth_value + scheme_len;
2592  if (!first && *p == ' ')
2593  {
2594  int len = lstrlenW(++p);
2595  in.cbBuffer = decode_base64(p, len, NULL);
2596  if (!(in.pvBuffer = HeapAlloc(GetProcessHeap(), 0, in.cbBuffer))) break;
2597  decode_base64(p, len, in.pvBuffer);
2598  }
2599  out.BufferType = SECBUFFER_TOKEN;
2600  out.cbBuffer = info->max_token;
2601  if (!(out.pvBuffer = HeapAlloc(GetProcessHeap(), 0, out.cbBuffer)))
2602  {
2603  HeapFree(GetProcessHeap(), 0, in.pvBuffer);
2604  break;
2605  }
2606  out_desc.ulVersion = 0;
2607  out_desc.cBuffers = 1;
2608  out_desc.pBuffers = &out;
2609 
2610  ret = InitializeSecurityContextW(first ? &info->cred : NULL, first ? NULL : &info->ctx,
2611  first ? servername : NULL, flags, 0, SECURITY_NETWORK_DREP,
2612  in.pvBuffer ? &in_desc : NULL, 0, &info->ctx, &out_desc,
2613  &info->attr, &info->exp);
2614  HeapFree(GetProcessHeap(), 0, in.pvBuffer);
2615  if (ret == SEC_E_OK)
2616  {
2617  HeapFree(GetProcessHeap(), 0, info->data);
2618  info->data = out.pvBuffer;
2619  info->data_len = out.cbBuffer;
2620  info->finished = TRUE;
2621  TRACE("sending last auth packet\n");
2622  status = RPC_S_OK;
2623  }
2624  else if (ret == SEC_I_CONTINUE_NEEDED)
2625  {
2626  HeapFree(GetProcessHeap(), 0, info->data);
2627  info->data = out.pvBuffer;
2628  info->data_len = out.cbBuffer;
2629  TRACE("sending next auth packet\n");
2630  status = RPC_S_OK;
2631  }
2632  else
2633  {
2634  ERR("InitializeSecurityContextW failed with error 0x%08x\n", ret);
2635  HeapFree(GetProcessHeap(), 0, out.pvBuffer);
2636  break;
2637  }
2638  info->scheme = creds->AuthnSchemes[0];
2639  break;
2640  }
2641  default:
2642  FIXME("scheme %u not supported\n", creds->AuthnSchemes[0]);
2643  break;
2644  }
2645 
2646  if (status != RPC_S_OK)
2647  {
2649  *auth_ptr = NULL;
2650  return status;
2651  }
2652  *auth_ptr = info;
2653  return RPC_S_OK;
2654 }
static struct authinfo * alloc_authinfo(void)
#define SECPKG_CRED_OUTBOUND
Definition: sspi.h:291
SEC_WINNT_AUTH_IDENTITY_W * TransportCredentials
Definition: rpcdce.h:245
static DWORD auth_scheme_from_header(const WCHAR *header)
#define WideCharToMultiByte
Definition: compat.h:111
SECURITY_STATUS WINAPI AcquireCredentialsHandleW(SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialsUse, PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn, PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
Definition: wrapper.c:105
WCHAR SEC_WCHAR
Definition: sspi.h:29
SECURITY_STATUS WINAPI FreeContextBuffer(PVOID pv)
Definition: sspi.c:699
#define TRUE
Definition: types.h:120
ULONG ulVersion
Definition: sspi.h:181
const GLint * first
Definition: glext.h:5794
#define RPC_C_HTTP_AUTHN_SCHEME_BASIC
Definition: rpcdce.h:205
DWORD scheme
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
#define ISC_REQ_DELEGATE
Definition: sspi.h:362
#define lstrlenW
Definition: compat.h:498
static const WCHAR negotiateW[]
struct _test_info info[]
Definition: SetCursorPos.c:19
long RPC_STATUS
Definition: rpc.h:52
#define FALSE
Definition: types.h:117
#define CP_UTF8
Definition: nls.h:20
#define RPC_S_OUT_OF_MEMORY
Definition: rpcnterr.h:24
unsigned int BOOL
Definition: ntddk_ex.h:94
ULONG cbMaxToken
Definition: sspi.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
#define SEC_I_CONTINUE_NEEDED
Definition: winerror.h:2927
static const WCHAR ntlmW[]
LONG SECURITY_STATUS
Definition: sspi.h:34
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
SECURITY_STATUS WINAPI InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext, SEC_WCHAR *pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
Definition: wrapper.c:301
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
#define RPC_C_HTTP_AUTHN_SCHEME_NTLM
Definition: rpcdce.h:206
int ret
#define RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE
Definition: rpcdce.h:209
#define SECBUFFER_TOKEN
Definition: sspi.h:161
GLenum GLsizei len
Definition: glext.h:6722
#define ISC_REQ_USE_DCE_STYLE
Definition: sspi.h:371
static void destroy_authinfo(struct authinfo *info)
#define SECURITY_NETWORK_DREP
Definition: sspi.h:474
#define SEC_E_OK
Definition: winerror.h:2356
#define ISC_REQ_CONNECTION
Definition: sspi.h:373
#define ERR(fmt,...)
Definition: debug.h:110
GLuint in
Definition: glext.h:9616
DWORD exp
Definition: msg.c:16033
#define ISC_REQ_MUTUAL_AUTH
Definition: sspi.h:363
static unsigned int decode_base64(const WCHAR *base64, unsigned int len, char *buf)
Definition: tftpd.h:85
unsigned int ULONG
Definition: retypes.h:1
GLenum GLuint id
Definition: glext.h:5579
GLfloat GLfloat p
Definition: glext.h:8902
static BOOL get_authvalue(HINTERNET request, DWORD scheme, WCHAR *buffer, DWORD buflen)
ULONG cBuffers
Definition: sspi.h:182
static SERVICE_STATUS status
Definition: service.c:31
#define HeapFree(x, y, z)
Definition: compat.h:483
SECURITY_STATUS WINAPI QuerySecurityPackageInfoW(SEC_WCHAR *pszPackageName, PSecPkgInfoW *ppPackageInfo)
Definition: wrapper.c:750
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: ps.c:97

Referenced by authorize_request().

◆ drain_content()

static void drain_content ( HINTERNET  request,
RpcHttpAsyncData async_data,
HANDLE  cancel_event 
)
static

Definition at line 2702 of file rpc_transport.c.

2703 {
2704  DWORD count, len = 0, size = sizeof(len);
2705  char buf[2048];
2706 
2708  if (!len) return;
2709  for (;;)
2710  {
2711  count = min(sizeof(buf), len);
2712  if (rpcrt4_http_async_read(request, async_data, cancel_event, buf, count) <= 0) return;
2713  len -= count;
2714  }
2715 }
#define HTTP_QUERY_CONTENT_LENGTH
Definition: wininet.h:1528
static int rpcrt4_http_async_read(HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event, void *buffer, unsigned int count)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int len
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
Definition: http.c:3883
GLenum GLsizei len
Definition: glext.h:6722
#define min(a, b)
Definition: monoChain.cc:55
#define HTTP_QUERY_FLAG_NUMBER
Definition: wininet.h:1606
Definition: tftpd.h:85

Referenced by authorize_request(), and rpcrt4_ncacn_http_open().

◆ encode_base64()

static UINT encode_base64 ( const char bin,
unsigned int  len,
WCHAR base64 
)
static

Definition at line 2321 of file rpc_transport.c.

2322 {
2323  static const char enc[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2324  UINT i = 0, x;
2325 
2326  while (len > 0)
2327  {
2328  /* first 6 bits, all from bin[0] */
2329  base64[i++] = enc[(bin[0] & 0xfc) >> 2];
2330  x = (bin[0] & 3) << 4;
2331 
2332  /* next 6 bits, 2 from bin[0] and 4 from bin[1] */
2333  if (len == 1)
2334  {
2335  base64[i++] = enc[x];
2336  base64[i++] = '=';
2337  base64[i++] = '=';
2338  break;
2339  }
2340  base64[i++] = enc[x | ((bin[1] & 0xf0) >> 4)];
2341  x = (bin[1] & 0x0f) << 2;
2342 
2343  /* next 6 bits 4 from bin[1] and 2 from bin[2] */
2344  if (len == 2)
2345  {
2346  base64[i++] = enc[x];
2347  base64[i++] = '=';
2348  break;
2349  }
2350  base64[i++] = enc[x | ((bin[2] & 0xc0) >> 6)];
2351 
2352  /* last 6 bits, all from bin [2] */
2353  base64[i++] = enc[bin[2] & 0x3f];
2354  bin += 3;
2355  len -= 3;
2356  }
2357  base64[i] = 0;
2358  return i;
2359 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
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
GLenum GLsizei len
Definition: glext.h:6722
unsigned int UINT
Definition: ndis.h:50
static struct _PeImage bin

Referenced by insert_authorization_header().

◆ get_authvalue()

static BOOL get_authvalue ( HINTERNET  request,
DWORD  scheme,
WCHAR buffer,
DWORD  buflen 
)
static

Definition at line 2496 of file rpc_transport.c.

2497 {
2498  DWORD len, index = 0;
2499  for (;;)
2500  {
2501  len = buflen;
2503  if (auth_scheme_from_header(buffer) == scheme) break;
2504  }
2505  return TRUE;
2506 }
static DWORD auth_scheme_from_header(const WCHAR *header)
#define TRUE
Definition: types.h:120
DWORD scheme
GLuint buffer
Definition: glext.h:5915
#define HTTP_QUERY_WWW_AUTHENTICATE
Definition: wininet.h:1563
unsigned int len
#define FALSE
Definition: types.h:117
GLuint index
Definition: glext.h:6031
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
Definition: http.c:3883
GLenum GLsizei len
Definition: glext.h:6722
Definition: tftpd.h:85

Referenced by do_authorization().

◆ get_np_event()

static HANDLE get_np_event ( RpcConnection_np connection)
static

Definition at line 97 of file rpc_transport.c.

98 {
99  HANDLE event = InterlockedExchangePointer(&connection->event_cache, NULL);
100  return event ? event : CreateEventW(NULL, TRUE, FALSE, NULL);
101 }
#define TRUE
Definition: types.h:120
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
struct _cl_event * event
Definition: glext.h:7739

Referenced by rpcrt4_conn_np_read(), rpcrt4_conn_np_write(), and rpcrt4_protseq_np_get_wait_array().

◆ has_credentials()

static BOOL has_credentials ( RpcConnection_http httpc)
static

Definition at line 2749 of file rpc_transport.c.

2750 {
2753 
2755  return FALSE;
2756 
2757  creds = httpc->common.QOS->qos->u.HttpCredentials;
2759  return FALSE;
2760 
2761  id = creds->TransportCredentials;
2762  if (!id || !id->User || !id->Password) return FALSE;
2763 
2764  return TRUE;
2765 }
SEC_WINNT_AUTH_IDENTITY_W * TransportCredentials
Definition: rpcdce.h:245
#define RPC_C_HTTP_AUTHN_TARGET_SERVER
Definition: rpcdce.h:202
#define TRUE
Definition: types.h:120
RpcConnection common
RPC_HTTP_TRANSPORT_CREDENTIALS_W * HttpCredentials
Definition: rpcdce.h:279
#define FALSE
Definition: types.h:117
RPC_SECURITY_QOS_V2_W * qos
Definition: rpc_binding.h:57
union _RPC_SECURITY_QOS_V2_W::@3168 u
ULONG AdditionalSecurityInfoType
Definition: rpcdce.h:276
GLenum GLuint id
Definition: glext.h:5579
#define RPC_C_AUTHN_INFO_TYPE_HTTP
Definition: rpcdce.h:195
RpcQualityOfService * QOS
Definition: rpc_binding.h:81

Referenced by rpcrt4_ncacn_http_open().

◆ insert_authorization_header()

static RPC_STATUS insert_authorization_header ( HINTERNET  request,
ULONG  scheme,
char data,
int  data_len 
)
static

Definition at line 2656 of file rpc_transport.c.

2657 {
2658  static const WCHAR authW[] = {'A','u','t','h','o','r','i','z','a','t','i','o','n',':',' '};
2659  static const WCHAR basicW[] = {'B','a','s','i','c',' '};
2660  static const WCHAR negotiateW[] = {'N','e','g','o','t','i','a','t','e',' '};
2661  static const WCHAR ntlmW[] = {'N','T','L','M',' '};
2662  int scheme_len, auth_len = ARRAY_SIZE(authW), len = ((data_len + 2) * 4) / 3;
2663  const WCHAR *scheme_str;
2664  WCHAR *header, *ptr;
2666 
2667  switch (scheme)
2668  {
2670  scheme_str = basicW;
2671  scheme_len = ARRAY_SIZE(basicW);
2672  break;
2674  scheme_str = negotiateW;
2675  scheme_len = ARRAY_SIZE(negotiateW);
2676  break;
2678  scheme_str = ntlmW;
2679  scheme_len = ARRAY_SIZE(ntlmW);
2680  break;
2681  default:
2682  ERR("unknown scheme %u\n", scheme);
2683  return RPC_S_SERVER_UNAVAILABLE;
2684  }
2685  if ((header = HeapAlloc(GetProcessHeap(), 0, (auth_len + scheme_len + len + 2) * sizeof(WCHAR))))
2686  {
2687  memcpy(header, authW, auth_len * sizeof(WCHAR));
2688  ptr = header + auth_len;
2689  memcpy(ptr, scheme_str, scheme_len * sizeof(WCHAR));
2690  ptr += scheme_len;
2692  ptr[len++] = '\r';
2693  ptr[len++] = '\n';
2694  ptr[len] = 0;
2696  status = RPC_S_OK;
2698  }
2699  return status;
2700 }
static const WCHAR basicW[]
#define RPC_C_HTTP_AUTHN_SCHEME_BASIC
Definition: rpcdce.h:205
DWORD scheme
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
static const WCHAR negotiateW[]
#define HTTP_ADDREQ_FLAG_REPLACE
Definition: wininet.h:1711
unsigned int len
long RPC_STATUS
Definition: rpc.h:52
static PVOID ptr
Definition: dispmode.c:27
#define HTTP_ADDREQ_FLAG_ADD
Definition: wininet.h:1707
static const WCHAR ntlmW[]
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned int data_len
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define RPC_C_HTTP_AUTHN_SCHEME_NTLM
Definition: rpcdce.h:206
#define RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE
Definition: rpcdce.h:209
BOOL WINAPI HttpAddRequestHeadersW(HINTERNET hHttpRequest, LPCWSTR lpszHeader, DWORD dwHeaderLength, DWORD dwModifier)
Definition: http.c:1396
static UINT encode_base64(const char *bin, unsigned int len, WCHAR *base64)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define ERR(fmt,...)
Definition: debug.h:110
#define ARRAY_SIZE(a)
Definition: main.h:24
Definition: tftpd.h:85
static SERVICE_STATUS status
Definition: service.c:31
#define HeapFree(x, y, z)
Definition: compat.h:483
struct CFHEADER header
Definition: fdi.c:101
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: ps.c:97

Referenced by authorize_request().

◆ insert_content_length_header()

static RPC_STATUS insert_content_length_header ( HINTERNET  request,
DWORD  len 
)
static

Definition at line 2145 of file rpc_transport.c.

2146 {
2147  static const WCHAR fmtW[] =
2148  {'C','o','n','t','e','n','t','-','L','e','n','g','t','h',':',' ','%','u','\r','\n',0};
2149  WCHAR header[ARRAY_SIZE(fmtW) + 10];
2150 
2151  swprintf(header, fmtW, len);
2153  return RPC_S_SERVER_UNAVAILABLE;
2154 }
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
#define HTTP_ADDREQ_FLAG_REPLACE
Definition: wininet.h:1711
#define HTTP_ADDREQ_FLAG_ADD
Definition: wininet.h:1707
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define swprintf(buf, format,...)
Definition: sprintf.c:56
BOOL WINAPI HttpAddRequestHeadersW(HINTERNET hHttpRequest, LPCWSTR lpszHeader, DWORD dwHeaderLength, DWORD dwModifier)
Definition: http.c:1396
GLenum GLsizei len
Definition: glext.h:6722
#define ARRAY_SIZE(a)
Definition: main.h:24
Definition: tftpd.h:85
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by rpcrt4_http_prepare_in_pipe(), and rpcrt4_http_prepare_out_pipe().

◆ is_pipe_listening()

static RPC_STATUS is_pipe_listening ( const char pipe_name)
static

Definition at line 397 of file rpc_transport.c.

398 {
399  return WaitNamedPipeA(pipe_name, 1) ? RPC_S_OK : RPC_S_NOT_LISTENING;
400 }
BOOL WINAPI WaitNamedPipeA(LPCSTR lpNamedPipeName, DWORD nTimeOut)
Definition: npipe.c:433
#define RPC_S_NOT_LISTENING
Definition: winerror.h:1026
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by rpcrt4_ncacn_np_is_server_listening(), and rpcrt4_ncalrpc_np_is_server_listening().

◆ is_secure()

static BOOL is_secure ( RpcConnection_http httpc)
static

Definition at line 2767 of file rpc_transport.c.

2768 {
2769  return httpc->common.QOS &&
2772 }
RpcConnection common
RPC_HTTP_TRANSPORT_CREDENTIALS_W * HttpCredentials
Definition: rpcdce.h:279
RPC_SECURITY_QOS_V2_W * qos
Definition: rpc_binding.h:57
union _RPC_SECURITY_QOS_V2_W::@3168 u
ULONG AdditionalSecurityInfoType
Definition: rpcdce.h:276
#define RPC_C_HTTP_FLAG_USE_SSL
Definition: rpcdce.h:198
#define RPC_C_AUTHN_INFO_TYPE_HTTP
Definition: rpcdce.h:195
RpcQualityOfService * QOS
Definition: rpc_binding.h:81

Referenced by open_connection(), rpcrt4_ncacn_http_open(), and set_auth_cookie().

◆ ncacn_pipe_name()

static char* ncacn_pipe_name ( const char endpoint)
static

Definition at line 263 of file rpc_transport.c.

265 {
266 #ifdef __REACTOS__
267  static const char prefix[] = "\\\\";
268  static const char local[] = ".";
269  char ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
270  DWORD bufLen = ARRAY_SIZE(ComputerName);
271 #else
272  static const char prefix[] = "\\\\.";
273 #endif
274  char *pipe_name;
275 
276 #ifdef __REACTOS__
277  if (server != NULL && *server != 0)
278  {
279  /* Trim any leading UNC server prefix. */
280  if (server[0] == '\\' && server[1] == '\\')
281  server += 2;
282 
283  /* If the server represents the local computer, use instead
284  * the local prefix to avoid a round in UNC name resolution. */
285  if (GetComputerNameA(ComputerName, &bufLen) &&
286  (stricmp(ComputerName, server) == 0))
287  {
288  server = local;
289  }
290  }
291  else
292  {
293  server = local;
294  }
295 #endif
296 
297  /* protseq=ncacn_np: named pipes */
298 #ifdef __REACTOS__
299  pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(server) + strlen(endpoint));
300  strcpy(pipe_name, prefix);
301  strcat(pipe_name, server);
302  strcat(pipe_name, endpoint);
303 #else
304  pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(endpoint));
305  strcat(strcpy(pipe_name, prefix), endpoint);
306 #endif
307  return pipe_name;
308 }
BOOL WINAPI SHIM_OBJ_NAME() GetComputerNameA(LPSTR lpBuffer, LPDWORD lpnSize)
Definition: shimtest.c:21
static rfbScreenInfoPtr server
Definition: vnc.c:74
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
smooth NULL
Definition: ftsmooth.c:416
_Check_return_ _CRTIMP int __cdecl stricmp(_In_z_ const char *_Str1, _In_z_ const char *_Str2)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define local
Definition: zutil.h:30
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:240
Definition: nis.h:10
#define ARRAY_SIZE(a)
Definition: main.h:24
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
void *WINAPI I_RpcAllocate(unsigned int Size)
Definition: rpcrt4_main.c:714

Referenced by rpcrt4_ncacn_np_is_server_listening(), rpcrt4_ncacn_np_open(), and rpcrt4_protseq_ncacn_np_open_endpoint().

◆ ncalrpc_pipe_name()

static char* ncalrpc_pipe_name ( const char endpoint)
static

Definition at line 199 of file rpc_transport.c.

200 {
201  static const char prefix[] = "\\\\.\\pipe\\lrpc\\";
202  char *pipe_name;
203 
204  /* protseq=ncalrpc: supposed to use NT LPC ports,
205  * but we'll implement it with named pipes for now */
206  pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(endpoint));
207  strcat(strcpy(pipe_name, prefix), endpoint);
208  return pipe_name;
209 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
Definition: nis.h:10
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
void *WINAPI I_RpcAllocate(unsigned int Size)
Definition: rpcrt4_main.c:714

Referenced by rpcrt4_ncalrpc_np_is_server_listening(), rpcrt4_ncalrpc_open(), and rpcrt4_protseq_ncalrpc_open_endpoint().

◆ prepare_async_request()

static void prepare_async_request ( RpcHttpAsyncData async_data)
static

Definition at line 1757 of file rpc_transport.c.

1758 {
1759  ResetEvent(async_data->completion_event);
1760  RpcHttpAsyncData_AddRef(async_data);
1761 }
static ULONG RpcHttpAsyncData_AddRef(RpcHttpAsyncData *data)
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714

Referenced by authorize_request(), rpcrt4_http_async_read(), rpcrt4_http_prepare_in_pipe(), rpcrt4_http_prepare_out_pipe(), rpcrt4_ncacn_http_wait_for_incoming_data(), and send_echo_request().

◆ release_np_event()

static void release_np_event ( RpcConnection_np connection,
HANDLE  event 
)
static

Definition at line 103 of file rpc_transport.c.

104 {
105  event = InterlockedExchangePointer(&connection->event_cache, event);
106  if (event)
108 }
#define CloseHandle
Definition: compat.h:487
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
struct _cl_event * event
Definition: glext.h:7739

Referenced by rpcrt4_conn_np_read(), rpcrt4_conn_np_write(), and rpcrt4_protseq_np_wait_for_new_connection().

◆ RpcHttpAsyncData_AddRef()

static ULONG RpcHttpAsyncData_AddRef ( RpcHttpAsyncData data)
static

Definition at line 1737 of file rpc_transport.c.

1738 {
1739  return InterlockedIncrement(&data->refs);
1740 }
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define InterlockedIncrement
Definition: armddk.h:53

Referenced by prepare_async_request().

◆ RpcHttpAsyncData_Release()

static ULONG RpcHttpAsyncData_Release ( RpcHttpAsyncData data)
static

Definition at line 1742 of file rpc_transport.c.

1743 {
1744  ULONG refs = InterlockedDecrement(&data->refs);
1745  if (!refs)
1746  {
1747  TRACE("destroying async data %p\n", data);
1748  CloseHandle(data->completion_event);
1749  HeapFree(GetProcessHeap(), 0, data->inet_buffers.lpvBuffer);
1750  data->cs.DebugInfo->Spare[0] = 0;
1752  HeapFree(GetProcessHeap(), 0, data);
1753  }
1754  return refs;
1755 }
#define CloseHandle
Definition: compat.h:487
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:483

Referenced by rpcrt4_http_internet_callback(), rpcrt4_ncacn_http_close(), and wait_async_request().

◆ RpcNetworkInqProtseqsA()

RPC_STATUS WINAPI RpcNetworkInqProtseqsA ( RPC_PROTSEQ_VECTORA **  protseqs)

Definition at line 3719 of file rpc_transport.c.

3720 {
3721  RPC_PROTSEQ_VECTORA *pvector;
3722  unsigned int i;
3724 
3725  TRACE("(%p)\n", protseqs);
3726 
3727  *protseqs = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_PROTSEQ_VECTORW)+(sizeof(unsigned char*)*ARRAY_SIZE(protseq_list)));
3728  if (!*protseqs)
3729  goto end;
3730  pvector = *protseqs;
3731  pvector->Count = 0;
3732  for (i = 0; i < ARRAY_SIZE(protseq_list); i++)
3733  {
3734  pvector->Protseq[i] = HeapAlloc(GetProcessHeap(), 0, strlen(protseq_list[i].name)+1);
3735  if (pvector->Protseq[i] == NULL)
3736  goto end;
3737  strcpy((char*)pvector->Protseq[i], protseq_list[i].name);
3738  pvector->Count++;
3739  }
3740  status = RPC_S_OK;
3741 
3742 end:
3743  if (status != RPC_S_OK)
3745  return status;
3746 }
static struct list protseqs
Definition: rpc_server.c:68
unsigned char * Protseq[1]
Definition: rpcdce.h:91
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
unsigned int Count
Definition: rpcdce.h:90
GLuint GLuint end
Definition: gl.h:1545
static const struct protseq_ops protseq_list[]
long RPC_STATUS
Definition: rpc.h:52
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
#define RPC_S_OUT_OF_MEMORY
Definition: rpcnterr.h:24
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
RPC_STATUS WINAPI RpcProtseqVectorFreeA(RPC_PROTSEQ_VECTORA **protseqs)
#define ARRAY_SIZE(a)
Definition: main.h:24
Definition: name.c:38
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
static SERVICE_STATUS status
Definition: service.c:31
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: ps.c:97

◆ RpcNetworkInqProtseqsW()

RPC_STATUS WINAPI RpcNetworkInqProtseqsW ( RPC_PROTSEQ_VECTORW **  protseqs)

Definition at line 3686 of file rpc_transport.c.

3687 {
3688  RPC_PROTSEQ_VECTORW *pvector;
3689  unsigned int i;
3691 
3692  TRACE("(%p)\n", protseqs);
3693 
3694  *protseqs = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_PROTSEQ_VECTORW)+(sizeof(unsigned short*)*ARRAY_SIZE(protseq_list)));
3695  if (!*protseqs)
3696  goto end;
3697  pvector = *protseqs;
3698  pvector->Count = 0;
3699  for (i = 0; i < ARRAY_SIZE(protseq_list); i++)
3700  {
3701  pvector->Protseq[i] = HeapAlloc(GetProcessHeap(), 0, (strlen(protseq_list[i].name)+1)*sizeof(unsigned short));
3702  if (pvector->Protseq[i] == NULL)
3703  goto end;
3705  (WCHAR*)pvector->Protseq[i], strlen(protseq_list[i].name) + 1);
3706  pvector->Count++;
3707  }
3708  status = RPC_S_OK;
3709 
3710 end:
3711  if (status != RPC_S_OK)
3713  return status;
3714 }
static struct list protseqs
Definition: rpc_server.c:68
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define CP_ACP
Definition: compat.h:109
char CHAR
Definition: xmlstorage.h:175
unsigned int Count
Definition: rpcdce.h:96
GLuint GLuint end
Definition: gl.h:1545
static const struct protseq_ops protseq_list[]
long RPC_STATUS
Definition: rpc.h:52
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
#define RPC_S_OUT_OF_MEMORY
Definition: rpcnterr.h:24
RPC_STATUS WINAPI RpcProtseqVectorFreeW(RPC_PROTSEQ_VECTORW **protseqs)
smooth NULL
Definition: ftsmooth.c:416
unsigned short * Protseq[1]
Definition: rpcdce.h:97
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ARRAY_SIZE(a)
Definition: main.h:24
#define MultiByteToWideChar
Definition: compat.h:110
Definition: name.c:38
static SERVICE_STATUS status
Definition: service.c:31
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: ps.c:97

◆ RpcNetworkIsProtseqValidA()

RPC_STATUS WINAPI RpcNetworkIsProtseqValidA ( RPC_CSTR  protseq)

Definition at line 3634 of file rpc_transport.c.

3635 {
3636  UNICODE_STRING protseqW;
3637 
3638  if (RtlCreateUnicodeStringFromAsciiz(&protseqW, (char*)protseq))
3639  {
3641  RtlFreeUnicodeString(&protseqW);
3642  return ret;
3643  }
3644  return RPC_S_OUT_OF_MEMORY;
3645 }
long RPC_STATUS
Definition: rpc.h:52
#define RPC_S_OUT_OF_MEMORY
Definition: rpcnterr.h:24
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
int ret
RPC_STATUS WINAPI RpcNetworkIsProtseqValidW(RPC_WSTR protseq)

Referenced by test_rpc_ncacn_ip_tcp().

◆ RpcNetworkIsProtseqValidW()

RPC_STATUS WINAPI RpcNetworkIsProtseqValidW ( RPC_WSTR  protseq)

Definition at line 3617 of file rpc_transport.c.

3618 {
3619  char ps[0x10];
3620 
3621  WideCharToMultiByte(CP_ACP, 0, protseq, -1,
3622  ps, sizeof ps, NULL, NULL);
3624  return RPC_S_OK;
3625 
3626  FIXME("Unknown protseq %s\n", debugstr_w(protseq));
3627 
3629 }
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
static const struct connection_ops * rpcrt4_get_conn_protseq_ops(const char *protseq)
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
#define RPC_S_INVALID_RPC_PROTSEQ
Definition: winerror.h:1015
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by RpcNetworkIsProtseqValidA().

◆ RpcProtseqVectorFreeA()

RPC_STATUS WINAPI RpcProtseqVectorFreeA ( RPC_PROTSEQ_VECTORA **  protseqs)

Definition at line 3650 of file rpc_transport.c.

3651 {
3652  TRACE("(%p)\n", protseqs);
3653 
3654  if (*protseqs)
3655  {
3656  unsigned int i;
3657  for (i = 0; i < (*protseqs)->Count; i++)
3658  HeapFree(GetProcessHeap(), 0, (*protseqs)->Protseq[i]);
3660  *protseqs = NULL;
3661  }
3662  return RPC_S_OK;
3663 }
static struct list protseqs
Definition: rpc_server.c:68
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
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
#define HeapFree(x, y, z)
Definition: compat.h:483
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by RpcNetworkInqProtseqsA().

◆ RpcProtseqVectorFreeW()

RPC_STATUS WINAPI RpcProtseqVectorFreeW ( RPC_PROTSEQ_VECTORW **  protseqs)

Definition at line 3668 of file rpc_transport.c.

3669 {
3670  TRACE("(%p)\n", protseqs);
3671 
3672  if (*protseqs)
3673  {
3674  unsigned int i;
3675  for (i = 0; i < (*protseqs)->Count; i++)
3676  HeapFree(GetProcessHeap(), 0, (*protseqs)->Protseq[i]);
3678  *protseqs = NULL;
3679  }
3680  return RPC_S_OK;
3681 }
static struct list protseqs
Definition: rpc_server.c:68
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
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
#define HeapFree(x, y, z)
Definition: compat.h:483
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by RpcNetworkInqProtseqsW().

◆ RPCRT4_CloseConnection()

RPC_STATUS RPCRT4_CloseConnection ( RpcConnection Connection)

Definition at line 3366 of file rpc_transport.c.

3367 {
3368  TRACE("(Connection == ^%p)\n", Connection);
3369  if (SecIsValidHandle(&Connection->ctx))
3370  {
3371  DeleteSecurityContext(&Connection->ctx);
3372  SecInvalidateHandle(&Connection->ctx);
3373  }
3374  rpcrt4_conn_close(Connection);
3375  return RPC_S_OK;
3376 }
static int rpcrt4_conn_close(RpcConnection *Connection)
Definition: rpc_binding.h:200
#define SecIsValidHandle(x)
Definition: sspi.h:63
#define SecInvalidateHandle(x)
Definition: sspi.h:58
#define TRACE(s)
Definition: solgame.cpp:4
CtxtHandle ctx
Definition: rpc_binding.h:74
#define RPC_S_OK
Definition: rpcnterr.h:22
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:450

Referenced by RPCRT4_ReleaseConnection(), and RPCRT4_server_thread().

◆ rpcrt4_conn_create_pipe()

static RPC_STATUS rpcrt4_conn_create_pipe ( RpcConnection conn)
static

Definition at line 110 of file rpc_transport.c.

111 {
112  RpcConnection_np *connection = (RpcConnection_np *) conn;
113 
114  TRACE("listening on %s\n", connection->listen_pipe);
115 
120  if (connection->pipe == INVALID_HANDLE_VALUE)
121  {
122  WARN("CreateNamedPipe failed with error %d\n", GetLastError());
125  else
127  }
128 
129  return RPC_S_OK;
130 }
#define PIPE_UNLIMITED_INSTANCES
Definition: winbase.h:175
#define ERROR_FILE_EXISTS
Definition: winerror.h:165
#define PIPE_TYPE_MESSAGE
Definition: winbase.h:168
HANDLE WINAPI CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: npipe.c:220
#define WARN(fmt,...)
Definition: debug.h:112
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
smooth NULL
Definition: ftsmooth.c:416
#define RPC_S_DUPLICATE_ENDPOINT
Definition: winerror.h:1048
#define TRACE(s)
Definition: solgame.cpp:4
#define PIPE_ACCESS_DUPLEX
Definition: winbase.h:164
#define PIPE_READMODE_MESSAGE
Definition: winbase.h:170
#define RPC_MAX_PACKET_SIZE
Definition: rpc_defs.h:184
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define RPC_S_OK
Definition: rpcnterr.h:22
#define RPC_S_CANT_CREATE_ENDPOINT
Definition: winerror.h:1031

Referenced by rpcrt4_ncacn_np_handoff(), rpcrt4_ncalrpc_handoff(), rpcrt4_protseq_ncacn_np_open_endpoint(), rpcrt4_protseq_ncalrpc_open_endpoint(), and rpcrt4_protseq_np_get_wait_array().

◆ rpcrt4_conn_np_alloc()

static RpcConnection* rpcrt4_conn_np_alloc ( void  )
static

Definition at line 91 of file rpc_transport.c.

92 {
94  return &npc->common;
95 }
RpcConnection common
Definition: rpc_transport.c:82
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define HEAP_ZERO_MEMORY
Definition: compat.h:134

◆ rpcrt4_conn_np_cancel_call()

static void rpcrt4_conn_np_cancel_call ( RpcConnection conn)
static

Definition at line 542 of file rpc_transport.c.

543 {
544  RpcConnection_np *connection = (RpcConnection_np *)conn;
545  CancelIoEx(connection->pipe, NULL);
546 }
smooth NULL
Definition: ftsmooth.c:416

◆ rpcrt4_conn_np_close()

static int rpcrt4_conn_np_close ( RpcConnection conn)
static

Definition at line 507 of file rpc_transport.c.

508 {
509  RpcConnection_np *connection = (RpcConnection_np *) conn;
510  if (connection->pipe)
511  {
512  FlushFileBuffers(connection->pipe);
513  CloseHandle(connection->pipe);
514  connection->pipe = 0;
515  }
516  if (connection->listen_event)
517  {
518  CloseHandle(connection->listen_event);
519  connection->listen_event = 0;
520  }
521  if (connection->event_cache)
522  {
523  CloseHandle(connection->event_cache);
524  connection->event_cache = 0;
525  }
526  return 0;
527 }
#define CloseHandle
Definition: compat.h:487
BOOL WINAPI FlushFileBuffers(IN HANDLE hFile)
Definition: fileinfo.c:175

◆ rpcrt4_conn_np_close_read()

static void rpcrt4_conn_np_close_read ( RpcConnection conn)
static

Definition at line 529 of file rpc_transport.c.

530 {
531  RpcConnection_np *connection = (RpcConnection_np*)conn;
533 
534  connection->read_closed = TRUE;
535 #ifdef __REACTOS__ /* FIXME: We should also cancel I/O for other threads */
536  NtCancelIoFile(connection->pipe, &io_status);
537 #else
538  NtCancelIoFileEx(connection->pipe, &connection->io_status, &io_status);
539 #endif
540 }
#define TRUE
Definition: types.h:120
static HANDLE PIO_APC_ROUTINE void PIO_STATUS_BLOCK io_status
Definition: comm.c:54
IO_STATUS_BLOCK io_status
Definition: rpc_transport.c:86
NTSYSAPI NTSTATUS WINAPI NtCancelIoFileEx(HANDLE, PIO_STATUS_BLOCK, PIO_STATUS_BLOCK)
NTSTATUS NTAPI NtCancelIoFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock)
Definition: file.c:4018

◆ rpcrt4_conn_np_handoff()

static void rpcrt4_conn_np_handoff ( RpcConnection_np old_npc,
RpcConnection_np new_npc 
)
static

Definition at line 367 of file rpc_transport.c.

368 {
369  /* because of the way named pipes work, we'll transfer the connected pipe
370  * to the child, then reopen the server binding to continue listening */
371 
372  new_npc->pipe = old_npc->pipe;
373  old_npc->pipe = 0;
374  assert(!old_npc->listen_event);
375 }
#define assert(x)
Definition: debug.h:53

Referenced by rpcrt4_ncacn_np_handoff(), and rpcrt4_ncalrpc_handoff().

◆ rpcrt4_conn_np_impersonate_client()

static RPC_STATUS rpcrt4_conn_np_impersonate_client ( RpcConnection conn)
static

Definition at line 666 of file rpc_transport.c.

667 {
668  RpcConnection_np *npc = (RpcConnection_np *)conn;
669  BOOL ret;
670 
671  TRACE("(%p)\n", conn);
672 
673  if (conn->AuthInfo && SecIsValidHandle(&conn->ctx))
675 
677  if (!ret)
678  {
680  WARN("ImpersonateNamedPipeClient failed with error %u\n", error);
681  switch (error)
682  {
685  }
686  }
687  return RPC_S_OK;
688 }
BOOL WINAPI ImpersonateNamedPipeClient(HANDLE hNamedPipe)
Definition: security.c:903
#define error(str)
Definition: mkdosfs.c:1605
#define RPC_S_NO_CONTEXT_AVAILABLE
Definition: winerror.h:1073
#define SecIsValidHandle(x)
Definition: sspi.h:63
#define WARN(fmt,...)
Definition: debug.h:112
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ERROR_CANNOT_IMPERSONATE
Definition: winerror.h:849
unsigned int BOOL
Definition: ntddk_ex.h:94
RPC_STATUS RPCRT4_default_impersonate_client(RpcConnection *conn)
Definition: rpc_message.c:1131
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
CtxtHandle ctx
Definition: rpc_binding.h:74
RpcAuthInfo * AuthInfo
Definition: rpc_binding.h:77
#define RPC_S_OK
Definition: rpcnterr.h:22

◆ rpcrt4_conn_np_read()

static int rpcrt4_conn_np_read ( RpcConnection conn,
void buffer,
unsigned int  count 
)
static

Definition at line 449 of file rpc_transport.c.

450 {
451  RpcConnection_np *connection = (RpcConnection_np *) conn;
452  HANDLE event;
454 
455  event = get_np_event(connection);
456  if (!event)
457  return -1;
458 
459  if (connection->read_closed)
461  else
462  status = NtReadFile(connection->pipe, event, NULL, NULL, &connection->io_status, buffer, count, NULL, NULL);
463  if (status == STATUS_PENDING)
464  {
465  /* check read_closed again before waiting to avoid a race */
466  if (connection->read_closed)
467  {
469 #ifdef __REACTOS__ /* FIXME: We should also cancel I/O for other threads */
470  NtCancelIoFile(connection->pipe, &io_status);
471 #else
472  NtCancelIoFileEx(connection->pipe, &connection->io_status, &io_status);
473 #endif
474  }
476  status = connection->io_status.u.Status;
477  }
478  release_np_event(connection, event);
479  return status && status != STATUS_BUFFER_OVERFLOW ? -1 : connection->io_status.Information;
480 }
static HANDLE get_np_event(RpcConnection_np *connection)
Definition: rpc_transport.c:97
GLuint GLuint GLsizei count
Definition: gl.h:1545
LONG NTSTATUS
Definition: precomp.h:26
static HANDLE PIO_APC_ROUTINE void PIO_STATUS_BLOCK io_status
Definition: comm.c:54
GLuint buffer
Definition: glext.h:5915
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
IO_STATUS_BLOCK io_status
Definition: rpc_transport.c:86
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
NTSYSAPI NTSTATUS WINAPI NtCancelIoFileEx(HANDLE, PIO_STATUS_BLOCK, PIO_STATUS_BLOCK)
struct _cl_event * event
Definition: glext.h:7739
static void release_np_event(RpcConnection_np *connection, HANDLE event)
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
NTSTATUS NTAPI NtCancelIoFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock)
Definition: file.c:4018
#define INFINITE
Definition: serial.h:102
static SERVICE_STATUS status
Definition: service.c:31
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
Definition: ps.c:97

Referenced by rpcrt4_conn_np_wait_for_incoming_data().

◆ rpcrt4_conn_np_revert_to_self()

static RPC_STATUS rpcrt4_conn_np_revert_to_self ( RpcConnection conn)
static

Definition at line 690 of file rpc_transport.c.

691 {
692  BOOL ret;
693 
694  TRACE("(%p)\n", conn);
695 
696  if (conn->AuthInfo && SecIsValidHandle(&conn->ctx))
697  return RPCRT4_default_revert_to_self(conn);
698 
699  ret = RevertToSelf();
700  if (!ret)
701  {
702  WARN("RevertToSelf failed with error %u\n", GetLastError());
704  }
705  return RPC_S_OK;
706 }
RPC_STATUS RPCRT4_default_revert_to_self(RpcConnection *conn)
Definition: rpc_message.c:1159
#define RPC_S_NO_CONTEXT_AVAILABLE
Definition: winerror.h:1073
BOOL WINAPI RevertToSelf(VOID)
Definition: security.c:1487
#define SecIsValidHandle(x)
Definition: sspi.h:63
#define WARN(fmt,...)
Definition: debug.h:112
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
int ret
CtxtHandle ctx
Definition: rpc_binding.h:74
RpcAuthInfo * AuthInfo
Definition: rpc_binding.h:77
#define RPC_S_OK
Definition: rpcnterr.h:22

◆ rpcrt4_conn_np_wait_for_incoming_data()

static int rpcrt4_conn_np_wait_for_incoming_data ( RpcConnection conn)
static

Definition at line 548 of file rpc_transport.c.

549 {
550  return rpcrt4_conn_np_read(conn, NULL, 0);
551 }
static int rpcrt4_conn_np_read(RpcConnection *conn, void *buffer, unsigned int count)
smooth NULL
Definition: ftsmooth.c:416

◆ rpcrt4_conn_np_write()

static int rpcrt4_conn_np_write ( RpcConnection conn,
const void buffer,
unsigned int  count 
)
static

Definition at line 482 of file rpc_transport.c.

483 {
484  RpcConnection_np *connection = (RpcConnection_np *) conn;
486  HANDLE event;
488 
489  event = get_np_event(connection);
490  if (!event)
491  return -1;
492 
493  status = NtWriteFile(connection->pipe, event, NULL, NULL, &io_status, buffer, count, NULL, NULL);
494  if (status == STATUS_PENDING)
495  {
497  status = io_status.u.Status;
498  }
499  release_np_event(connection, event);
500  if (status)
501  return -1;
502 
503  assert(io_status.Information == count);
504  return count;
505 }
static HANDLE get_np_event(RpcConnection_np *connection)
Definition: rpc_transport.c:97
GLuint GLuint GLsizei count
Definition: gl.h:1545
LONG NTSTATUS
Definition: precomp.h:26
static HANDLE PIO_APC_ROUTINE void PIO_STATUS_BLOCK io_status
Definition: comm.c:54
#define assert(x)
Definition: debug.h:53
GLuint buffer
Definition: glext.h:5915
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_PENDING
Definition: ntstatus.h:82
NTSYSAPI NTSTATUS NTAPI NtWriteFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID WriteBuffer, IN ULONG WriteBufferLength, IN PLARGE_INTEGER FileOffset OPTIONAL, IN PULONG LockOperationKey OPTIONAL)
struct _cl_event * event
Definition: glext.h:7739
static void release_np_event(RpcConnection_np *connection, HANDLE event)
#define INFINITE
Definition: serial.h:102
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ rpcrt4_conn_open_pipe()

static RPC_STATUS rpcrt4_conn_open_pipe ( RpcConnection Connection,
LPCSTR  pname,
BOOL  wait 
)
static

Definition at line 132 of file rpc_transport.c.

133 {
134  RpcConnection_np *npc = (RpcConnection_np *) Connection;
135  HANDLE pipe;
136  DWORD err, dwMode;
137 
138  TRACE("connecting to %s\n", pname);
139 
140  while (TRUE) {
141  DWORD dwFlags = 0;
142  if (Connection->QOS)
143  {
145  switch (Connection->QOS->qos->ImpersonationType)
146  {
148  /* FIXME: what to do here? */
149  break;
152  break;
155  break;
158  break;
161  break;
162  }
163  if (Connection->QOS->qos->IdentityTracking == RPC_C_QOS_IDENTITY_DYNAMIC)
165  }
168  if (pipe != INVALID_HANDLE_VALUE) break;
169  err = GetLastError();
170  if (err == ERROR_PIPE_BUSY) {
172  TRACE("retrying busy server\n");
173  continue;
174  }
175  TRACE("connection failed, error=%x\n", err);
176  return RPC_S_SERVER_TOO_BUSY;
177 #ifdef __REACTOS__
178  } else if (err == ERROR_BAD_NETPATH) {
179  TRACE("connection failed, error=%x\n", err);
181 #endif
182  }
183  if (!wait || !WaitNamedPipeA(pname, NMPWAIT_WAIT_FOREVER)) {
184  err = GetLastError();
185  WARN("connection failed, error=%x\n", err);
187  }
188  }
189 
190  /* success */
191  /* pipe is connected; change to message-read mode. */
192  dwMode = PIPE_READMODE_MESSAGE;
193  SetNamedPipeHandleState(pipe, &dwMode, NULL, NULL);
194  npc->pipe = pipe;
195 
196  return RPC_S_OK;
197 }
#define TRUE
Definition: types.h:120
#define SECURITY_IDENTIFICATION
Definition: winbase.h:522
#define WARN(fmt,...)
Definition: debug.h:112
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define RPC_C_IMP_LEVEL_ANONYMOUS
Definition: rpcdce.h:174
#define RPC_C_IMP_LEVEL_IDENTIFY
Definition: rpcdce.h:175
#define NMPWAIT_USE_DEFAULT_WAIT
Definition: winbase.h:134
#define RPC_C_IMP_LEVEL_IMPERSONATE
Definition: rpcdce.h:176
#define ERROR_BAD_NETPATH
Definition: winerror.h:145
BOOL WINAPI WaitNamedPipeA(LPCSTR lpNamedPipeName, DWORD nTimeOut)
Definition: npipe.c:433
GLenum pname
Definition: glext.h:5645
#define SECURITY_DELEGATION
Definition: winbase.h:524
#define GENERIC_WRITE
Definition: nt_native.h:90
#define NMPWAIT_WAIT_FOREVER
Definition: winbase.h:133
smooth NULL
Definition: ftsmooth.c:416
#define SECURITY_CONTEXT_TRACKING
Definition: winbase.h:525
#define OPEN_EXISTING
Definition: compat.h:523
#define SECURITY_SQOS_PRESENT
Definition: winbase.h:527
#define TRACE(s)
Definition: solgame.cpp:4
#define RPC_C_QOS_IDENTITY_DYNAMIC
Definition: rpcdce.h:181
BOOL WINAPI SetNamedPipeHandleState(HANDLE hNamedPipe, LPDWORD lpMode, LPDWORD lpMaxCollectionCount, LPDWORD lpCollectDataTimeout)
Definition: npipe.c:774
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERROR_PIPE_BUSY
Definition: winerror.h:283
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define GENERIC_READ
Definition: compat.h:135
#define err(...)
RPC_SECURITY_QOS_V2_W * qos
Definition: rpc_binding.h:57
#define SECURITY_ANONYMOUS
Definition: winbase.h:521
#define SECURITY_IMPERSONATION
Definition: winbase.h:523
#define RPC_S_SERVER_TOO_BUSY
Definition: winerror.h:1034
#define PIPE_READMODE_MESSAGE
Definition: winbase.h:170
RpcQualityOfService * QOS
Definition: rpc_binding.h:81
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:488
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define RPC_C_IMP_LEVEL_DEFAULT
Definition: rpcdce.h:173
#define RPC_C_IMP_LEVEL_DELEGATE
Definition: rpcdce.h:177
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by rpcrt4_ncacn_np_open(), and rpcrt4_ncalrpc_open().

◆ rpcrt4_conn_release_and_wait()

void rpcrt4_conn_release_and_wait ( RpcConnection connection)

Definition at line 3442 of file rpc_transport.c.

3443 {
3444  HANDLE event = NULL;
3445 
3446  if (connection->ref > 1)
3447  event = connection->wait_release = CreateEventW(NULL, TRUE, FALSE, NULL);
3448 
3449  RPCRT4_ReleaseConnection(connection);
3450 
3451  if(event)
3452  {
3454  CloseHandle(event);
3455  }
3456 }
#define CloseHandle
Definition: compat.h:487
#define TRUE
Definition: types.h:120
void RPCRT4_ReleaseConnection(RpcConnection *connection)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
HANDLE wait_release
Definition: rpc_binding.h:66
struct _cl_event * event
Definition: glext.h:7739
#define INFINITE
Definition: serial.h:102

Referenced by RPCRT4_server_thread().

◆ rpcrt4_conn_tcp_alloc()

static RpcConnection* rpcrt4_conn_tcp_alloc ( void  )
static

Definition at line 1191 of file rpc_transport.c.

1192 {
1193  RpcConnection_tcp *tcpc;
1195  if (tcpc == NULL)
1196  return NULL;
1197  tcpc->sock = -1;
1198  if (!rpcrt4_sock_wait_init(tcpc))
1199  {
1200  HeapFree(GetProcessHeap(), 0, tcpc);
1201  return NULL;
1202  }
1203  return &tcpc->common;
1204 }
static BOOL rpcrt4_sock_wait_init(RpcConnection_tcp *tcpc)
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
RpcConnection common
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define HeapFree(x, y, z)
Definition: compat.h:483

◆ rpcrt4_conn_tcp_cancel_call()

static void rpcrt4_conn_tcp_cancel_call ( RpcConnection conn)
static

Definition at line 1541 of file rpc_transport.c.

1542 {
1543  RpcConnection_tcp *connection = (RpcConnection_tcp *) conn;
1544 
1545  TRACE("%p\n", connection);
1546 
1547  SetEvent(connection->cancel_event);
1548 }
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
#define TRACE(s)
Definition: solgame.cpp:4

◆ rpcrt4_conn_tcp_close()

static int rpcrt4_conn_tcp_close ( RpcConnection conn)
static

Definition at line 1521 of file rpc_transport.c.

1522 {
1523  RpcConnection_tcp *connection = (RpcConnection_tcp *) conn;
1524 
1525  TRACE("%d\n", connection->sock);
1526 
1527  if (connection->sock != -1)
1528  closesocket(connection->sock);
1529  connection->sock = -1;
1530  CloseHandle(connection->sock_event);
1531  CloseHandle(connection->cancel_event);
1532  return 0;
1533 }
#define CloseHandle
Definition: compat.h:487
#define closesocket
Definition: precomp.h:57
#define TRACE(s)
Definition: solgame.cpp:4

◆ rpcrt4_conn_tcp_close_read()

static void rpcrt4_conn_tcp_close_read ( RpcConnection conn)
static

Definition at line 1535 of file rpc_transport.c.

1536 {
1537  RpcConnection_tcp *connection = (RpcConnection_tcp *) conn;
1538  shutdown(connection->sock, SD_RECEIVE);
1539 }
INT WSAAPI shutdown(IN SOCKET s, IN INT how)
Definition: sockctrl.c:506
#define SD_RECEIVE
Definition: winsock.h:54

◆ rpcrt4_conn_tcp_handoff()

static RPC_STATUS rpcrt4_conn_tcp_handoff ( RpcConnection old_conn,
RpcConnection new_conn 
)
static

Definition at line 1435 of file rpc_transport.c.

1436 {
1437  int ret;
1438  struct sockaddr_in address;
1439  socklen_t addrsize;
1442  u_long nonblocking;
1443 
1444  addrsize = sizeof(address);
1445  ret = accept(server->sock, (struct sockaddr*) &address, &addrsize);
1446  if (ret < 0)
1447  {
1448  ERR("Failed to accept a TCP connection: error %d\n", ret);
1449  return RPC_S_OUT_OF_RESOURCES;
1450  }
1451 
1452  nonblocking = 1;
1453  ioctlsocket(ret, FIONBIO, &nonblocking);
1454  client->sock = ret;
1455 
1456  client->common.NetworkAddr = HeapAlloc(GetProcessHeap(), 0, INET6_ADDRSTRLEN);
1457  ret = getnameinfo((struct sockaddr*)&address, addrsize, client->common.NetworkAddr, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST);
1458  if (ret != 0)
1459  {
1460  ERR("Failed to retrieve the IP address, error %d\n", ret);
1461  return RPC_S_OUT_OF_RESOURCES;
1462  }
1463 
1464  TRACE("Accepted a new TCP connection from %s\n", client->common.NetworkAddr);
1465  return RPC_S_OK;
1466 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
unsigned long u_long
Definition: linux.h:269
#define NI_NUMERICHOST
Definition: ws2def.h:354
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static FILE * client
Definition: client.c:41
GLuint address
Definition: glext.h:9393
int socklen_t
Definition: tcp.c:35
int ret
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23
#define FIONBIO
Definition: winsock.h:149
#define ERR(fmt,...)
Definition: debug.h:110
#define ioctlsocket
Definition: precomp.h:58
#define getnameinfo
Definition: wspiapi.h:45
#define RPC_S_OUT_OF_RESOURCES
Definition: winerror.h:1032
#define INET6_ADDRSTRLEN
Definition: ws2ipdef.h:132
#define RPC_S_OK
Definition: rpcnterr.h:22

◆ rpcrt4_conn_tcp_is_server_listening()

static RPC_STATUS rpcrt4_conn_tcp_is_server_listening ( const char endpoint)
static

Definition at line 1550 of file rpc_transport.c.

1551 {
1552  FIXME("\n");
1553  return RPC_S_ACCESS_DENIED;
1554 }
#define RPC_S_ACCESS_DENIED
Definition: rpcnterr.h:29
#define FIXME(fmt,...)
Definition: debug.h:111

◆ rpcrt4_conn_tcp_read()

static int rpcrt4_conn_tcp_read ( RpcConnection Connection,
void buffer,
unsigned int  count 
)
static

Definition at line 1468 of file rpc_transport.c.

1470 {
1471  RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
1472  int bytes_read = 0;
1473  while (bytes_read != count)
1474  {
1475  int r = recv(tcpc->sock, (char *)buffer + bytes_read, count - bytes_read, 0);
1476  if (!r)
1477  return -1;
1478  else if (r > 0)
1479  bytes_read += r;
1480  else if (WSAGetLastError() == WSAEINTR)
1481  continue;
1482  else if (WSAGetLastError() != WSAEWOULDBLOCK)
1483  {
1484  WARN("recv() failed: %u\n", WSAGetLastError());
1485  return -1;
1486  }
1487  else
1488  {
1489  if (!rpcrt4_sock_wait_for_recv(tcpc))
1490  return -1;
1491  }
1492  }
1493  TRACE("%d %p %u -> %d\n", tcpc->sock, buffer, count, bytes_read);
1494  return bytes_read;
1495 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define WARN(fmt,...)
Definition: debug.h:112
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
GLuint buffer
Definition: glext.h:5915
#define TRACE(s)
Definition: solgame.cpp:4
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
static BOOL rpcrt4_sock_wait_for_recv(RpcConnection_tcp *tcpc)
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
#define WSAEINTR
Definition: winerror.h:1942

◆ rpcrt4_conn_tcp_wait_for_incoming_data()

static int rpcrt4_conn_tcp_wait_for_incoming_data ( RpcConnection Connection)
static

Definition at line 1556 of file rpc_transport.c.

1557 {
1558  RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
1559 
1560  TRACE("%p\n", Connection);
1561 
1562  if (!rpcrt4_sock_wait_for_recv(tcpc))
1563  return -1;
1564  return 0;
1565 }
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL rpcrt4_sock_wait_for_recv(RpcConnection_tcp *tcpc)

◆ rpcrt4_conn_tcp_write()

static int rpcrt4_conn_tcp_write ( RpcConnection Connection,
const void buffer,
unsigned int  count 
)
static

Definition at line 1497 of file rpc_transport.c.

1499 {
1500  RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
1501  int bytes_written = 0;
1502  while (bytes_written != count)
1503  {
1504  int r = send(tcpc->sock, (const char *)buffer + bytes_written, count - bytes_written, 0);
1505  if (r >= 0)
1506  bytes_written += r;
1507  else if (WSAGetLastError() == WSAEINTR)
1508  continue;
1509  else if (WSAGetLastError() != WSAEWOULDBLOCK)
1510  return -1;
1511  else
1512  {
1513  if (!rpcrt4_sock_wait_for_send(tcpc))
1514  return -1;
1515  }
1516  }
1517  TRACE("%d %p %u -> %d\n", tcpc->sock, buffer, count, bytes_written);
1518  return bytes_written;
1519 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
GLuint buffer
Definition: glext.h:5915
#define TRACE(s)
Definition: solgame.cpp:4
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
static BOOL rpcrt4_sock_wait_for_send(RpcConnection_tcp *tcpc)
#define WSAEINTR
Definition: winerror.h:1942

◆ RPCRT4_CreateConnection()

RPC_STATUS RPCRT4_CreateConnection ( RpcConnection **  Connection,
BOOL  server,
LPCSTR  Protseq,
LPCSTR  NetworkAddr,
LPCSTR  Endpoint,
LPCWSTR  NetworkOptions,
RpcAuthInfo AuthInfo,
RpcQualityOfService QOS,
LPCWSTR  CookieAuth 
)

Definition at line 3378 of file rpc_transport.c.

3381 {
3382  static LONG next_id;
3383  const struct connection_ops *ops;
3384  RpcConnection* NewConnection;
3385 
3386  ops = rpcrt4_get_conn_protseq_ops(Protseq);
3387  if (!ops)
3388  {
3389  FIXME("not supported for protseq %s\n", Protseq);
3391  }
3392 
3393  NewConnection = ops->alloc();
3394  NewConnection->ref = 1;
3395  NewConnection->server = server;
3396  NewConnection->ops = ops;
3397  NewConnection->NetworkAddr = RPCRT4_strdupA(NetworkAddr);
3398  NewConnection->Endpoint = RPCRT4_strdupA(Endpoint);
3399  NewConnection->NetworkOptions = RPCRT4_strdupW(NetworkOptions);
3400  NewConnection->CookieAuth = RPCRT4_strdupW(CookieAuth);
3401  NewConnection->MaxTransmissionSize = RPC_MAX_PACKET_SIZE;
3402  NewConnection->NextCallId = 1;
3403 
3404  SecInvalidateHandle(&NewConnection->ctx);
3405  if (AuthInfo) RpcAuthInfo_AddRef(AuthInfo);
3406  NewConnection->AuthInfo = AuthInfo;
3407  NewConnection->auth_context_id = InterlockedIncrement( &next_id );
3409  NewConnection->QOS = QOS;
3410 
3411  list_init(&NewConnection->conn_pool_entry);
3412  list_init(&NewConnection->protseq_entry);
3413 
3414  TRACE("connection: %p\n", NewConnection);
3415  *Connection = NewConnection;
3416 
3417  return RPC_S_OK;
3418 }
USHORT MaxTransmissionSize
Definition: rpc_binding.h:71
struct list protseq_entry
Definition: rpc_binding.h:94
static rfbScreenInfoPtr server
Definition: vnc.c:74
USHORT NextCallId
Definition: rpc_binding.h:93
static const struct connection_ops * rpcrt4_get_conn_protseq_ops(const char *protseq)
const struct connection_ops * ops
Definition: rpc_binding.h:70
struct list conn_pool_entry
Definition: rpc_binding.h:85
#define SecInvalidateHandle(x)
Definition: sspi.h:58
long LONG
Definition: pedump.c:60
ULONG RpcAuthInfo_AddRef(RpcAuthInfo *AuthInfo)
Definition: rpc_binding.c:1179
#define FIXME(fmt,...)
Definition: debug.h:111
#define RPC_S_PROTSEQ_NOT_SUPPORTED
Definition: winerror.h:1014
#define TRACE(s)
Definition: solgame.cpp:4
LPWSTR NetworkOptions
Definition: rpc_binding.h:69
LPSTR NetworkAddr
Definition: rpc_binding.h:67
LPWSTR CookieAuth
Definition: rpc_binding.h:82
CtxtHandle ctx
Definition: rpc_binding.h:74
RpcConnection *(* alloc)(void)
Definition: rpc_binding.h:102
#define InterlockedIncrement
Definition: armddk.h:53
RpcAuthInfo * AuthInfo
Definition: rpc_binding.h:77
#define RPCRT4_strdupA(x)
Definition: rpc_binding.h:151
ULONG RpcQualityOfService_AddRef(RpcQualityOfService *qos)
Definition: rpc_binding.c:1356
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
#define RPC_MAX_PACKET_SIZE
Definition: rpc_defs.h:184
RpcQualityOfService * QOS
Definition: rpc_binding.h:81
ULONG auth_context_id
Definition: rpc_binding.h:78
struct _QualityOfService QOS
#define RPCRT4_strdupW(x)
Definition: rpc_binding.h:152
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by RpcAssoc_GetClientConnection(), rpcrt4_protseq_ncacn_ip_tcp_open_endpoint(), rpcrt4_protseq_ncacn_np_open_endpoint(), rpcrt4_protseq_ncalrpc_open_endpoint(), and rpcrt4_spawn_connection().

◆ rpcrt4_get_conn_protseq_ops()

static const struct connection_ops* rpcrt4_get_conn_protseq_ops ( const char protseq)
static

Definition at line 3347 of file rpc_transport.c.

3348 {
3349  unsigned int i;
3350  for(i = 0; i < ARRAY_SIZE(conn_protseq_list); i++)
3351  if (!strcmp(conn_protseq_list[i].name, protseq))
3352  return &conn_protseq_list[i];
3353  return NULL;
3354 }
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
smooth NULL
Definition: ftsmooth.c:416
static const struct connection_ops conn_protseq_list[]
#define ARRAY_SIZE(a)
Definition: main.h:24
Definition: name.c:38
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by RpcNetworkIsProtseqValidW(), RPCRT4_CreateConnection(), RPCRT4_IsServerListening(), and RpcTransport_GetTopOfTower().

◆ rpcrt4_get_protseq_ops()

const struct protseq_ops* rpcrt4_get_protseq_ops ( const char protseq)

Definition at line 3338 of file rpc_transport.c.

3339 {
3340  unsigned int i;
3341  for(i = 0; i < ARRAY_SIZE(protseq_list); i++)
3342  if (!strcmp(protseq_list[i].name, protseq))
3343  return &protseq_list[i];
3344  return NULL;
3345 }
static const struct protseq_ops protseq_list[]
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
smooth NULL
Definition: ftsmooth.c:416
#define ARRAY_SIZE(a)
Definition: main.h:24
Definition: name.c:38
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by alloc_serverprotoseq().

◆ RPCRT4_GrabConnection()

RpcConnection* RPCRT4_GrabConnection ( RpcConnection connection)

Definition at line 3458 of file rpc_transport.c.

3459 {
3460  LONG ref = InterlockedIncrement(&connection->ref);
3461  TRACE("%p ref=%u\n", connection, ref);
3462  return connection;
3463 }
Definition: send.c:48
long LONG
Definition: pedump.c:60
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53

Referenced by RPCRT4_io_thread(), and RPCRT4_server_thread().

◆ rpcrt4_http_async_read()

static int rpcrt4_http_async_read ( HINTERNET  req,
RpcHttpAsyncData async_data,
HANDLE  cancel_event,
void buffer,
unsigned int  count 
)
static

Definition at line 2084 of file rpc_transport.c.

2086 {
2087  char *buf = buffer;
2088  BOOL ret;
2089  unsigned int bytes_left = count;
2091 
2092  async_data->inet_buffers.lpvBuffer = HeapAlloc(GetProcessHeap(), 0, count);
2093 
2094  while (bytes_left)
2095  {
2096  async_data->inet_buffers.dwBufferLength = bytes_left;
2097  prepare_async_request(async_data);
2098  ret = InternetReadFileExW(req, &async_data->inet_buffers, IRF_ASYNC, 0);
2099  status = wait_async_request(async_data, ret, cancel_event);
2100  if (status != RPC_S_OK)
2101  {
2103  TRACE("call cancelled\n");
2104  break;
2105  }
2106 
2107  if (!async_data->inet_buffers.dwBufferLength)
2108  break;
2109  memcpy(buf, async_data->inet_buffers.lpvBuffer,
2110  async_data->inet_buffers.dwBufferLength);
2111 
2112  bytes_left -= async_data->inet_buffers.dwBufferLength;
2113  buf += async_data->inet_buffers.dwBufferLength;
2114  }
2115 
2116  HeapFree(GetProcessHeap(), 0, async_data->inet_buffers.lpvBuffer);
2117  async_data->inet_buffers.lpvBuffer = NULL;
2118 
2119  TRACE("%p %p %u -> %u\n", req, buffer, count, status);
2120  return status == RPC_S_OK ? count : -1;
2121 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define IRF_ASYNC
Definition: wininet.h:622
static RPC_STATUS wait_async_request(RpcHttpAsyncData *async_data, BOOL call_ret, HANDLE cancel_event)
GLuint buffer
Definition: glext.h:5915
INTERNET_BUFFERSW inet_buffers
DWORD dwBufferLength
Definition: wininet.h:278
long RPC_STATUS
Definition: rpc.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
static void prepare_async_request(RpcHttpAsyncData *async_data)
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define RPC_S_CALL_CANCELLED
Definition: winerror.h:1125
int ret
BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:2268
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
LPVOID lpvBuffer
Definition: wininet.h:277
#define HeapFree(x, y, z)
Definition: compat.h:483
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: ps.c:97

Referenced by drain_content(), rpcrt4_http_prepare_out_pipe(), rpcrt4_http_read_http_packet(), rpcrt4_ncacn_http_read(), and send_echo_request().

◆ rpcrt4_http_check_response()

static RPC_STATUS rpcrt4_http_check_response ( HINTERNET  hor)
static

Definition at line 1923 of file rpc_transport.c.

1924 {
1925  BOOL ret;
1927  DWORD size;
1928  DWORD index;
1929  WCHAR buf[32];
1930  WCHAR *status_text = buf;
1931  TRACE("\n");
1932 
1933  index = 0;
1934  size = sizeof(status_code);
1936  if (!ret)
1937  return GetLastError();
1938  if (status_code == HTTP_STATUS_OK)
1939  return RPC_S_OK;
1940  index = 0;
1941  size = sizeof(buf);
1942  ret = HttpQueryInfoW(hor, HTTP_QUERY_STATUS_TEXT, status_text, &size, &index);
1944  {
1945  status_text = HeapAlloc(GetProcessHeap(), 0, size);
1946  ret = HttpQueryInfoW(hor, HTTP_QUERY_STATUS_TEXT, status_text, &size, &index);
1947  }
1948 
1949  ERR("server returned: %d %s\n", status_code, ret ? debugstr_w(status_text) : "<status text unavailable>");
1950  if(status_text != buf) HeapFree(GetProcessHeap(), 0, status_text);
1951 
1953  return ERROR_ACCESS_DENIED;
1954  return RPC_S_SERVER_UNAVAILABLE;
1955 }
#define HTTP_QUERY_STATUS_TEXT
Definition: wininet.h:1543
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
struct status_code status_code
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
GLuint index
Definition: glext.h:6031
#define HTTP_STATUS_DENIED
Definition: winhttp.h:256
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define HTTP_STATUS_OK
Definition: winhttp.h:240
int ret
BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
Definition: http.c:3883
#define index(s, c)
Definition: various.h:29
#define HTTP_QUERY_STATUS_CODE
Definition: wininet.h:1542
#define ERR(fmt,...)
Definition: debug.h:110
#define HTTP_QUERY_FLAG_NUMBER
Definition: wininet.h:1606
#define HeapFree(x, y, z)
Definition: compat.h:483
#define RPC_S_OK
Definition: rpcnterr.h:22
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by authorize_request(), rpcrt4_http_prepare_out_pipe(), rpcrt4_ncacn_http_open(), and send_echo_request().

◆ rpcrt4_http_internet_callback()

static VOID WINAPI rpcrt4_http_internet_callback ( HINTERNET  hInternet,
DWORD_PTR  dwContext,
DWORD  dwInternetStatus,
LPVOID  lpvStatusInformation,
DWORD  dwStatusInformationLength 
)
static

Definition at line 1898 of file rpc_transport.c.

1904 {
1905  RpcHttpAsyncData *async_data = (RpcHttpAsyncData *)dwContext;
1906 
1907  switch (dwInternetStatus)
1908  {
1910  TRACE("INTERNET_STATUS_REQUEST_COMPLETED\n");
1911  if (async_data)
1912  {
1913  INTERNET_ASYNC_RESULT *async_result = lpvStatusInformation;
1914 
1915  async_data->async_result = async_result->dwResult ? ERROR_SUCCESS : async_result->dwError;
1916  SetEvent(async_data->completion_event);
1917  RpcHttpAsyncData_Release(async_data);
1918  }
1919  break;
1920  }
1921 }
#define ERROR_SUCCESS
Definition: deptool.c:10
static ULONG RpcHttpAsyncData_Release(RpcHttpAsyncData *data)
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
#define TRACE(s)
Definition: solgame.cpp:4
DWORD_PTR dwResult
Definition: wininet.h:155
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898

Referenced by rpcrt4_http_internet_connect().

◆ rpcrt4_http_internet_connect()

static RPC_STATUS rpcrt4_http_internet_connect ( RpcConnection_http httpc)
static

Definition at line 1957 of file rpc_transport.c.

1958 {
1959  static const WCHAR wszUserAgent[] = {'M','S','R','P','C',0};
1960  LPWSTR proxy = NULL;
1961  LPWSTR user = NULL;
1962  LPWSTR password = NULL;
1963  LPWSTR servername = NULL;
1964  const WCHAR *option;
1966 
1967  if (httpc->common.QOS &&
1969  {
1970  const RPC_HTTP_TRANSPORT_CREDENTIALS_W *http_cred = httpc->common.QOS->qos->u.HttpCredentials;
1971  if (http_cred->TransportCredentials)
1972  {
1973  WCHAR *p;
1974  const SEC_WINNT_AUTH_IDENTITY_W *cred = http_cred->TransportCredentials;
1975  ULONG len = cred->DomainLength + 1 + cred->UserLength;
1976  user = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
1977  if (!user)
1978  return RPC_S_OUT_OF_RESOURCES;
1979  p = user;
1980  if (cred->DomainLength)
1981  {
1982  memcpy(p, cred->Domain, cred->DomainLength * sizeof(WCHAR));
1983  p += cred->DomainLength;
1984  *p = '\\';
1985  p++;
1986  }
1987  memcpy(p, cred->User, cred->UserLength * sizeof(WCHAR));
1988  p[cred->UserLength] = 0;
1989 
1991  }
1992  }
1993 
1994  for (option = httpc->common.NetworkOptions; option;
1995  option = (wcschr(option, ',') ? wcschr(option, ',')+1 : NULL))
1996  {
1997  static const WCHAR wszRpcProxy[] = {'R','p','c','P','r','o','x','y','=',0};
1998  static const WCHAR wszHttpProxy[] = {'H','t','t','p','P','r','o','x','y','=',0};
1999 
2000  if (!_wcsnicmp(option, wszRpcProxy, ARRAY_SIZE(wszRpcProxy)-1))
2001  {
2002  const WCHAR *value_start = option + ARRAY_SIZE(wszRpcProxy)-1;
2003  const WCHAR *value_end;
2004  const WCHAR *p;
2005 
2006  value_end = wcschr(option, ',');
2007  if (!value_end)
2008  value_end = value_start + lstrlenW(value_start);
2009  for (p = value_start; p < value_end; p++)
2010  if (*p == ':')
2011  {
2012  port = wcstol(p+1, NULL, 10);
2013  value_end = p;
2014  break;
2015  }
2016  TRACE("RpcProxy value is %s\n", debugstr_wn(value_start, value_end-value_start));
2017  servername = RPCRT4_strndupW(value_start, value_end-value_start);
2018  }
2019  else if (!_wcsnicmp(option, wszHttpProxy, ARRAY_SIZE(wszHttpProxy)-1))
2020  {
2021  const WCHAR *value_start = option + ARRAY_SIZE(wszHttpProxy)-1;
2022  const WCHAR *value_end;
2023 
2024  value_end = wcschr(option, ',');
2025  if (!value_end)
2026  value_end = value_start + lstrlenW(value_start);
2027  TRACE("HttpProxy value is %s\n", debugstr_wn(value_start, value_end-value_start));
2028  proxy = RPCRT4_strndupW(value_start, value_end-value_start);
2029  }
2030  else
2031  FIXME("unhandled option %s\n", debugstr_w(option));
2032  }
2033 
2036  if (!httpc->app_info)
2037  {
2039  HeapFree(GetProcessHeap(), 0, user);
2040  HeapFree(GetProcessHeap(), 0, proxy);
2041  HeapFree(GetProcessHeap(), 0, servername);
2042  ERR("InternetOpenW failed with error %d\n", GetLastError());
2043  return RPC_S_SERVER_UNAVAILABLE;
2044  }
2046 
2047  /* if no RpcProxy option specified, set the HTTP server address to the
2048  * RPC server address */
2049  if (!servername)
2050  {
2051  servername = HeapAlloc(GetProcessHeap(), 0, (strlen(httpc->common.NetworkAddr) + 1)*sizeof(WCHAR));
2052  if (!servername)
2053  {
2055  HeapFree(GetProcessHeap(), 0, user);
2056  HeapFree(GetProcessHeap(), 0, proxy);
2057  return RPC_S_OUT_OF_RESOURCES;
2058  }
2059  MultiByteToWideChar(CP_ACP, 0, httpc->common.NetworkAddr, -1, servername, strlen(httpc->common.NetworkAddr) + 1);
2060  }
2061 
2062  port = (httpc->common.QOS &&
2066 
2067  httpc->session = InternetConnectW(httpc->app_info, servername, port, user, password,
2068  INTERNET_SERVICE_HTTP, 0, 0);
2069 
2071  HeapFree(GetProcessHeap(), 0, user);
2072  HeapFree(GetProcessHeap(), 0, proxy);
2073 
2074  if (!httpc->session)
2075  {
2076  ERR("InternetConnectW failed with error %d\n", GetLastError());
2077  HeapFree(GetProcessHeap(), 0, servername);
2078  return RPC_S_SERVER_UNAVAILABLE;
2079  }
2080  httpc->servername = servername;
2081  return RPC_S_OK;
2082 }
unsigned short * Domain
Definition: rpcdce.h:225
int proxy
Definition: main.c:67
static VOID WINAPI rpcrt4_http_internet_callback(HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength)
unsigned short * User
Definition: rpcdce.h:223
SEC_WINNT_AUTH_IDENTITY_W * TransportCredentials
Definition: rpcdce.h:245
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
unsigned short * Password
Definition: rpcdce.h:227
#define CP_ACP
Definition: compat.h:109
RpcConnection common
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define INTERNET_OPEN_TYPE_PROXY
Definition: wininet.h:523
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
RPC_HTTP_TRANSPORT_CREDENTIALS_W * HttpCredentials
Definition: rpcdce.h:279
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define lstrlenW
Definition: compat.h:498
#define INTERNET_DEFAULT_HTTP_PORT
Definition: winhttp.h:36
WORD INTERNET_PORT
Definition: winhttp.h:38
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
Definition: getopt.h:108
GLuint GLenum option
Definition: glext.h:11211
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackW(HINTERNET hInternet, INTERNET_STATUS_CALLBACK lpfnIntCB)
Definition: internet.c:2097
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPWSTR NetworkOptions
Definition: rpc_binding.h:69
LPSTR NetworkAddr
Definition: rpc_binding.h:67
#define INTERNET_FLAG_ASYNC
Definition: wininet.h:64
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
RPC_SECURITY_QOS_V2_W * qos
Definition: rpc_binding.h:57
#define debugstr_wn
Definition: kernel32.h:33
union _RPC_SECURITY_QOS_V2_W::@3168 u
#define ERR(fmt,...)
Definition: debug.h:110
#define INTERNET_DEFAULT_HTTPS_PORT
Definition: winhttp.h:37
#define INTERNET_OPEN_TYPE_PRECONFIG
Definition: wininet.h:521
ULONG AdditionalSecurityInfoType
Definition: rpcdce.h:276
#define ARRAY_SIZE(a)
Definition: main.h:24
#define RPC_S_OUT_OF_RESOURCES
Definition: winerror.h:1032
#define MultiByteToWideChar
Definition: compat.h:110
#define RPC_C_HTTP_FLAG_USE_SSL
Definition: rpcdce.h:198
unsigned int ULONG
Definition: retypes.h:1
#define RPC_C_AUTHN_INFO_TYPE_HTTP
Definition: rpcdce.h:195
RpcQualityOfService * QOS
Definition: rpc_binding.h:81
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
HINTERNET WINAPI InternetConnectW(HINTERNET hInternet, LPCWSTR lpszServerName, INTERNET_PORT nServerPort, LPCWSTR lpszUserName, LPCWSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:1280
LPWSTR RPCRT4_strndupW(LPCWSTR src, INT slen)
Definition: rpc_binding.c:91
HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType, LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags)
Definition: internet.c:1001
USHORT port
Definition: uri.c:228
#define INTERNET_SERVICE_HTTP
Definition: wininet.h:562
void user(int argc, const char *argv[])
Definition: cmds.c:1350
#define HeapFree(x, y, z)
Definition: compat.h:483
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by rpcrt4_ncacn_http_open().

◆ rpcrt4_http_keep_connection_active_timer_proc()

static VOID rpcrt4_http_keep_connection_active_timer_proc ( PVOID  param,
BOOLEAN  dummy 
)
static

Definition at line 1853 of file rpc_transport.c.

1854 {
1855  HINTERNET in_request = param;
1856  RpcPktHdr *idle_pkt;
1857 
1859  0, 0);
1860  if (idle_pkt)
1861  {
1862  DWORD bytes_written;
1863  InternetWriteFile(in_request, idle_pkt, idle_pkt->common.frag_len, &bytes_written);
1864  RPCRT4_FreeHeader(idle_pkt);
1865  }
1866 }
VOID RPCRT4_FreeHeader(RpcPktHdr *Header)
Definition: rpc_message.c:403
RpcPktCommonHdr common
Definition: rpc_defs.h:152
BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer, DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
Definition: internet.c:2134
unsigned short frag_len
Definition: rpc_defs.h:33
GLfloat param
Definition: glext.h:5796
unsigned long DWORD
Definition: ntddk_ex.h:95
#define NDR_LOCAL_DATA_REPRESENTATION
Definition: rpcndr.h:107
RpcPktHdr * RPCRT4_BuildHttpHeader(ULONG DataRepresentation, unsigned short flags, unsigned short num_data_items, unsigned int payload_size)
Definition: rpc_message.c:291

Referenced by rpcrt4_http_timer_thread().

◆ rpcrt4_http_prepare_in_pipe()

static RPC_STATUS rpcrt4_http_prepare_in_pipe ( HINTERNET  in_request,
RpcHttpAsyncData async_data,
HANDLE  cancel_event,
const UUID connection_uuid,
const UUID in_pipe_uuid,
const UUID association_uuid,
BOOL  authorized 
)
static

Definition at line 2157 of file rpc_transport.c.

2160 {
2161  BOOL ret;
2163  RpcPktHdr *hdr;
2164  INTERNET_BUFFERSW buffers_in;
2165  DWORD bytes_written;
2166 
2167  if (!authorized)
2168  {
2169  /* ask wininet to authorize, if necessary */
2170  status = send_echo_request(in_request, async_data, cancel_event);
2171  if (status != RPC_S_OK) return status;
2172  }
2173  memset(&buffers_in, 0, sizeof(buffers_in));
2174  buffers_in.dwStructSize = sizeof(buffers_in);
2175  /* FIXME: get this from the registry */
2176  buffers_in.dwBufferTotal = 1024 * 1024 * 1024; /* 1Gb */
2177  status = insert_content_length_header(in_request, buffers_in.dwBufferTotal);
2178  if (status != RPC_S_OK) return status;
2179 
2180  prepare_async_request(async_data);
2181  ret = HttpSendRequestExW(in_request, &buffers_in, NULL, 0, 0);
2182  status = wait_async_request(async_data, ret, cancel_event);
2183  if (status != RPC_S_OK) return status;
2184 
2185  TRACE("sending HTTP connect header to server\n");
2186  hdr = RPCRT4_BuildHttpConnectHeader(FALSE, connection_uuid, in_pipe_uuid, association_uuid);
2187  if (!hdr) return RPC_S_OUT_OF_RESOURCES;
2188  ret = InternetWriteFile(in_request, hdr, hdr->common.frag_len, &bytes_written);
2190  if (!ret)
2191  {
2192  ERR("InternetWriteFile failed with error %d\n", GetLastError());
2193  return RPC_S_SERVER_UNAVAILABLE;
2194  }
2195 
2196  return RPC_S_OK;
2197 }
DWORD dwStructSize
Definition: wininet.h:272
static RPC_STATUS send_echo_request(HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event)
char hdr[14]
Definition: iptest.cpp:33
DWORD dwBufferTotal
Definition: wininet.h:279
VOID RPCRT4_FreeHeader(RpcPktHdr *Header)
Definition: rpc_message.c:403
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static RPC_STATUS wait_async_request(RpcHttpAsyncData *async_data, BOOL call_ret, HANDLE cancel_event)
long RPC_STATUS
Definition: rpc.h:52
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
RpcPktHdr * RPCRT4_BuildHttpConnectHeader(int out_pipe, const UUID *connection_uuid, const UUID *pipe_uuid, const UUID *association_uuid)
Definition: rpc_message.c:344
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI HttpSendRequestExW(HINTERNET hRequest, LPINTERNET_BUFFERSW lpBuffersIn, LPINTERNET_BUFFERSW lpBuffersOut, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:5536
BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer, DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
Definition: internet.c:2134
static void prepare_async_request(RpcHttpAsyncData *async_data)
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define ERR(fmt,...)
Definition: debug.h:110
#define RPC_S_OUT_OF_RESOURCES
Definition: winerror.h:1032
#define memset(x, y, z)
Definition: compat.h:39
static SERVICE_STATUS status
Definition: service.c:31
#define RPC_S_OK
Definition: rpcnterr.h:22
static RPC_STATUS insert_content_length_header(HINTERNET request, DWORD len)
Definition: ps.c:97

Referenced by rpcrt4_ncacn_http_open().

◆ rpcrt4_http_prepare_out_pipe()

static RPC_STATUS rpcrt4_http_prepare_out_pipe ( HINTERNET  out_request,
RpcHttpAsyncData async_data,
HANDLE  cancel_event,
const UUID connection_uuid,
const UUID out_pipe_uuid,
ULONG flow_control_increment,
BOOL  authorized 
)
static

Definition at line 2244 of file rpc_transport.c.

2248 {
2249  BOOL ret;
2251  RpcPktHdr *hdr;
2252  BYTE *data_from_server;
2253  RpcPktHdr pkt_from_server;
2254  ULONG field1, field3;
2255  BYTE buf[20];
2256 
2257  if (!authorized)
2258  {
2259  /* ask wininet to authorize, if necessary */
2260  status = send_echo_request(out_request, async_data, cancel_event);
2261  if (status != RPC_S_OK) return status;
2262  }
2263  else
2264  rpcrt4_http_async_read(out_request, async_data, cancel_event, buf, sizeof(buf));
2265 
2266  hdr = RPCRT4_BuildHttpConnectHeader(TRUE, connection_uuid, out_pipe_uuid, NULL);
2267  if (!hdr) return RPC_S_OUT_OF_RESOURCES;
2268 
2269  status = insert_content_length_header(out_request, hdr->common.frag_len);
2270  if (status != RPC_S_OK)
2271  {
2273  return status;
2274  }
2275 
2276  TRACE("sending HTTP connect header to server\n");
2277  prepare_async_request(async_data);
2278  ret = HttpSendRequestW(out_request, NULL, 0, hdr, hdr->common.frag_len);
2279  status = wait_async_request(async_data, ret, cancel_event);
2281  if (status != RPC_S_OK) return status;
2282 
2283  status = rpcrt4_http_check_response(out_request);
2284  if (status != RPC_S_OK) return status;
2285 
2286  status = rpcrt4_http_read_http_packet(out_request, async_data, cancel_event,
2287  &pkt_from_server, &data_from_server);
2288  if (status != RPC_S_OK) return status;
2289  status = RPCRT4_ParseHttpPrepareHeader1(&pkt_from_server, data_from_server,
2290  &field1);
2291  HeapFree(GetProcessHeap(), 0, data_from_server);
2292  if (status != RPC_S_OK) return status;
2293  TRACE("received (%d) from first prepare header\n", field1);
2294 
2295  for (;;)
2296  {
2297  status = rpcrt4_http_read_http_packet(out_request, async_data, cancel_event,
2298  &pkt_from_server, &data_from_server);
2299  if (status != RPC_S_OK) return status;
2300  if (pkt_from_server.http.flags != 0x0001) break;
2301 
2302  TRACE("http idle packet, waiting for real packet\n");
2303  HeapFree(GetProcessHeap(), 0, data_from_server);
2304  if (pkt_from_server.http.num_data_items != 0)
2305  {
2306  ERR("HTTP idle packet should have no data items instead of %d\n",
2307  pkt_from_server.http.num_data_items);
2308  return RPC_S_PROTOCOL_ERROR;
2309  }
2310  }
2311  status = RPCRT4_ParseHttpPrepareHeader2(&pkt_from_server, data_from_server,
2312  &field1, flow_control_increment,
2313  &field3);
2314  HeapFree(GetProcessHeap(), 0, data_from_server);
2315  if (status != RPC_S_OK) return status;
2316  TRACE("received (0x%08x 0x%08x %d) from second prepare header\n", field1, *flow_control_increment, field3);
2317 
2318  return RPC_S_OK;
2319 }
static RPC_STATUS send_echo_request(HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event)
static int rpcrt4_http_async_read(HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event, void *buffer, unsigned int count)
char hdr[14]
Definition: iptest.cpp:33
RPC_STATUS RPCRT4_ParseHttpPrepareHeader1(RpcPktHdr *header, unsigned char *data, ULONG *field1)
Definition: rpc_message.c:566
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define TRUE
Definition: types.h:120
VOID RPCRT4_FreeHeader(RpcPktHdr *Header)
Definition: rpc_message.c:403
static RPC_STATUS wait_async_request(RpcHttpAsyncData *async_data, BOOL call_ret, HANDLE cancel_event)
long RPC_STATUS
Definition: rpc.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned short flags
Definition: rpc_defs.h:138
RpcPktHdr * RPCRT4_BuildHttpConnectHeader(int out_pipe, const UUID *connection_uuid, const UUID *pipe_uuid, const UUID *association_uuid)
Definition: rpc_message.c:344
smooth NULL
Definition: ftsmooth.c:416
static RPC_STATUS rpcrt4_http_read_http_packet(HINTERNET request, RpcHttpAsyncData *async_data, HANDLE cancel_event, RpcPktHdr *hdr, BYTE **data)
BOOL WINAPI HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders, DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength)
Definition: http.c:5631
#define RPC_S_PROTOCOL_ERROR
Definition: winerror.h:1039
static void prepare_async_request(RpcHttpAsyncData *async_data)
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
int ret
RPC_STATUS RPCRT4_ParseHttpPrepareHeader2(RpcPktHdr *header, unsigned char *data, ULONG *field1, ULONG *bytes_until_next_packet, ULONG *field3)
Definition: rpc_message.c:591
unsigned char BYTE
Definition: xxhash.c:193
RpcPktHttpHdr http
Definition: rpc_defs.h:159
#define ERR(fmt,...)
Definition: debug.h:110
#define RPC_S_OUT_OF_RESOURCES
Definition: winerror.h:1032
unsigned int ULONG
Definition: retypes.h:1
static RPC_STATUS rpcrt4_http_check_response(HINTERNET hor)
unsigned short num_data_items
Definition: rpc_defs.h:139
static SERVICE_STATUS status
Definition: service.c:31
#define HeapFree(x, y, z)
Definition: compat.h:483
#define RPC_S_OK
Definition: rpcnterr.h:22
static RPC_STATUS insert_content_length_header(HINTERNET request, DWORD len)
Definition: ps.c:97

Referenced by rpcrt4_ncacn_http_open().

◆ rpcrt4_http_read_http_packet()

static RPC_STATUS rpcrt4_http_read_http_packet ( HINTERNET  request,
RpcHttpAsyncData async_data,
HANDLE  cancel_event,
RpcPktHdr hdr,
BYTE **  data 
)
static

Definition at line 2199 of file rpc_transport.c.

2201 {
2202  unsigned short data_len;
2203  unsigned int size;
2204 
2205  if (rpcrt4_http_async_read(request, async_data, cancel_event, hdr, sizeof(hdr->common)) < 0)
2206  return RPC_S_SERVER_UNAVAILABLE;
2207  if (hdr->common.ptype != PKT_HTTP || hdr->common.frag_len < sizeof(hdr->http))
2208  {
2209  ERR("wrong packet type received %d or wrong frag_len %d\n",
2210  hdr->common.ptype, hdr->common.frag_len);
2211  return RPC_S_PROTOCOL_ERROR;
2212  }
2213 
2214  size = sizeof(hdr->http) - sizeof(hdr->common);
2215  if (rpcrt4_http_async_read(request, async_data, cancel_event, &hdr->common + 1, size) < 0)
2216  return RPC_S_SERVER_UNAVAILABLE;
2217 
2218  data_len = hdr->common.frag_len - sizeof(hdr->http);
2219  if (data_len)
2220  {
2221  *data = HeapAlloc(GetProcessHeap(), 0, data_len);
2222  if (!*data)
2223  return RPC_S_OUT_OF_RESOURCES;
2224  if (rpcrt4_http_async_read(request, async_data, cancel_event, *data, data_len) < 0)
2225  {
2226  HeapFree(GetProcessHeap(), 0, *data);
2227  return RPC_S_SERVER_UNAVAILABLE;
2228  }
2229  }
2230  else
2231  *data = NULL;
2232 
2233  if (!RPCRT4_IsValidHttpPacket(hdr, *data, data_len))
2234  {
2235  ERR("invalid http packet\n");
2236  HeapFree(GetProcessHeap(), 0, *data);
2237  return RPC_S_PROTOCOL_ERROR;
2238  }
2239 
2240  return RPC_S_OK;
2241 }
static int rpcrt4_http_async_read(HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event, void *buffer, unsigned int count)
char hdr[14]
Definition: iptest.cpp:33
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
smooth NULL
Definition: ftsmooth.c:416
#define RPC_S_PROTOCOL_ERROR
Definition: winerror.h:1039
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define ERR(fmt,...)
Definition: debug.h:110
#define RPC_S_OUT_OF_RESOURCES
Definition: winerror.h:1032
Definition: tftpd.h:85
BOOL RPCRT4_IsValidHttpPacket(RpcPktHdr *hdr, unsigned char *data, unsigned short data_len)
Definition: rpc_message.c:483
#define HeapFree(x, y, z)
Definition: compat.h:483
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by rpcrt4_http_prepare_out_pipe().

◆ rpcrt4_http_timer_calc_timeout()

static DWORD rpcrt4_http_timer_calc_timeout ( DWORD last_sent_time)
inlinestatic

Definition at line 1868 of file rpc_transport.c.

1869 {
1871  DWORD cached_last_sent_time = *last_sent_time;
1872  return HTTP_IDLE_TIME - (cur_time - cached_last_sent_time > HTTP_IDLE_TIME ? 0 : cur_time - cached_last_sent_time);
1873 }
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
time_t cur_time
#define HTTP_IDLE_TIME
unsigned long DWORD
Definition: ntddk_ex.h:95

Referenced by rpcrt4_http_timer_thread().

◆ rpcrt4_http_timer_thread()

static DWORD CALLBACK rpcrt4_http_timer_thread ( PVOID  param)
static

Definition at line 1875 of file rpc_transport.c.

1876 {
1877  HttpTimerThreadData *data_in = param;
1879  DWORD timeout;
1880 
1881  data = *data_in;
1882  HeapFree(GetProcessHeap(), 0, data_in);
1883 
1884  for (timeout = HTTP_IDLE_TIME;
1885  WaitForSingleObject(data.timer_cancelled, timeout) == WAIT_TIMEOUT;
1886  timeout = rpcrt4_http_timer_calc_timeout(data.last_sent_time))
1887  {
1888  /* are we too soon after last send? */
1889  if (GetTickCount() - *data.last_sent_time < HTTP_IDLE_TIME)
1890  continue;
1892  }
1893 
1894  CloseHandle(data.timer_cancelled);
1895  return 0;
1896 }
#define CloseHandle
Definition: compat.h:487
#define TRUE
Definition: types.h:120
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
#define HTTP_IDLE_TIME
Definition: dhcpd.h:245
GLbitfield GLuint64 timeout
Definition: glext.h:7164
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define GetProcessHeap()
Definition: compat.h:484
GLfloat param
Definition: glext.h:5796
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define WAIT_TIMEOUT
Definition: dderror.h:14
static VOID rpcrt4_http_keep_connection_active_timer_proc(PVOID param, BOOLEAN dummy)
static DWORD rpcrt4_http_timer_calc_timeout(DWORD *last_sent_time)
#define HeapFree(x, y, z)
Definition: compat.h:483

Referenced by rpcrt4_ncacn_http_open().

◆ rpcrt4_ip_tcp_get_top_of_tower()

static size_t rpcrt4_ip_tcp_get_top_of_tower ( unsigned char tower_data,
const char networkaddr,
unsigned char  tcp_protid,
const char endpoint 
)
static

Definition at line 980 of file rpc_transport.c.

984 {
985  twr_tcp_floor_t *tcp_floor;
986  twr_ipv4_floor_t *ipv4_floor;
987  struct addrinfo *ai;
988  struct addrinfo hints;
989  int ret;
990  size_t size = sizeof(*tcp_floor) + sizeof(*ipv4_floor);
991 
992  TRACE("(%p, %s, %s)\n", tower_data, networkaddr, endpoint);
993 
994  if (!tower_data)
995  return size;
996 
997  tcp_floor = (twr_tcp_floor_t *)tower_data;
998  tower_data += sizeof(*tcp_floor);
999 
1000  ipv4_floor = (twr_ipv4_floor_t *)tower_data;
1001 
1002  tcp_floor->count_lhs = sizeof(tcp_floor->protid);
1003  tcp_floor->protid = tcp_protid;
1004  tcp_floor->count_rhs = sizeof(tcp_floor->port);
1005 
1006  ipv4_floor->count_lhs = sizeof(ipv4_floor->protid);
1007  ipv4_floor->protid = EPM_PROTOCOL_IP;
1008  ipv4_floor->count_rhs = sizeof(ipv4_floor->ipv4addr);
1009 
1010  hints.ai_flags = AI_NUMERICHOST;
1011  /* FIXME: only support IPv4 at the moment. how is IPv6 represented by the EPM? */
1012  hints.ai_family = PF_INET;
1013  hints.ai_socktype = SOCK_STREAM;
1014  hints.ai_protocol = IPPROTO_TCP;
1015  hints.ai_addrlen = 0;
1016  hints.ai_addr = NULL;
1017  hints.ai_canonname = NULL;
1018  hints.ai_next = NULL;
1019 
1020  ret = getaddrinfo(networkaddr, endpoint, &hints, &ai);
1021  if (ret)
1022  {
1023  ret = getaddrinfo("0.0.0.0", endpoint, &hints, &ai);
1024  if (ret)
1025  {
1026  ERR("getaddrinfo failed: %s\n", gai_strerror(ret));
1027  return 0;
1028  }
1029  }
1030 
1031  if (ai->ai_family == PF_INET)
1032  {
1033  const struct sockaddr_in *sin = (const struct sockaddr_in *)ai->ai_addr;
1034  tcp_floor->port = sin->sin_port;
1035  ipv4_floor->ipv4addr = sin->sin_addr.s_addr;
1036  }
1037  else
1038  {
1039  ERR("unexpected protocol family %d\n", ai->ai_family);
1040  freeaddrinfo(ai);
1041  return 0;
1042  }
1043 
1044  freeaddrinfo(ai);
1045 
1046  return size;
1047 }
namespace GUID const ADDRINFOEXW * hints
Definition: sock.c:80
#define freeaddrinfo
Definition: wspiapi.h:46
u_int16 port
Definition: epm_towers.h:70
#define EPM_PROTOCOL_IP
Definition: epm_towers.h:31
smooth NULL
Definition: ftsmooth.c:416
#define PF_INET
Definition: winsock.h:373
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define gai_strerror
Definition: ws2tcpip.h:521
int ret
#define ERR(fmt,...)
Definition: debug.h:110
u_int16 count_lhs
Definition: epm_towers.h:67
#define AI_NUMERICHOST
Definition: ws2def.h:295
Definition: nis.h:10
u_int16 count_rhs
Definition: epm_towers.h:69
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
#define SOCK_STREAM
Definition: tcpip.h:118
struct sockaddr * ai_addr
Definition: ws2def.h:671
#define getaddrinfo
Definition: wspiapi.h:44
int ai_family
Definition: ws2def.h:666

Referenced by rpcrt4_ncacn_http_get_top_of_tower(), and rpcrt4_ncacn_ip_tcp_get_top_of_tower().

◆ rpcrt4_ip_tcp_parse_top_of_tower()

static RPC_STATUS rpcrt4_ip_tcp_parse_top_of_tower ( const unsigned char tower_data,
size_t  tower_size,
char **  networkaddr,
unsigned char  tcp_protid,
char **  endpoint 
)
static

Definition at line 1049 of file rpc_transport.c.

1054 {
1055  const twr_tcp_floor_t *tcp_floor = (const twr_tcp_floor_t *)tower_data;
1056  const twr_ipv4_floor_t *ipv4_floor;
1057  struct in_addr in_addr;
1058 
1059  TRACE("(%p, %d, %p, %p)\n", tower_data, (int)tower_size, networkaddr, endpoint);
1060 
1061  if (tower_size < sizeof(*tcp_floor))
1062  return EPT_S_NOT_REGISTERED;
1063 
1064  tower_data += sizeof(*tcp_floor);
1065  tower_size -= sizeof(*tcp_floor);
1066 
1067  if (tower_size < sizeof(*ipv4_floor))
1068  return EPT_S_NOT_REGISTERED;
1069 
1070  ipv4_floor = (const twr_ipv4_floor_t *)tower_data;
1071 
1072  if ((tcp_floor->count_lhs != sizeof(tcp_floor->protid)) ||
1073  (tcp_floor->protid != tcp_protid) ||
1074  (tcp_floor->count_rhs != sizeof(tcp_floor->port)) ||
1075  (ipv4_floor->count_lhs != sizeof(ipv4_floor->protid)) ||
1076  (ipv4_floor->protid != EPM_PROTOCOL_IP) ||
1077  (ipv4_floor->count_rhs != sizeof(ipv4_floor->ipv4addr)))
1078  return EPT_S_NOT_REGISTERED;
1079 
1080  if (endpoint)
1081  {
1082  *endpoint = I_RpcAllocate(6 /* sizeof("65535") + 1 */);
1083  if (!*endpoint)
1084  return RPC_S_OUT_OF_RESOURCES;
1085  sprintf(*endpoint, "%u", ntohs(tcp_floor->port));
1086  }
1087 
1088  if (networkaddr)
1089  {
1090  *networkaddr = I_RpcAllocate(INET_ADDRSTRLEN);
1091  if (!*networkaddr)
1092  {
1093  if (endpoint)
1094  {
1095  I_RpcFree(*endpoint);
1096  *endpoint = NULL;
1097  }
1098  return RPC_S_OUT_OF_RESOURCES;
1099  }
1100  in_addr.s_addr = ipv4_floor->ipv4addr;
1101  if (!inet_ntop(AF_INET, &in_addr, *networkaddr, INET_ADDRSTRLEN))
1102  {
1103  ERR("inet_ntop: %u\n", WSAGetLastError());
1104  I_RpcFree(*networkaddr);
1105  *networkaddr = NULL;
1106  if (endpoint)
1107  {
1108  I_RpcFree(*endpoint);
1109  *endpoint = NULL;
1110  }
1111  return EPT_S_NOT_REGISTERED;
1112  }
1113  }
1114 
1115  return RPC_S_OK;
1116 }
void WINAPI I_RpcFree(void *Object)
Definition: rpcrt4_main.c:722
u_int16 count_rhs
Definition: epm_towers.h:77
u_int32 ipv4addr
Definition: epm_towers.h:78
u32_t s_addr
Definition: inet.h:45
#define ntohs(x)
Definition: module.h:208
u_int16 port
Definition: epm_towers.h:70
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define EPM_PROTOCOL_IP
Definition: epm_towers.h:31
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
Definition: tcpip.h:125
#define INET_ADDRSTRLEN
Definition: ws2ipdef.h:131
#define ERR(fmt,...)
Definition: debug.h:110
u_int16 count_lhs
Definition: epm_towers.h:67
Definition: nis.h:10
u_int16 count_rhs
Definition: epm_towers.h:69
#define RPC_S_OUT_OF_RESOURCES
Definition: winerror.h:1032
#define EPT_S_NOT_REGISTERED
Definition: winerror.h:1061
#define AF_INET
Definition: tcpip.h:117
u_int16 count_lhs
Definition: epm_towers.h:75
const char *WSAAPI inet_ntop(int af, const void *src, char *dst, size_t cnt)
Definition: unix_func.c:8
void *WINAPI I_RpcAllocate(unsigned int Size)
Definition: rpcrt4_main.c:714
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by rpcrt4_ncacn_http_parse_top_of_tower(), and rpcrt4_ncacn_ip_tcp_parse_top_of_tower().

◆ RPCRT4_IsServerListening()

RPC_STATUS RPCRT4_IsServerListening ( const char protseq,
const char endpoint 
)

Definition at line 3508 of file rpc_transport.c.

3509 {
3510  const struct connection_ops *ops;
3511 
3512  ops = rpcrt4_get_conn_protseq_ops(protseq);
3513  if (!ops)
3514  {
3515  FIXME("not supported for protseq %s\n", protseq);
3516  return RPC_S_INVALID_BINDING;
3517  }
3518 
3519  return ops->is_server_listening(endpoint);
3520 }
static const struct connection_ops * rpcrt4_get_conn_protseq_ops(const char *protseq)
#define FIXME(fmt,...)
Definition: debug.h:111
#define RPC_S_INVALID_BINDING
Definition: winerror.h:1013
RPC_STATUS(* is_server_listening)(const char *endpoint)
Definition: rpc_binding.h:110
Definition: nis.h:10

Referenced by RpcMgmtIsServerListening().