ReactOS  0.4.9-dev-717-g6d91262
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 "wine/unicode.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 ARRAYSIZE(a)   (sizeof((a)) / sizeof((a)[0]))
 
#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 *Connection)
 
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_ops
rpcrt4_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 unsigned int num_auth_schemes = sizeof(auth_schemes)/sizeof(auth_schemes[0])
 
static const struct connection_ops conn_protseq_list []
 
static const struct protseq_ops protseq_list []
 

Macro Definition Documentation

#define DEFAULT_NCACN_HTTP_TIMEOUT   (60 * 1000)

Definition at line 60 of file rpc_transport.c.

Referenced by wait_async_request().

#define HTTP_IDLE_TIME   60000

Definition at line 1674 of file rpc_transport.c.

Referenced by rpcrt4_http_timer_calc_timeout(), and rpcrt4_http_timer_thread().

#define WIN32_NO_STATUS

Definition at line 27 of file rpc_transport.c.

Typedef Documentation

Function Documentation

static struct authinfo* alloc_authinfo ( void  )
static

Definition at line 2384 of file rpc_transport.c.

Referenced by do_authorization().

2385 {
2386  struct authinfo *ret;
2387 
2388  if (!(ret = HeapAlloc(GetProcessHeap(), 0, sizeof(*ret) ))) return NULL;
2389 
2390  SecInvalidateHandle(&ret->cred);
2391  SecInvalidateHandle(&ret->ctx);
2392  memset(&ret->exp, 0, sizeof(ret->exp));
2393  ret->scheme = 0;
2394  ret->attr = 0;
2395  ret->max_token = 0;
2396  ret->data = NULL;
2397  ret->data_len = 0;
2398  ret->finished = FALSE;
2399  return ret;
2400 }
#define SecInvalidateHandle(x)
Definition: sspi.h:58
CredHandle cred
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
TimeStamp exp
unsigned int data_len
int ret
DWORD scheme
char * data
#define memset(x, y, z)
Definition: compat.h:39
ULONG max_token
CtxtHandle ctx
static DWORD auth_scheme_from_header ( const WCHAR header)
static

Definition at line 2437 of file rpc_transport.c.

Referenced by do_authorization(), and get_authvalue().

2438 {
2439  unsigned int i;
2440  for (i = 0; i < num_auth_schemes; i++)
2441  {
2442  if (!strncmpiW( header, auth_schemes[i].str, auth_schemes[i].len ) &&
2443  (header[auth_schemes[i].len] == ' ' || !header[auth_schemes[i].len])) return auth_schemes[i].scheme;
2444  }
2445  return 0;
2446 }
static const struct @513 auth_schemes[]
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
GLenum GLclampf GLint i
Definition: glfuncs.h:14
const WCHAR * str
GLenum GLsizei len
Definition: glext.h:6722
static const unsigned int num_auth_schemes
struct CFHEADER header
Definition: fdi.c:109
static RPC_STATUS authorize_request ( RpcConnection_http httpc,
HINTERNET  request 
)
static

Definition at line 2669 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_http_open().

2670 {
2671  static const WCHAR authW[] = {'A','u','t','h','o','r','i','z','a','t','i','o','n',':','\r','\n',0};
2672  struct authinfo *info = NULL;
2674  BOOL ret;
2675 
2676  for (;;)
2677  {
2678  status = do_authorization(request, httpc->servername, httpc->common.QOS->qos->u.HttpCredentials, &info);
2679  if (status != RPC_S_OK) break;
2680 
2681  status = insert_authorization_header(request, info->scheme, info->data, info->data_len);
2682  if (status != RPC_S_OK) break;
2683 
2685  ret = HttpSendRequestW(request, NULL, 0, NULL, 0);
2686  status = wait_async_request(httpc->async_data, ret, httpc->cancel_event);
2687  if (status != RPC_S_OK || info->finished) break;
2688 
2689  status = rpcrt4_http_check_response(request);
2690  if (status != RPC_S_OK && status != ERROR_ACCESS_DENIED) break;
2691  drain_content(request, httpc->async_data, httpc->cancel_event);
2692  }
2693 
2696 
2697  destroy_authinfo(info);
2698  return status;
2699 }
static void drain_content(HINTERNET request, RpcHttpAsyncData *async_data, HANDLE cancel_event)
__wchar_t WCHAR
Definition: xmlstorage.h:180
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
Definition: compobj.c:611
union _RPC_SECURITY_QOS_V2_W::@3061 u
#define HTTP_ADDREQ_FLAG_REPLACE
Definition: wininet.h:1711
long RPC_STATUS
Definition: rpc.h:52
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
#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:5561
static RPC_STATUS insert_authorization_header(HINTERNET request, ULONG scheme, char *data, int data_len)
static void prepare_async_request(RpcHttpAsyncData *async_data)
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned int data_len
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:1354
static void destroy_authinfo(struct authinfo *info)
RPC_SECURITY_QOS_V2_W * qos
Definition: rpc_binding.h:57
DWORD scheme
char * data
RpcHttpAsyncData * async_data
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
static unsigned int decode_base64 ( const WCHAR base64,
unsigned int  len,
char buf 
)
static

Definition at line 2322 of file rpc_transport.c.

Referenced by do_authorization().

2323 {
2324  unsigned int i = 0;
2325  char c0, c1, c2, c3;
2326  const WCHAR *p = base64;
2327 
2328  while (len > 4)
2329  {
2330  if ((c0 = decode_char( p[0] )) > 63) return 0;
2331  if ((c1 = decode_char( p[1] )) > 63) return 0;
2332  if ((c2 = decode_char( p[2] )) > 63) return 0;
2333  if ((c3 = decode_char( p[3] )) > 63) return 0;
2334 
2335  if (buf)
2336  {
2337  buf[i + 0] = (c0 << 2) | (c1 >> 4);
2338  buf[i + 1] = (c1 << 4) | (c2 >> 2);
2339  buf[i + 2] = (c2 << 6) | c3;
2340  }
2341  len -= 4;
2342  i += 3;
2343  p += 4;
2344  }
2345  if (p[2] == '=')
2346  {
2347  if ((c0 = decode_char( p[0] )) > 63) return 0;
2348  if ((c1 = decode_char( p[1] )) > 63) return 0;
2349 
2350  if (buf) buf[i] = (c0 << 2) | (c1 >> 4);
2351  i++;
2352  }
2353  else if (p[3] == '=')
2354  {
2355  if ((c0 = decode_char( p[0] )) > 63) return 0;
2356  if ((c1 = decode_char( p[1] )) > 63) return 0;
2357  if ((c2 = decode_char( p[2] )) > 63) return 0;
2358 
2359  if (buf)
2360  {
2361  buf[i + 0] = (c0 << 2) | (c1 >> 4);
2362  buf[i + 1] = (c1 << 4) | (c2 >> 2);
2363  }
2364  i += 2;
2365  }
2366  else
2367  {
2368  if ((c0 = decode_char( p[0] )) > 63) return 0;
2369  if ((c1 = decode_char( p[1] )) > 63) return 0;
2370  if ((c2 = decode_char( p[2] )) > 63) return 0;
2371  if ((c3 = decode_char( p[3] )) > 63) return 0;
2372 
2373  if (buf)
2374  {
2375  buf[i + 0] = (c0 << 2) | (c1 >> 4);
2376  buf[i + 1] = (c1 << 4) | (c2 >> 2);
2377  buf[i + 2] = (c2 << 6) | c3;
2378  }
2379  i += 3;
2380  }
2381  return i;
2382 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLclampf GLint i
Definition: glfuncs.h:14
GLenum GLsizei len
Definition: glext.h:6722
static char decode_char(WCHAR c)
GLfloat GLfloat p
Definition: glext.h:8902
static char decode_char ( WCHAR  c)
inlinestatic

Definition at line 2312 of file rpc_transport.c.

Referenced by decode_base64().

2313 {
2314  if (c >= 'A' && c <= 'Z') return c - 'A';
2315  if (c >= 'a' && c <= 'z') return c - 'a' + 26;
2316  if (c >= '0' && c <= '9') return c - '0' + 52;
2317  if (c == '+') return 62;
2318  if (c == '/') return 63;
2319  return 64;
2320 }
const GLubyte * c
Definition: glext.h:8905
static void destroy_authinfo ( struct authinfo info)
static

Definition at line 2402 of file rpc_transport.c.

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

2403 {
2404  if (!info) return;
2405 
2406  if (SecIsValidHandle(&info->ctx))
2407  DeleteSecurityContext(&info->ctx);
2408  if (SecIsValidHandle(&info->cred))
2409  FreeCredentialsHandle(&info->cred);
2410 
2411  HeapFree(GetProcessHeap(), 0, info->data);
2412  HeapFree(GetProcessHeap(), 0, info);
2413 }
#define SecIsValidHandle(x)
Definition: sspi.h:63
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)
Definition: wrapper.c:151
CredHandle cred
#define GetProcessHeap()
Definition: compat.h:395
char * data
#define HeapFree(x, y, z)
Definition: compat.h:394
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:450
CtxtHandle ctx
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 2460 of file rpc_transport.c.

Referenced by authorize_request().

2462 {
2463  struct authinfo *info = *auth_ptr;
2466 
2467  if ((!info && !(info = alloc_authinfo()))) return RPC_S_SERVER_UNAVAILABLE;
2468 
2469  switch (creds->AuthnSchemes[0])
2470  {
2472  {
2473  int userlen = WideCharToMultiByte(CP_UTF8, 0, id->User, id->UserLength, NULL, 0, NULL, NULL);
2474  int passlen = WideCharToMultiByte(CP_UTF8, 0, id->Password, id->PasswordLength, NULL, 0, NULL, NULL);
2475 
2476  info->data_len = userlen + passlen + 1;
2477  if (!(info->data = HeapAlloc(GetProcessHeap(), 0, info->data_len)))
2478  {
2479  status = RPC_S_OUT_OF_MEMORY;
2480  break;
2481  }
2482  WideCharToMultiByte(CP_UTF8, 0, id->User, id->UserLength, info->data, userlen, NULL, NULL);
2483  info->data[userlen] = ':';
2484  WideCharToMultiByte(CP_UTF8, 0, id->Password, id->PasswordLength, info->data + userlen + 1, passlen, NULL, NULL);
2485 
2487  info->finished = TRUE;
2488  status = RPC_S_OK;
2489  break;
2490  }
2493  {
2494 
2495  static SEC_WCHAR ntlmW[] = {'N','T','L','M',0}, negotiateW[] = {'N','e','g','o','t','i','a','t','e',0};
2497  SecBufferDesc out_desc, in_desc;
2498  SecBuffer out, in;
2500  SEC_WCHAR *scheme;
2501  int scheme_len;
2502  const WCHAR *p;
2503  WCHAR auth_value[2048];
2504  DWORD size = sizeof(auth_value);
2505  BOOL first = FALSE;
2506 
2507  if (creds->AuthnSchemes[0] == RPC_C_HTTP_AUTHN_SCHEME_NTLM) scheme = ntlmW;
2508  else scheme = negotiateW;
2509  scheme_len = strlenW( scheme );
2510 
2511  if (!*auth_ptr)
2512  {
2513  TimeStamp exp;
2514  SecPkgInfoW *pkg_info;
2515 
2516  ret = AcquireCredentialsHandleW(NULL, scheme, SECPKG_CRED_OUTBOUND, NULL, id, NULL, NULL, &info->cred, &exp);
2517  if (ret != SEC_E_OK) break;
2518 
2519  ret = QuerySecurityPackageInfoW(scheme, &pkg_info);
2520  if (ret != SEC_E_OK) break;
2521 
2522  info->max_token = pkg_info->cbMaxToken;
2523  FreeContextBuffer(pkg_info);
2524  first = TRUE;
2525  }
2526  else
2527  {
2528  if (info->finished || !get_authvalue(request, creds->AuthnSchemes[0], auth_value, size)) break;
2529  if (auth_scheme_from_header(auth_value) != info->scheme)
2530  {
2531  ERR("authentication scheme changed\n");
2532  break;
2533  }
2534  }
2536  in.cbBuffer = 0;
2537  in.pvBuffer = NULL;
2538 
2539  in_desc.ulVersion = 0;
2540  in_desc.cBuffers = 1;
2541  in_desc.pBuffers = &in;
2542 
2543  p = auth_value + scheme_len;
2544  if (!first && *p == ' ')
2545  {
2546  int len = strlenW(++p);
2547  in.cbBuffer = decode_base64(p, len, NULL);
2548  if (!(in.pvBuffer = HeapAlloc(GetProcessHeap(), 0, in.cbBuffer))) break;
2549  decode_base64(p, len, in.pvBuffer);
2550  }
2552  out.cbBuffer = info->max_token;
2553  if (!(out.pvBuffer = HeapAlloc(GetProcessHeap(), 0, out.cbBuffer)))
2554  {
2555  HeapFree(GetProcessHeap(), 0, in.pvBuffer);
2556  break;
2557  }
2558  out_desc.ulVersion = 0;
2559  out_desc.cBuffers = 1;
2560  out_desc.pBuffers = &out;
2561 
2562  ret = InitializeSecurityContextW(first ? &info->cred : NULL, first ? NULL : &info->ctx,
2563  first ? servername : NULL, flags, 0, SECURITY_NETWORK_DREP,
2564  in.pvBuffer ? &in_desc : NULL, 0, &info->ctx, &out_desc,
2565  &info->attr, &info->exp);
2566  HeapFree(GetProcessHeap(), 0, in.pvBuffer);
2567  if (ret == SEC_E_OK)
2568  {
2569  HeapFree(GetProcessHeap(), 0, info->data);
2570  info->data = out.pvBuffer;
2571  info->data_len = out.cbBuffer;
2572  info->finished = TRUE;
2573  TRACE("sending last auth packet\n");
2574  status = RPC_S_OK;
2575  }
2576  else if (ret == SEC_I_CONTINUE_NEEDED)
2577  {
2578  HeapFree(GetProcessHeap(), 0, info->data);
2579  info->data = out.pvBuffer;
2580  info->data_len = out.cbBuffer;
2581  TRACE("sending next auth packet\n");
2582  status = RPC_S_OK;
2583  }
2584  else
2585  {
2586  ERR("InitializeSecurityContextW failed with error 0x%08x\n", ret);
2587  HeapFree(GetProcessHeap(), 0, out.pvBuffer);
2588  break;
2589  }
2590  info->scheme = creds->AuthnSchemes[0];
2591  break;
2592  }
2593  default:
2594  FIXME("scheme %u not supported\n", creds->AuthnSchemes[0]);
2595  break;
2596  }
2597 
2598  if (status != RPC_S_OK)
2599  {
2600  destroy_authinfo(info);
2601  *auth_ptr = NULL;
2602  return status;
2603  }
2604  *auth_ptr = info;
2605  return RPC_S_OK;
2606 }
static struct authinfo * alloc_authinfo(void)
#define TRUE
Definition: types.h:120
unsigned short * User
Definition: rpcdce.h:223
#define SECPKG_CRED_OUTBOUND
Definition: sspi.h:277
SEC_WINNT_AUTH_IDENTITY_W * TransportCredentials
Definition: rpcdce.h:245
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
static DWORD auth_scheme_from_header(const WCHAR *header)
#define WideCharToMultiByte
Definition: compat.h:101
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
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned short * Password
Definition: rpcdce.h:227
ULONG ulVersion
Definition: sspi.h:167
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:348
Definition: compobj.c:611
DWORD DWORD
Definition: winlogon.h:75
static const WCHAR negotiateW[]
long RPC_STATUS
Definition: rpc.h:52
CredHandle cred
#define FALSE
Definition: types.h:117
#define CP_UTF8
Definition: nls.h:20
#define RPC_S_OUT_OF_MEMORY
Definition: rpcnterr.h:24
ULONG cbMaxToken
Definition: sspi.h:104
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define SEC_I_CONTINUE_NEEDED
Definition: winerror.h:2927
static const WCHAR ntlmW[]
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
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:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
TimeStamp exp
static FILE * out
Definition: regtests2xml.c:44
unsigned int data_len
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:147
ULONG BufferType
Definition: sspi.h:140
#define ISC_REQ_USE_DCE_STYLE
Definition: sspi.h:357
GLenum GLsizei len
Definition: glext.h:6722
static void destroy_authinfo(struct authinfo *info)
#define SECURITY_NETWORK_DREP
Definition: sspi.h:460
DWORD scheme
#define SEC_E_OK
Definition: winerror.h:2356
GLfloat CONST GLvector4f * in
Definition: m_xform.h:122
#define ISC_REQ_CONNECTION
Definition: sspi.h:359
#define ERR(fmt,...)
Definition: debug.h:109
char * data
const XML_Char XML_Encoding * info
Definition: expat.h:530
ULONG cbBuffer
Definition: sspi.h:139
#define ISC_REQ_MUTUAL_AUTH
Definition: sspi.h:349
static unsigned int decode_base64(const WCHAR *base64, unsigned int len, char *buf)
LONG SECURITY_STATUS
Definition: sspi.h:34
DWORD exp
Definition: msg.c:15681
unsigned int ULONG
Definition: retypes.h:1
GLfloat GLfloat p
Definition: glext.h:8902
static BOOL get_authvalue(HINTERNET request, DWORD scheme, WCHAR *buffer, DWORD buflen)
ULONG cBuffers
Definition: sspi.h:168
static SERVICE_STATUS status
Definition: service.c:31
#define HeapFree(x, y, z)
Definition: compat.h:394
ULONG max_token
SECURITY_STATUS WINAPI QuerySecurityPackageInfoW(SEC_WCHAR *pszPackageName, PSecPkgInfoW *ppPackageInfo)
Definition: wrapper.c:750
#define RPC_S_OK
Definition: rpcnterr.h:22
CtxtHandle ctx
Definition: ps.c:97
static void drain_content ( HINTERNET  request,
RpcHttpAsyncData async_data,
HANDLE  cancel_event 
)
static

Definition at line 2654 of file rpc_transport.c.

Referenced by authorize_request(), and rpcrt4_ncacn_http_open().

2655 {
2656  DWORD count, len = 0, size = sizeof(len);
2657  char buf[2048];
2658 
2660  if (!len) return;
2661  for (;;)
2662  {
2663  count = min(sizeof(buf), len);
2664  if (rpcrt4_http_async_read(request, async_data, cancel_event, buf, count) <= 0) return;
2665  len -= count;
2666  }
2667 }
#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
DWORD DWORD
Definition: winlogon.h:75
unsigned int len
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
GLuint GLuint GLsizei count
Definition: gl.h:1545
BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
Definition: http.c:3807
GLenum GLsizei len
Definition: glext.h:6722
#define min(a, b)
Definition: monoChain.cc:55
#define HTTP_QUERY_FLAG_NUMBER
Definition: wininet.h:1606
static UINT encode_base64 ( const char bin,
unsigned int  len,
WCHAR base64 
)
static

Definition at line 2272 of file rpc_transport.c.

Referenced by insert_authorization_header().

2273 {
2274  static const char enc[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2275  UINT i = 0, x;
2276 
2277  while (len > 0)
2278  {
2279  /* first 6 bits, all from bin[0] */
2280  base64[i++] = enc[(bin[0] & 0xfc) >> 2];
2281  x = (bin[0] & 3) << 4;
2282 
2283  /* next 6 bits, 2 from bin[0] and 4 from bin[1] */
2284  if (len == 1)
2285  {
2286  base64[i++] = enc[x];
2287  base64[i++] = '=';
2288  base64[i++] = '=';
2289  break;
2290  }
2291  base64[i++] = enc[x | ((bin[1] & 0xf0) >> 4)];
2292  x = (bin[1] & 0x0f) << 2;
2293 
2294  /* next 6 bits 4 from bin[1] and 2 from bin[2] */
2295  if (len == 2)
2296  {
2297  base64[i++] = enc[x];
2298  base64[i++] = '=';
2299  break;
2300  }
2301  base64[i++] = enc[x | ((bin[2] & 0xc0) >> 6)];
2302 
2303  /* last 6 bits, all from bin [2] */
2304  base64[i++] = enc[bin[2] & 0x3f];
2305  bin += 3;
2306  len -= 3;
2307  }
2308  base64[i] = 0;
2309  return i;
2310 }
GLenum GLclampf GLint i
Definition: glfuncs.h:14
GLenum GLsizei len
Definition: glext.h:6722
unsigned int UINT
Definition: ndis.h:50
static struct _PeImage bin
INT x
Definition: msvc.h:62
static BOOL get_authvalue ( HINTERNET  request,
DWORD  scheme,
WCHAR buffer,
DWORD  buflen 
)
static

Definition at line 2448 of file rpc_transport.c.

Referenced by do_authorization().

2449 {
2450  DWORD len, index = 0;
2451  for (;;)
2452  {
2453  len = buflen;
2454  if (!HttpQueryInfoW(request, HTTP_QUERY_WWW_AUTHENTICATE, buffer, &len, &index)) return FALSE;
2455  if (auth_scheme_from_header(buffer) == scheme) break;
2456  }
2457  return TRUE;
2458 }
#define TRUE
Definition: types.h:120
static DWORD auth_scheme_from_header(const WCHAR *header)
DWORD scheme
GLuint buffer
Definition: glext.h:5915
#define HTTP_QUERY_WWW_AUTHENTICATE
Definition: wininet.h:1563
DWORD DWORD
Definition: winlogon.h:75
unsigned int len
#define FALSE
Definition: types.h:117
GLuint index
Definition: glext.h:6031
BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
Definition: http.c:3807
static HANDLE get_np_event ( RpcConnection_np connection)
static

Definition at line 103 of file rpc_transport.c.

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

104 {
105  HANDLE event = InterlockedExchangePointer(&connection->event_cache, NULL);
106  return event ? event : CreateEventW(NULL, TRUE, FALSE, NULL);
107 }
#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:597
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
DWORD *typedef HANDLE
Definition: winlogon.h:52
static BOOL has_credentials ( RpcConnection_http httpc)
static

Definition at line 2701 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_http_open().

2702 {
2705 
2707  return FALSE;
2708 
2709  creds = httpc->common.QOS->qos->u.HttpCredentials;
2711  return FALSE;
2712 
2713  id = creds->TransportCredentials;
2714  if (!id || !id->User || !id->Password) return FALSE;
2715 
2716  return TRUE;
2717 }
#define TRUE
Definition: types.h:120
unsigned short * User
Definition: rpcdce.h:223
SEC_WINNT_AUTH_IDENTITY_W * TransportCredentials
Definition: rpcdce.h:245
#define RPC_C_HTTP_AUTHN_TARGET_SERVER
Definition: rpcdce.h:202
unsigned short * Password
Definition: rpcdce.h:227
RpcConnection common
RPC_HTTP_TRANSPORT_CREDENTIALS_W * HttpCredentials
Definition: rpcdce.h:279
union _RPC_SECURITY_QOS_V2_W::@3061 u
#define FALSE
Definition: types.h:117
RPC_SECURITY_QOS_V2_W * qos
Definition: rpc_binding.h:57
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
static RPC_STATUS insert_authorization_header ( HINTERNET  request,
ULONG  scheme,
char data,
int  data_len 
)
static

Definition at line 2608 of file rpc_transport.c.

Referenced by authorize_request().

2609 {
2610  static const WCHAR authW[] = {'A','u','t','h','o','r','i','z','a','t','i','o','n',':',' '};
2611  static const WCHAR basicW[] = {'B','a','s','i','c',' '};
2612  static const WCHAR negotiateW[] = {'N','e','g','o','t','i','a','t','e',' '};
2613  static const WCHAR ntlmW[] = {'N','T','L','M',' '};
2614  int scheme_len, auth_len = sizeof(authW) / sizeof(authW[0]), len = ((data_len + 2) * 4) / 3;
2615  const WCHAR *scheme_str;
2616  WCHAR *header, *ptr;
2618 
2619  switch (scheme)
2620  {
2622  scheme_str = basicW;
2623  scheme_len = sizeof(basicW) / sizeof(basicW[0]);
2624  break;
2626  scheme_str = negotiateW;
2627  scheme_len = sizeof(negotiateW) / sizeof(negotiateW[0]);
2628  break;
2630  scheme_str = ntlmW;
2631  scheme_len = sizeof(ntlmW) / sizeof(ntlmW[0]);
2632  break;
2633  default:
2634  ERR("unknown scheme %u\n", scheme);
2635  return RPC_S_SERVER_UNAVAILABLE;
2636  }
2637  if ((header = HeapAlloc(GetProcessHeap(), 0, (auth_len + scheme_len + len + 2) * sizeof(WCHAR))))
2638  {
2639  memcpy(header, authW, auth_len * sizeof(WCHAR));
2640  ptr = header + auth_len;
2641  memcpy(ptr, scheme_str, scheme_len * sizeof(WCHAR));
2642  ptr += scheme_len;
2643  len = encode_base64(data, data_len, ptr);
2644  ptr[len++] = '\r';
2645  ptr[len++] = '\n';
2646  ptr[len] = 0;
2648  status = RPC_S_OK;
2649  HeapFree(GetProcessHeap(), 0, header);
2650  }
2651  return status;
2652 }
static const WCHAR basicW[]
__wchar_t WCHAR
Definition: xmlstorage.h:180
#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:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
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:1354
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:109
static SERVICE_STATUS status
Definition: service.c:31
#define HeapFree(x, y, z)
Definition: compat.h:394
struct CFHEADER header
Definition: fdi.c:109
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: ps.c:97
static RPC_STATUS insert_content_length_header ( HINTERNET  request,
DWORD  len 
)
static

Definition at line 2096 of file rpc_transport.c.

Referenced by rpcrt4_http_prepare_in_pipe(), and rpcrt4_http_prepare_out_pipe().

2097 {
2098  static const WCHAR fmtW[] =
2099  {'C','o','n','t','e','n','t','-','L','e','n','g','t','h',':',' ','%','u','\r','\n',0};
2100  WCHAR header[sizeof(fmtW) / sizeof(fmtW[0]) + 10];
2101 
2102  sprintfW(header, fmtW, len);
2103  if ((HttpAddRequestHeadersW(request, header, -1, HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD))) return RPC_S_OK;
2104  return RPC_S_SERVER_UNAVAILABLE;
2105 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
#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
BOOL WINAPI HttpAddRequestHeadersW(HINTERNET hHttpRequest, LPCWSTR lpszHeader, DWORD dwHeaderLength, DWORD dwModifier)
Definition: http.c:1354
GLenum GLsizei len
Definition: glext.h:6722
#define sprintfW
Definition: unicode.h:58
struct CFHEADER header
Definition: fdi.c:109
#define RPC_S_OK
Definition: rpcnterr.h:22
static RPC_STATUS is_pipe_listening ( const char pipe_name)
static

Definition at line 351 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_np_is_server_listening(), and rpcrt4_ncalrpc_np_is_server_listening().

352 {
353  return WaitNamedPipeA(pipe_name, 1) ? RPC_S_OK : RPC_S_NOT_LISTENING;
354 }
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
static BOOL is_secure ( RpcConnection_http httpc)
static

Definition at line 2719 of file rpc_transport.c.

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

2720 {
2721  return httpc->common.QOS &&
2724 }
RpcConnection common
RPC_HTTP_TRANSPORT_CREDENTIALS_W * HttpCredentials
Definition: rpcdce.h:279
union _RPC_SECURITY_QOS_V2_W::@3061 u
RPC_SECURITY_QOS_V2_W * qos
Definition: rpc_binding.h:57
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
static char* ncacn_pipe_name ( const char endpoint)
static

Definition at line 261 of file rpc_transport.c.

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

262 {
263  static const char prefix[] = "\\\\.";
264  char *pipe_name;
265 
266  /* protseq=ncacn_np: named pipes */
267  pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(endpoint));
268  strcat(strcpy(pipe_name, prefix), endpoint);
269  return pipe_name;
270 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
const XML_Char * prefix
Definition: expat.h:380
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:717
static char* ncalrpc_pipe_name ( const char endpoint)
static

Definition at line 200 of file rpc_transport.c.

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

201 {
202  static const char prefix[] = "\\\\.\\pipe\\lrpc\\";
203  char *pipe_name;
204 
205  /* protseq=ncalrpc: supposed to use NT LPC ports,
206  * but we'll implement it with named pipes for now */
207  pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(endpoint));
208  strcat(strcpy(pipe_name, prefix), endpoint);
209  return pipe_name;
210 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
const XML_Char * prefix
Definition: expat.h:380
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:717
static void prepare_async_request ( RpcHttpAsyncData async_data)
static

Definition at line 1708 of file rpc_transport.c.

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().

1709 {
1710  ResetEvent(async_data->completion_event);
1711  RpcHttpAsyncData_AddRef(async_data);
1712 }
static ULONG RpcHttpAsyncData_AddRef(RpcHttpAsyncData *data)
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:660
static void release_np_event ( RpcConnection_np connection,
HANDLE  event 
)
static

Definition at line 109 of file rpc_transport.c.

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

110 {
111  event = InterlockedExchangePointer(&connection->event_cache, event);
112  if (event)
114 }
#define CloseHandle
Definition: compat.h:398
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
struct _cl_event * event
Definition: glext.h:7739
static ULONG RpcHttpAsyncData_AddRef ( RpcHttpAsyncData data)
static

Definition at line 1688 of file rpc_transport.c.

Referenced by prepare_async_request().

1689 {
1690  return InterlockedIncrement(&data->refs);
1691 }
#define InterlockedIncrement
Definition: armddk.h:53
static ULONG RpcHttpAsyncData_Release ( RpcHttpAsyncData data)
static

Definition at line 1693 of file rpc_transport.c.

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

1694 {
1695  ULONG refs = InterlockedDecrement(&data->refs);
1696  if (!refs)
1697  {
1698  TRACE("destroying async data %p\n", data);
1701  data->cs.DebugInfo->Spare[0] = 0;
1702  DeleteCriticalSection(&data->cs);
1703  HeapFree(GetProcessHeap(), 0, data);
1704  }
1705  return refs;
1706 }
#define CloseHandle
Definition: compat.h:398
INTERNET_BUFFERSW inet_buffers
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
PCRITICAL_SECTION_DEBUG DebugInfo
Definition: winbase.h:859
#define InterlockedDecrement
Definition: armddk.h:52
CRITICAL_SECTION cs
unsigned int ULONG
Definition: retypes.h:1
LPVOID lpvBuffer
Definition: wininet.h:277
#define HeapFree(x, y, z)
Definition: compat.h:394
DWORD_PTR Spare[8/sizeof(DWORD_PTR)]
Definition: winbase.h:852
RPC_STATUS WINAPI RpcNetworkInqProtseqsA ( RPC_PROTSEQ_VECTORA **  protseqs)

Definition at line 3669 of file rpc_transport.c.

3670 {
3671  RPC_PROTSEQ_VECTORA *pvector;
3672  unsigned int i;
3674 
3675  TRACE("(%p)\n", protseqs);
3676 
3677  *protseqs = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_PROTSEQ_VECTORW)+(sizeof(unsigned char*)*ARRAYSIZE(protseq_list)));
3678  if (!*protseqs)
3679  goto end;
3680  pvector = *protseqs;
3681  pvector->Count = 0;
3682  for (i = 0; i < ARRAYSIZE(protseq_list); i++)
3683  {
3684  pvector->Protseq[i] = HeapAlloc(GetProcessHeap(), 0, strlen(protseq_list[i].name)+1);
3685  if (pvector->Protseq[i] == NULL)
3686  goto end;
3687  strcpy((char*)pvector->Protseq[i], protseq_list[i].name);
3688  pvector->Count++;
3689  }
3690  status = RPC_S_OK;
3691 
3692 end:
3693  if (status != RPC_S_OK)
3694  RpcProtseqVectorFreeA(protseqs);
3695  return status;
3696 }
static struct list protseqs
Definition: rpc_server.c:71
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
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#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:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
RPC_STATUS WINAPI RpcProtseqVectorFreeA(RPC_PROTSEQ_VECTORA **protseqs)
Definition: name.c:36
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define ARRAYSIZE(a)
Definition: rpc_transport.c:63
static SERVICE_STATUS status
Definition: service.c:31
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: ps.c:97
RPC_STATUS WINAPI RpcNetworkInqProtseqsW ( RPC_PROTSEQ_VECTORW **  protseqs)

Definition at line 3636 of file rpc_transport.c.

3637 {
3638  RPC_PROTSEQ_VECTORW *pvector;
3639  unsigned int i;
3641 
3642  TRACE("(%p)\n", protseqs);
3643 
3644  *protseqs = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_PROTSEQ_VECTORW)+(sizeof(unsigned short*)*ARRAYSIZE(protseq_list)));
3645  if (!*protseqs)
3646  goto end;
3647  pvector = *protseqs;
3648  pvector->Count = 0;
3649  for (i = 0; i < ARRAYSIZE(protseq_list); i++)
3650  {
3651  pvector->Protseq[i] = HeapAlloc(GetProcessHeap(), 0, (strlen(protseq_list[i].name)+1)*sizeof(unsigned short));
3652  if (pvector->Protseq[i] == NULL)
3653  goto end;
3654  MultiByteToWideChar(CP_ACP, 0, (CHAR*)protseq_list[i].name, -1,
3655  (WCHAR*)pvector->Protseq[i], strlen(protseq_list[i].name) + 1);
3656  pvector->Count++;
3657  }
3658  status = RPC_S_OK;
3659 
3660 end:
3661  if (status != RPC_S_OK)
3662  RpcProtseqVectorFreeW(protseqs);
3663  return status;
3664 }
static struct list protseqs
Definition: rpc_server.c:71
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CP_ACP
Definition: compat.h:99
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
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#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:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define MultiByteToWideChar
Definition: compat.h:100
Definition: name.c:36
#define ARRAYSIZE(a)
Definition: rpc_transport.c:63
static SERVICE_STATUS status
Definition: service.c:31
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: ps.c:97
RPC_STATUS WINAPI RpcNetworkIsProtseqValidA ( RPC_CSTR  protseq)

Definition at line 3584 of file rpc_transport.c.

Referenced by test_rpc_ncacn_ip_tcp().

3585 {
3586  UNICODE_STRING protseqW;
3587 
3588  if (RtlCreateUnicodeStringFromAsciiz(&protseqW, (char*)protseq))
3589  {
3591  RtlFreeUnicodeString(&protseqW);
3592  return ret;
3593  }
3594  return RPC_S_OUT_OF_MEMORY;
3595 }
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)
RPC_STATUS WINAPI RpcNetworkIsProtseqValidW ( RPC_WSTR  protseq)

Definition at line 3567 of file rpc_transport.c.

Referenced by RpcNetworkIsProtseqValidA().

3568 {
3569  char ps[0x10];
3570 
3571  WideCharToMultiByte(CP_ACP, 0, protseq, -1,
3572  ps, sizeof ps, NULL, NULL);
3574  return RPC_S_OK;
3575 
3576  FIXME("Unknown protseq %s\n", debugstr_w(protseq));
3577 
3579 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
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:110
smooth NULL
Definition: ftsmooth.c:416
#define RPC_S_INVALID_RPC_PROTSEQ
Definition: winerror.h:1015
#define RPC_S_OK
Definition: rpcnterr.h:22
RPC_STATUS WINAPI RpcProtseqVectorFreeA ( RPC_PROTSEQ_VECTORA **  protseqs)

Definition at line 3600 of file rpc_transport.c.

Referenced by RpcNetworkInqProtseqsA().

3601 {
3602  TRACE("(%p)\n", protseqs);
3603 
3604  if (*protseqs)
3605  {
3606  unsigned int i;
3607  for (i = 0; i < (*protseqs)->Count; i++)
3608  HeapFree(GetProcessHeap(), 0, (*protseqs)->Protseq[i]);
3609  HeapFree(GetProcessHeap(), 0, *protseqs);
3610  *protseqs = NULL;
3611  }
3612  return RPC_S_OK;
3613 }
GLenum GLclampf GLint i
Definition: glfuncs.h:14
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
#define HeapFree(x, y, z)
Definition: compat.h:394
#define RPC_S_OK
Definition: rpcnterr.h:22
RPC_STATUS WINAPI RpcProtseqVectorFreeW ( RPC_PROTSEQ_VECTORW **  protseqs)

Definition at line 3618 of file rpc_transport.c.

Referenced by RpcNetworkInqProtseqsW().

3619 {
3620  TRACE("(%p)\n", protseqs);
3621 
3622  if (*protseqs)
3623  {
3624  unsigned int i;
3625  for (i = 0; i < (*protseqs)->Count; i++)
3626  HeapFree(GetProcessHeap(), 0, (*protseqs)->Protseq[i]);
3627  HeapFree(GetProcessHeap(), 0, *protseqs);
3628  *protseqs = NULL;
3629  }
3630  return RPC_S_OK;
3631 }
GLenum GLclampf GLint i
Definition: glfuncs.h:14
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
#define HeapFree(x, y, z)
Definition: compat.h:394
#define RPC_S_OK
Definition: rpcnterr.h:22
RPC_STATUS RPCRT4_CloseConnection ( RpcConnection Connection)

Definition at line 3317 of file rpc_transport.c.

Referenced by RPCRT4_ReleaseConnection(), and RPCRT4_server_thread().

3318 {
3319  TRACE("(Connection == ^%p)\n", Connection);
3320  if (SecIsValidHandle(&Connection->ctx))
3321  {
3322  DeleteSecurityContext(&Connection->ctx);
3323  SecInvalidateHandle(&Connection->ctx);
3324  }
3325  rpcrt4_conn_close(Connection);
3326  return RPC_S_OK;
3327 }
static int rpcrt4_conn_close(RpcConnection *Connection)
Definition: rpc_binding.h:199
#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
static RPC_STATUS rpcrt4_conn_create_pipe ( RpcConnection conn)
static

Definition at line 116 of file rpc_transport.c.

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().

117 {
118  RpcConnection_np *connection = (RpcConnection_np *) conn;
119 
120  TRACE("listening on %s\n", connection->listen_pipe);
121 
126  if (connection->pipe == INVALID_HANDLE_VALUE)
127  {
128  WARN("CreateNamedPipe failed with error %d\n", GetLastError());
131  else
133  }
134 
135  return RPC_S_OK;
136 }
#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:111
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1056
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
static RpcConnection* rpcrt4_conn_np_alloc ( void  )
static

Definition at line 97 of file rpc_transport.c.

98 {
100  return &npc->common;
101 }
RpcConnection common
Definition: rpc_transport.c:88
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
static void rpcrt4_conn_np_cancel_call ( RpcConnection conn)
static

Definition at line 492 of file rpc_transport.c.

493 {
494  RpcConnection_np *connection = (RpcConnection_np *)conn;
495  CancelIoEx(connection->pipe, NULL);
496 }
smooth NULL
Definition: ftsmooth.c:416
static int rpcrt4_conn_np_close ( RpcConnection conn)
static

Definition at line 457 of file rpc_transport.c.

458 {
459  RpcConnection_np *connection = (RpcConnection_np *) conn;
460  if (connection->pipe)
461  {
462  FlushFileBuffers(connection->pipe);
463  CloseHandle(connection->pipe);
464  connection->pipe = 0;
465  }
466  if (connection->listen_event)
467  {
468  CloseHandle(connection->listen_event);
469  connection->listen_event = 0;
470  }
471  if (connection->event_cache)
472  {
473  CloseHandle(connection->event_cache);
474  connection->event_cache = 0;
475  }
476  return 0;
477 }
#define CloseHandle
Definition: compat.h:398
BOOL WINAPI FlushFileBuffers(IN HANDLE hFile)
Definition: fileinfo.c:175
static void rpcrt4_conn_np_close_read ( RpcConnection conn)
static

Definition at line 479 of file rpc_transport.c.

480 {
481  RpcConnection_np *connection = (RpcConnection_np*)conn;
483 
484  connection->read_closed = TRUE;
485 #ifdef __REACTOS__ /* FIXME: We should also cancel I/O for other threads */
486  NtCancelIoFile(connection->pipe, &io_status);
487 #else
488  NtCancelIoFileEx(connection->pipe, &connection->io_status, &io_status);
489 #endif
490 }
#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:92
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:3575
static void rpcrt4_conn_np_handoff ( RpcConnection_np old_npc,
RpcConnection_np new_npc 
)
static

Definition at line 321 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_np_handoff(), and rpcrt4_ncalrpc_handoff().

322 {
323  /* because of the way named pipes work, we'll transfer the connected pipe
324  * to the child, then reopen the server binding to continue listening */
325 
326  new_npc->pipe = old_npc->pipe;
327  old_npc->pipe = 0;
328  assert(!old_npc->listen_event);
329 }
#define assert(x)
Definition: debug.h:53
static RPC_STATUS rpcrt4_conn_np_impersonate_client ( RpcConnection conn)
static

Definition at line 617 of file rpc_transport.c.

618 {
619  RpcConnection_np *npc = (RpcConnection_np *)conn;
620  BOOL ret;
621 
622  TRACE("(%p)\n", conn);
623 
624  if (conn->AuthInfo && SecIsValidHandle(&conn->ctx))
626 
627  ret = ImpersonateNamedPipeClient(npc->pipe);
628  if (!ret)
629  {
631  WARN("ImpersonateNamedPipeClient failed with error %u\n", error);
632  switch (error)
633  {
636  }
637  }
638  return RPC_S_OK;
639 }
BOOL WINAPI ImpersonateNamedPipeClient(HANDLE hNamedPipe)
Definition: security.c:898
#define RPC_S_NO_CONTEXT_AVAILABLE
Definition: winerror.h:1073
#define SecIsValidHandle(x)
Definition: sspi.h:63
#define WARN(fmt,...)
Definition: debug.h:111
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1056
#define ERROR_CANNOT_IMPERSONATE
Definition: winerror.h:849
DWORD DWORD
Definition: winlogon.h:75
RPC_STATUS RPCRT4_default_impersonate_client(RpcConnection *conn)
Definition: rpc_message.c:1130
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
int ret
CtxtHandle ctx
Definition: rpc_binding.h:74
RpcAuthInfo * AuthInfo
Definition: rpc_binding.h:77
#define RPC_S_OK
Definition: rpcnterr.h:22
static int rpcrt4_conn_np_read ( RpcConnection conn,
void buffer,
unsigned int  count 
)
static

Definition at line 399 of file rpc_transport.c.

400 {
401  RpcConnection_np *connection = (RpcConnection_np *) conn;
402  HANDLE event;
404 
405  event = get_np_event(connection);
406  if (!event)
407  return -1;
408 
409  if (connection->read_closed)
410  status = STATUS_CANCELLED;
411  else
412  status = NtReadFile(connection->pipe, event, NULL, NULL, &connection->io_status, buffer, count, NULL, NULL);
413  if (status == STATUS_PENDING)
414  {
415  /* check read_closed again before waiting to avoid a race */
416  if (connection->read_closed)
417  {
419 #ifdef __REACTOS__ /* FIXME: We should also cancel I/O for other threads */
420  NtCancelIoFile(connection->pipe, &io_status);
421 #else
422  NtCancelIoFileEx(connection->pipe, &connection->io_status, &io_status);
423 #endif
424  }
426  status = connection->io_status.u.Status;
427  }
428  release_np_event(connection, event);
429  return status && status != STATUS_BUFFER_OVERFLOW ? -1 : connection->io_status.Information;
430 }
static HANDLE get_np_event(RpcConnection_np *connection)
static HANDLE PIO_APC_ROUTINE void PIO_STATUS_BLOCK io_status
Definition: comm.c:54
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
IO_STATUS_BLOCK io_status
Definition: rpc_transport.c:92
smooth NULL
Definition: ftsmooth.c:416
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_PENDING
Definition: ntstatus.h:82
NTSYSAPI NTSTATUS WINAPI NtCancelIoFileEx(HANDLE, PIO_STATUS_BLOCK, PIO_STATUS_BLOCK)
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
GLuint GLuint GLsizei count
Definition: gl.h:1545
struct _cl_event * event
Definition: glext.h:7739
static void release_np_event(RpcConnection_np *connection, HANDLE event)
DWORD *typedef HANDLE
Definition: winlogon.h:52
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:49
NTSTATUS NTAPI NtCancelIoFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock)
Definition: file.c:3575
#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)
static RPC_STATUS rpcrt4_conn_np_revert_to_self ( RpcConnection conn)
static

Definition at line 641 of file rpc_transport.c.

642 {
643  BOOL ret;
644 
645  TRACE("(%p)\n", conn);
646 
647  if (conn->AuthInfo && SecIsValidHandle(&conn->ctx))
648  return RPCRT4_default_revert_to_self(conn);
649 
650  ret = RevertToSelf();
651  if (!ret)
652  {
653  WARN("RevertToSelf failed with error %u\n", GetLastError());
655  }
656  return RPC_S_OK;
657 }
RPC_STATUS RPCRT4_default_revert_to_self(RpcConnection *conn)
Definition: rpc_message.c:1158
#define RPC_S_NO_CONTEXT_AVAILABLE
Definition: winerror.h:1073
BOOL WINAPI RevertToSelf(VOID)
Definition: security.c:1482
#define SecIsValidHandle(x)
Definition: sspi.h:63
#define WARN(fmt,...)
Definition: debug.h:111
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1056
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
int ret
CtxtHandle ctx
Definition: rpc_binding.h:74
RpcAuthInfo * AuthInfo
Definition: rpc_binding.h:77
#define RPC_S_OK
Definition: rpcnterr.h:22
static int rpcrt4_conn_np_wait_for_incoming_data ( RpcConnection Connection)
static

Definition at line 498 of file rpc_transport.c.

499 {
500  /* FIXME: implement when named pipe writes use overlapped I/O */
501  return -1;
502 }
static int rpcrt4_conn_np_write ( RpcConnection conn,
const void buffer,
unsigned int  count 
)
static

Definition at line 432 of file rpc_transport.c.

433 {
434  RpcConnection_np *connection = (RpcConnection_np *) conn;
436  HANDLE event;
438 
439  event = get_np_event(connection);
440  if (!event)
441  return -1;
442 
443  status = NtWriteFile(connection->pipe, event, NULL, NULL, &io_status, buffer, count, NULL, NULL);
444  if (status == STATUS_PENDING)
445  {
447  status = io_status.u.Status;
448  }
449  release_np_event(connection, event);
450  if (status)
451  return -1;
452 
453  assert(io_status.Information == count);
454  return count;
455 }
static HANDLE get_np_event(RpcConnection_np *connection)
static HANDLE PIO_APC_ROUTINE void PIO_STATUS_BLOCK io_status
Definition: comm.c:54
#define assert(x)
Definition: debug.h:53
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
smooth NULL
Definition: ftsmooth.c:416
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_PENDING
Definition: ntstatus.h:82
GLuint GLuint GLsizei count
Definition: gl.h:1545
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)
DWORD *typedef HANDLE
Definition: winlogon.h:52
#define INFINITE
Definition: serial.h:102
static SERVICE_STATUS status
Definition: service.c:31
static RPC_STATUS rpcrt4_conn_open_pipe ( RpcConnection Connection,
LPCSTR  pname,
BOOL  wait 
)
static

Definition at line 138 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_np_open(), and rpcrt4_ncalrpc_open().

139 {
140  RpcConnection_np *npc = (RpcConnection_np *) Connection;
141  HANDLE pipe;
142  DWORD err, dwMode;
143 
144  TRACE("connecting to %s\n", pname);
145 
146  while (TRUE) {
147  DWORD dwFlags = 0;
148  if (Connection->QOS)
149  {
150  dwFlags = SECURITY_SQOS_PRESENT;
151  switch (Connection->QOS->qos->ImpersonationType)
152  {
154  /* FIXME: what to do here? */
155  break;
157  dwFlags |= SECURITY_ANONYMOUS;
158  break;
160  dwFlags |= SECURITY_IDENTIFICATION;
161  break;
163  dwFlags |= SECURITY_IMPERSONATION;
164  break;
166  dwFlags |= SECURITY_DELEGATION;
167  break;
168  }
169  if (Connection->QOS->qos->IdentityTracking == RPC_C_QOS_IDENTITY_DYNAMIC)
170  dwFlags |= SECURITY_CONTEXT_TRACKING;
171  }
173  OPEN_EXISTING, dwFlags | FILE_FLAG_OVERLAPPED, 0);
174  if (pipe != INVALID_HANDLE_VALUE) break;
175  err = GetLastError();
176  if (err == ERROR_PIPE_BUSY) {
178  TRACE("retrying busy server\n");
179  continue;
180  }
181  TRACE("connection failed, error=%x\n", err);
182  return RPC_S_SERVER_TOO_BUSY;
183  }
184  if (!wait || !WaitNamedPipeA(pname, NMPWAIT_WAIT_FOREVER)) {
185  err = GetLastError();
186  WARN("connection failed, error=%x\n", err);
188  }
189  }
190 
191  /* success */
192  /* pipe is connected; change to message-read mode. */
193  dwMode = PIPE_READMODE_MESSAGE;
194  SetNamedPipeHandleState(pipe, &dwMode, NULL, NULL);
195  npc->pipe = pipe;
196 
197  return RPC_S_OK;
198 }
#define TRUE
Definition: types.h:120
#define SECURITY_IDENTIFICATION
Definition: winbase.h:522
#define WARN(fmt,...)
Definition: debug.h:111
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1056
#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
DWORD DWORD
Definition: winlogon.h:75
BOOL WINAPI WaitNamedPipeA(LPCSTR lpNamedPipeName, DWORD nTimeOut)
Definition: npipe.c:433
#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:426
#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
#define ERROR_PIPE_BUSY
Definition: winerror.h:283
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define GENERIC_READ
Definition: compat.h:124
#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
DWORD *typedef HANDLE
Definition: winlogon.h:52
RpcQualityOfService * QOS
Definition: rpc_binding.h:81
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
#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
DWORD HDC HDC DVTARGETDEVICE DWORD dwMode
Definition: msvc.h:106
#define RPC_S_OK
Definition: rpcnterr.h:22
void rpcrt4_conn_release_and_wait ( RpcConnection connection)

Definition at line 3393 of file rpc_transport.c.

Referenced by RPCRT4_server_thread().

3394 {
3395  HANDLE event = NULL;
3396 
3397  if (connection->ref > 1)
3398  event = connection->wait_release = CreateEventW(NULL, TRUE, FALSE, NULL);
3399 
3400  RPCRT4_ReleaseConnection(connection);
3401 
3402  if(event)
3403  {
3405  CloseHandle(event);
3406  }
3407 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
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:597
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
DWORD *typedef HANDLE
Definition: winlogon.h:52
#define INFINITE
Definition: serial.h:102
static RpcConnection* rpcrt4_conn_tcp_alloc ( void  )
static

Definition at line 1142 of file rpc_transport.c.

1143 {
1144  RpcConnection_tcp *tcpc;
1146  if (tcpc == NULL)
1147  return NULL;
1148  tcpc->sock = -1;
1149  if (!rpcrt4_sock_wait_init(tcpc))
1150  {
1151  HeapFree(GetProcessHeap(), 0, tcpc);
1152  return NULL;
1153  }
1154  return &tcpc->common;
1155 }
static BOOL rpcrt4_sock_wait_init(RpcConnection_tcp *tcpc)
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
RpcConnection common
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define HeapFree(x, y, z)
Definition: compat.h:394
static void rpcrt4_conn_tcp_cancel_call ( RpcConnection conn)
static

Definition at line 1492 of file rpc_transport.c.

1493 {
1494  RpcConnection_tcp *connection = (RpcConnection_tcp *) conn;
1495 
1496  TRACE("%p\n", connection);
1497 
1498  SetEvent(connection->cancel_event);
1499 }
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
#define TRACE(s)
Definition: solgame.cpp:4
static int rpcrt4_conn_tcp_close ( RpcConnection conn)
static

Definition at line 1472 of file rpc_transport.c.

1473 {
1474  RpcConnection_tcp *connection = (RpcConnection_tcp *) conn;
1475 
1476  TRACE("%d\n", connection->sock);
1477 
1478  if (connection->sock != -1)
1479  closesocket(connection->sock);
1480  connection->sock = -1;
1481  CloseHandle(connection->sock_event);
1482  CloseHandle(connection->cancel_event);
1483  return 0;
1484 }
#define CloseHandle
Definition: compat.h:398
#define closesocket
Definition: main.c:39
#define TRACE(s)
Definition: solgame.cpp:4
static void rpcrt4_conn_tcp_close_read ( RpcConnection conn)
static

Definition at line 1486 of file rpc_transport.c.

1487 {
1488  RpcConnection_tcp *connection = (RpcConnection_tcp *) conn;
1489  shutdown(connection->sock, SD_RECEIVE);
1490 }
INT WSAAPI shutdown(IN SOCKET s, IN INT how)
Definition: sockctrl.c:506
#define SD_RECEIVE
Definition: winsock.h:54
static RPC_STATUS rpcrt4_conn_tcp_handoff ( RpcConnection old_conn,
RpcConnection new_conn 
)
static

Definition at line 1386 of file rpc_transport.c.

1387 {
1388  int ret;
1389  struct sockaddr_in address;
1390  socklen_t addrsize;
1393  u_long nonblocking;
1394 
1395  addrsize = sizeof(address);
1396  ret = accept(server->sock, (struct sockaddr*) &address, &addrsize);
1397  if (ret < 0)
1398  {
1399  ERR("Failed to accept a TCP connection: error %d\n", ret);
1400  return RPC_S_OUT_OF_RESOURCES;
1401  }
1402 
1403  nonblocking = 1;
1404  ioctlsocket(ret, FIONBIO, &nonblocking);
1405  client->sock = ret;
1406 
1408  ret = getnameinfo((struct sockaddr*)&address, addrsize, client->common.NetworkAddr, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST);
1409  if (ret != 0)
1410  {
1411  ERR("Failed to retrieve the IP address, error %d\n", ret);
1412  return RPC_S_OUT_OF_RESOURCES;
1413  }
1414 
1415  TRACE("Accepted a new TCP connection from %s\n", client->common.NetworkAddr);
1416  return RPC_S_OK;
1417 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
unsigned long u_long
Definition: linux.h:269
#define NI_NUMERICHOST
Definition: ws2def.h:354
#define INET6_ADDRSTRLEN
Definition: request.c:1491
smooth NULL
Definition: ftsmooth.c:416
#define ioctlsocket
Definition: main.c:40
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static FILE * client
Definition: client.c:41
GLuint address
Definition: glext.h:9393
LPSTR NetworkAddr
Definition: rpc_binding.h:67
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:109
#define getnameinfo
Definition: wspiapi.h:45
#define RPC_S_OUT_OF_RESOURCES
Definition: winerror.h:1032
RpcConnection common
#define RPC_S_OK
Definition: rpcnterr.h:22
static RPC_STATUS rpcrt4_conn_tcp_is_server_listening ( const char endpoint)
static

Definition at line 1501 of file rpc_transport.c.

1502 {
1503  FIXME("\n");
1504  return RPC_S_ACCESS_DENIED;
1505 }
#define RPC_S_ACCESS_DENIED
Definition: rpcnterr.h:29
#define FIXME(fmt,...)
Definition: debug.h:110
static int rpcrt4_conn_tcp_read ( RpcConnection Connection,
void buffer,
unsigned int  count 
)
static

Definition at line 1419 of file rpc_transport.c.

1421 {
1422  RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
1423  int bytes_read = 0;
1424  while (bytes_read != count)
1425  {
1426  int r = recv(tcpc->sock, (char *)buffer + bytes_read, count - bytes_read, 0);
1427  if (!r)
1428  return -1;
1429  else if (r > 0)
1430  bytes_read += r;
1431  else if (WSAGetLastError() == WSAEINTR)
1432  continue;
1433  else if (WSAGetLastError() != WSAEWOULDBLOCK)
1434  {
1435  WARN("recv() failed: %u\n", WSAGetLastError());
1436  return -1;
1437  }
1438  else
1439  {
1440  if (!rpcrt4_sock_wait_for_recv(tcpc))
1441  return -1;
1442  }
1443  }
1444  TRACE("%d %p %u -> %d\n", tcpc->sock, buffer, count, bytes_read);
1445  return bytes_read;
1446 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define WARN(fmt,...)
Definition: debug.h:111
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
#define TRACE(s)
Definition: solgame.cpp:4
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
GLuint GLuint GLsizei count
Definition: gl.h:1545
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
static int rpcrt4_conn_tcp_wait_for_incoming_data ( RpcConnection Connection)
static

Definition at line 1507 of file rpc_transport.c.

1508 {
1509  RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
1510 
1511  TRACE("%p\n", Connection);
1512 
1513  if (!rpcrt4_sock_wait_for_recv(tcpc))
1514  return -1;
1515  return 0;
1516 }
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL rpcrt4_sock_wait_for_recv(RpcConnection_tcp *tcpc)
static int rpcrt4_conn_tcp_write ( RpcConnection Connection,
const void buffer,
unsigned int  count 
)
static

Definition at line 1448 of file rpc_transport.c.

1450 {
1451  RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
1452  int bytes_written = 0;
1453  while (bytes_written != count)
1454  {
1455  int r = send(tcpc->sock, (const char *)buffer + bytes_written, count - bytes_written, 0);
1456  if (r >= 0)
1457  bytes_written += r;
1458  else if (WSAGetLastError() == WSAEINTR)
1459  continue;
1460  else if (WSAGetLastError() != WSAEWOULDBLOCK)
1461  return -1;
1462  else
1463  {
1464  if (!rpcrt4_sock_wait_for_send(tcpc))
1465  return -1;
1466  }
1467  }
1468  TRACE("%d %p %u -> %d\n", tcpc->sock, buffer, count, bytes_written);
1469  return bytes_written;
1470 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
#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
GLuint GLuint GLsizei count
Definition: gl.h:1545
static BOOL rpcrt4_sock_wait_for_send(RpcConnection_tcp *tcpc)
#define WSAEINTR
Definition: winerror.h:1942
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 3329 of file rpc_transport.c.

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().

3332 {
3333  static LONG next_id;
3334  const struct connection_ops *ops;
3335  RpcConnection* NewConnection;
3336 
3337  ops = rpcrt4_get_conn_protseq_ops(Protseq);
3338  if (!ops)
3339  {
3340  FIXME("not supported for protseq %s\n", Protseq);
3342  }
3343 
3344  NewConnection = ops->alloc();
3345  NewConnection->ref = 1;
3346  NewConnection->server = server;
3347  NewConnection->ops = ops;
3348  NewConnection->NetworkAddr = RPCRT4_strdupA(NetworkAddr);
3349  NewConnection->Endpoint = RPCRT4_strdupA(Endpoint);
3350  NewConnection->NetworkOptions = RPCRT4_strdupW(NetworkOptions);
3351  NewConnection->CookieAuth = RPCRT4_strdupW(CookieAuth);
3352  NewConnection->MaxTransmissionSize = RPC_MAX_PACKET_SIZE;
3353  NewConnection->NextCallId = 1;
3354 
3355  SecInvalidateHandle(&NewConnection->ctx);
3356  if (AuthInfo) RpcAuthInfo_AddRef(AuthInfo);
3357  NewConnection->AuthInfo = AuthInfo;
3358  NewConnection->auth_context_id = InterlockedIncrement( &next_id );
3359  if (QOS) RpcQualityOfService_AddRef(QOS);
3360  NewConnection->QOS = QOS;
3361 
3362  list_init(&NewConnection->conn_pool_entry);
3363  list_init(&NewConnection->protseq_entry);
3364 
3365  TRACE("connection: %p\n", NewConnection);
3366  *Connection = NewConnection;
3367 
3368  return RPC_S_OK;
3369 }
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)
static LONG next_id
Definition: changenotify.c:91
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:1180
#define FIXME(fmt,...)
Definition: debug.h:110
RpcConnection *(* alloc)(void)
Definition: rpc_binding.h:102
#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
#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:1357
__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
static const struct connection_ops* rpcrt4_get_conn_protseq_ops ( const char protseq)
static

Definition at line 3298 of file rpc_transport.c.

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

3299 {
3300  unsigned int i;
3301  for(i=0; i<ARRAYSIZE(conn_protseq_list); i++)
3302  if (!strcmp(conn_protseq_list[i].name, protseq))
3303  return &conn_protseq_list[i];
3304  return NULL;
3305 }
GLenum GLclampf GLint i
Definition: glfuncs.h:14
smooth NULL
Definition: ftsmooth.c:416
static const struct connection_ops conn_protseq_list[]
Definition: name.c:36
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ARRAYSIZE(a)
Definition: rpc_transport.c:63
const struct protseq_ops* rpcrt4_get_protseq_ops ( const char protseq)

Definition at line 3289 of file rpc_transport.c.

Referenced by alloc_serverprotoseq().

3290 {
3291  unsigned int i;
3292  for(i=0; i<ARRAYSIZE(protseq_list); i++)
3293  if (!strcmp(protseq_list[i].name, protseq))
3294  return &protseq_list[i];
3295  return NULL;
3296 }
static const struct protseq_ops protseq_list[]
GLenum GLclampf GLint i
Definition: glfuncs.h:14
smooth NULL
Definition: ftsmooth.c:416
Definition: name.c:36
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ARRAYSIZE(a)
Definition: rpc_transport.c:63
RpcConnection* RPCRT4_GrabConnection ( RpcConnection connection)

Definition at line 3409 of file rpc_transport.c.

Referenced by RPCRT4_io_thread(), and RPCRT4_server_thread().

3410 {
3411  LONG ref = InterlockedIncrement(&connection->ref);
3412  TRACE("%p ref=%u\n", connection, ref);
3413  return connection;
3414 }
Definition: send.c:47
long LONG
Definition: pedump.c:60
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53
static int rpcrt4_http_async_read ( HINTERNET  req,
RpcHttpAsyncData async_data,
HANDLE  cancel_event,
void buffer,
unsigned int  count 
)
static

Definition at line 2035 of file rpc_transport.c.

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

2037 {
2038  char *buf = buffer;
2039  BOOL ret;
2040  unsigned int bytes_left = count;
2042 
2043  async_data->inet_buffers.lpvBuffer = HeapAlloc(GetProcessHeap(), 0, count);
2044 
2045  while (bytes_left)
2046  {
2047  async_data->inet_buffers.dwBufferLength = bytes_left;
2048  prepare_async_request(async_data);
2049  ret = InternetReadFileExW(req, &async_data->inet_buffers, IRF_ASYNC, 0);
2050  status = wait_async_request(async_data, ret, cancel_event);
2051  if (status != RPC_S_OK)
2052  {
2053  if (status == RPC_S_CALL_CANCELLED)
2054  TRACE("call cancelled\n");
2055  break;
2056  }
2057 
2058  if (!async_data->inet_buffers.dwBufferLength)
2059  break;
2060  memcpy(buf, async_data->inet_buffers.lpvBuffer,
2061  async_data->inet_buffers.dwBufferLength);
2062 
2063  bytes_left -= async_data->inet_buffers.dwBufferLength;
2064  buf += async_data->inet_buffers.dwBufferLength;
2065  }
2066 
2067  HeapFree(GetProcessHeap(), 0, async_data->inet_buffers.lpvBuffer);
2068  async_data->inet_buffers.lpvBuffer = NULL;
2069 
2070  TRACE("%p %p %u -> %u\n", req, buffer, count, status);
2071  return status == RPC_S_OK ? count : -1;
2072 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#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
smooth NULL
Definition: ftsmooth.c:416
static void prepare_async_request(RpcHttpAsyncData *async_data)
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#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:2267
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
LPVOID lpvBuffer
Definition: wininet.h:277
#define HeapFree(x, y, z)
Definition: compat.h:394
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: ps.c:97
static RPC_STATUS rpcrt4_http_check_response ( HINTERNET  hor)
static

Definition at line 1874 of file rpc_transport.c.

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

1875 {
1876  BOOL ret;
1878  DWORD size;
1879  DWORD index;
1880  WCHAR buf[32];
1881  WCHAR *status_text = buf;
1882  TRACE("\n");
1883 
1884  index = 0;
1885  size = sizeof(status_code);
1886  ret = HttpQueryInfoW(hor, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, &status_code, &size, &index);
1887  if (!ret)
1888  return GetLastError();
1889  if (status_code == HTTP_STATUS_OK)
1890  return RPC_S_OK;
1891  index = 0;
1892  size = sizeof(buf);
1893  ret = HttpQueryInfoW(hor, HTTP_QUERY_STATUS_TEXT, status_text, &size, &index);
1894  if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
1895  {
1896  status_text = HeapAlloc(GetProcessHeap(), 0, size);
1897  ret = HttpQueryInfoW(hor, HTTP_QUERY_STATUS_TEXT, status_text, &size, &index);
1898  }
1899 
1900  ERR("server returned: %d %s\n", status_code, ret ? debugstr_w(status_text) : "<status text unavailable>");
1901  if(status_text != buf) HeapFree(GetProcessHeap(), 0, status_text);
1902 
1903  if (status_code == HTTP_STATUS_DENIED)
1904  return ERROR_ACCESS_DENIED;
1905  return RPC_S_SERVER_UNAVAILABLE;
1906 }
#define HTTP_QUERY_STATUS_TEXT
Definition: wininet.h:1543
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1056
DWORD DWORD
Definition: winlogon.h:75
struct status_code status_code
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
#define debugstr_w
Definition: kernel32.h:32
#define HTTP_STATUS_DENIED
Definition: winhttp.h:256
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#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:3807
#define index(s, c)
Definition: various.h:29
#define HTTP_QUERY_STATUS_CODE
Definition: wininet.h:1542
#define ERR(fmt,...)
Definition: debug.h:109
#define HTTP_QUERY_FLAG_NUMBER
Definition: wininet.h:1606
#define HeapFree(x, y, z)
Definition: compat.h:394
#define RPC_S_OK
Definition: rpcnterr.h:22
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
static VOID WINAPI rpcrt4_http_internet_callback ( HINTERNET  hInternet,
DWORD_PTR  dwContext,
DWORD  dwInternetStatus,
LPVOID  lpvStatusInformation,
DWORD  dwStatusInformationLength 
)
static

Definition at line 1849 of file rpc_transport.c.

Referenced by rpcrt4_http_internet_connect().

1855 {
1856  RpcHttpAsyncData *async_data = (RpcHttpAsyncData *)dwContext;
1857 
1858  switch (dwInternetStatus)
1859  {
1861  TRACE("INTERNET_STATUS_REQUEST_COMPLETED\n");
1862  if (async_data)
1863  {
1864  INTERNET_ASYNC_RESULT *async_result = lpvStatusInformation;
1865 
1866  async_data->async_result = async_result->dwResult ? ERROR_SUCCESS : async_result->dwError;
1867  SetEvent(async_data->completion_event);
1868  RpcHttpAsyncData_Release(async_data);
1869  }
1870  break;
1871  }
1872 }
#define ERROR_SUCCESS
Definition: deptool.c:10
static ULONG RpcHttpAsyncData_Release(RpcHttpAsyncData *data)
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
#define TRACE(s)
Definition: solgame.cpp:4
DWORD_PTR dwResult
Definition: wininet.h:155
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
static RPC_STATUS rpcrt4_http_internet_connect ( RpcConnection_http httpc)
static

Definition at line 1908 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_http_open().

1909 {
1910  static const WCHAR wszUserAgent[] = {'M','S','R','P','C',0};
1911  LPWSTR proxy = NULL;
1912  LPWSTR user = NULL;
1913  LPWSTR password = NULL;
1914  LPWSTR servername = NULL;
1915  const WCHAR *option;
1917 
1918  if (httpc->common.QOS &&
1920  {
1921  const RPC_HTTP_TRANSPORT_CREDENTIALS_W *http_cred = httpc->common.QOS->qos->u.HttpCredentials;
1922  if (http_cred->TransportCredentials)
1923  {
1924  WCHAR *p;
1925  const SEC_WINNT_AUTH_IDENTITY_W *cred = http_cred->TransportCredentials;
1926  ULONG len = cred->DomainLength + 1 + cred->UserLength;
1927  user = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
1928  if (!user)
1929  return RPC_S_OUT_OF_RESOURCES;
1930  p = user;
1931  if (cred->DomainLength)
1932  {
1933  memcpy(p, cred->Domain, cred->DomainLength * sizeof(WCHAR));
1934  p += cred->DomainLength;
1935  *p = '\\';
1936  p++;
1937  }
1938  memcpy(p, cred->User, cred->UserLength * sizeof(WCHAR));
1939  p[cred->UserLength] = 0;
1940 
1941  password = RPCRT4_strndupW(cred->Password, cred->PasswordLength);
1942  }
1943  }
1944 
1945  for (option = httpc->common.NetworkOptions; option;
1946  option = (strchrW(option, ',') ? strchrW(option, ',')+1 : NULL))
1947  {
1948  static const WCHAR wszRpcProxy[] = {'R','p','c','P','r','o','x','y','=',0};
1949  static const WCHAR wszHttpProxy[] = {'H','t','t','p','P','r','o','x','y','=',0};
1950 
1951  if (!strncmpiW(option, wszRpcProxy, sizeof(wszRpcProxy)/sizeof(wszRpcProxy[0])-1))
1952  {
1953  const WCHAR *value_start = option + sizeof(wszRpcProxy)/sizeof(wszRpcProxy[0])-1;
1954  const WCHAR *value_end;
1955  const WCHAR *p;
1956 
1957  value_end = strchrW(option, ',');
1958  if (!value_end)
1959  value_end = value_start + strlenW(value_start);
1960  for (p = value_start; p < value_end; p++)
1961  if (*p == ':')
1962  {
1963  port = atoiW(p+1);
1964  value_end = p;
1965  break;
1966  }
1967  TRACE("RpcProxy value is %s\n", debugstr_wn(value_start, value_end-value_start));
1968  servername = RPCRT4_strndupW(value_start, value_end-value_start);
1969  }
1970  else if (!strncmpiW(option, wszHttpProxy, sizeof(wszHttpProxy)/sizeof(wszHttpProxy[0])-1))
1971  {
1972  const WCHAR *value_start = option + sizeof(wszHttpProxy)/sizeof(wszHttpProxy[0])-1;
1973  const WCHAR *value_end;
1974 
1975  value_end = strchrW(option, ',');
1976  if (!value_end)
1977  value_end = value_start + strlenW(value_start);
1978  TRACE("HttpProxy value is %s\n", debugstr_wn(value_start, value_end-value_start));
1979  proxy = RPCRT4_strndupW(value_start, value_end-value_start);
1980  }
1981  else
1982  FIXME("unhandled option %s\n", debugstr_w(option));
1983  }
1984 
1987  if (!httpc->app_info)
1988  {
1989  HeapFree(GetProcessHeap(), 0, password);
1990  HeapFree(GetProcessHeap(), 0, user);
1991  HeapFree(GetProcessHeap(), 0, proxy);
1992  HeapFree(GetProcessHeap(), 0, servername);
1993  ERR("InternetOpenW failed with error %d\n", GetLastError());
1994  return RPC_S_SERVER_UNAVAILABLE;
1995  }
1997 
1998  /* if no RpcProxy option specified, set the HTTP server address to the
1999  * RPC server address */
2000  if (!servername)
2001  {
2002  servername = HeapAlloc(GetProcessHeap(), 0, (strlen(httpc->common.NetworkAddr) + 1)*sizeof(WCHAR));
2003  if (!servername)
2004  {
2005  HeapFree(GetProcessHeap(), 0, password);
2006  HeapFree(GetProcessHeap(), 0, user);
2007  HeapFree(GetProcessHeap(), 0, proxy);
2008  return RPC_S_OUT_OF_RESOURCES;
2009  }
2010  MultiByteToWideChar(CP_ACP, 0, httpc->common.NetworkAddr, -1, servername, strlen(httpc->common.NetworkAddr) + 1);
2011  }
2012 
2013  port = (httpc->common.QOS &&
2017 
2018  httpc->session = InternetConnectW(httpc->app_info, servername, port, user, password,
2019  INTERNET_SERVICE_HTTP, 0, 0);
2020 
2021  HeapFree(GetProcessHeap(), 0, password);
2022  HeapFree(GetProcessHeap(), 0, user);
2023  HeapFree(GetProcessHeap(), 0, proxy);
2024 
2025  if (!httpc->session)
2026  {
2027  ERR("InternetConnectW failed with error %d\n", GetLastError());
2028  HeapFree(GetProcessHeap(), 0, servername);
2029  return RPC_S_SERVER_UNAVAILABLE;
2030  }
2031  httpc->servername = servername;
2032  return RPC_S_OK;
2033 }
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
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned short * Password
Definition: rpcdce.h:227
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
#define CP_ACP
Definition: compat.h:99
RpcConnection common
#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:1056
RPC_HTTP_TRANSPORT_CREDENTIALS_W * HttpCredentials
Definition: rpcdce.h:279
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
union _RPC_SECURITY_QOS_V2_W::@3061 u
#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:110
smooth NULL
Definition: ftsmooth.c:416
GLuint GLenum option
Definition: glext.h:11211
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackW(HINTERNET hInternet, INTERNET_STATUS_CALLBACK lpfnIntCB)
Definition: internet.c:2095
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
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
#define ERR(fmt,...)
Definition: debug.h:109
#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 RPC_S_OUT_OF_RESOURCES
Definition: winerror.h:1032
#define MultiByteToWideChar
Definition: compat.h:100
#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
HINTERNET WINAPI InternetConnectW(HINTERNET hInternet, LPCWSTR lpszServerName, INTERNET_PORT nServerPort, LPCWSTR lpszUserName, LPCWSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:1278
LPWSTR RPCRT4_strndupW(LPCWSTR src, INT slen)
Definition: rpc_binding.c:92
HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType, LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags)
Definition: internet.c:999
USHORT port
Definition: uri.c:227
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#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:394
#define RPC_S_OK
Definition: rpcnterr.h:22
WINE_UNICODE_INLINE int atoiW(const WCHAR *str)
Definition: unicode.h:315
static VOID rpcrt4_http_keep_connection_active_timer_proc ( PVOID  param,
BOOLEAN  dummy 
)
static

Definition at line 1804 of file rpc_transport.c.

Referenced by rpcrt4_http_timer_thread().

1805 {
1806  HINTERNET in_request = param;
1807  RpcPktHdr *idle_pkt;
1808 
1810  0, 0);
1811  if (idle_pkt)
1812  {
1813  DWORD bytes_written;
1814  InternetWriteFile(in_request, idle_pkt, idle_pkt->common.frag_len, &bytes_written);
1815  RPCRT4_FreeHeader(idle_pkt);
1816  }
1817 }
VOID RPCRT4_FreeHeader(RpcPktHdr *Header)
Definition: rpc_message.c:402
DWORD DWORD
Definition: winlogon.h:75
RpcPktCommonHdr common
Definition: rpc_defs.h:152
BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer, DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
Definition: internet.c:2132
unsigned short frag_len
Definition: rpc_defs.h:33
GLfloat param
Definition: glext.h:5796
#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:290
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 2108 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_http_open().

2111 {
2112  BOOL ret;
2114  RpcPktHdr *hdr;
2115  INTERNET_BUFFERSW buffers_in;
2116  DWORD bytes_written;
2117 
2118  if (!authorized)
2119  {
2120  /* ask wininet to authorize, if necessary */
2121  status = send_echo_request(in_request, async_data, cancel_event);
2122  if (status != RPC_S_OK) return status;
2123  }
2124  memset(&buffers_in, 0, sizeof(buffers_in));
2125  buffers_in.dwStructSize = sizeof(buffers_in);
2126  /* FIXME: get this from the registry */
2127  buffers_in.dwBufferTotal = 1024 * 1024 * 1024; /* 1Gb */
2128  status = insert_content_length_header(in_request, buffers_in.dwBufferTotal);
2129  if (status != RPC_S_OK) return status;
2130 
2131  prepare_async_request(async_data);
2132  ret = HttpSendRequestExW(in_request, &buffers_in, NULL, 0, 0);
2133  status = wait_async_request(async_data, ret, cancel_event);
2134  if (status != RPC_S_OK) return status;
2135 
2136  TRACE("sending HTTP connect header to server\n");
2137  hdr = RPCRT4_BuildHttpConnectHeader(FALSE, connection_uuid, in_pipe_uuid, association_uuid);
2138  if (!hdr) return RPC_S_OUT_OF_RESOURCES;
2139  ret = InternetWriteFile(in_request, hdr, hdr->common.frag_len, &bytes_written);
2140  RPCRT4_FreeHeader(hdr);
2141  if (!ret)
2142  {
2143  ERR("InternetWriteFile failed with error %d\n", GetLastError());
2144  return RPC_S_SERVER_UNAVAILABLE;
2145  }
2146 
2147  return RPC_S_OK;
2148 }
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:402
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1056
static RPC_STATUS wait_async_request(RpcHttpAsyncData *async_data, BOOL call_ret, HANDLE cancel_event)
DWORD DWORD
Definition: winlogon.h:75
long RPC_STATUS
Definition: rpc.h:52
RpcPktCommonHdr common
Definition: rpc_defs.h:152
#define FALSE
Definition: types.h:117
RpcPktHdr * RPCRT4_BuildHttpConnectHeader(int out_pipe, const UUID *connection_uuid, const UUID *pipe_uuid, const UUID *association_uuid)
Definition: rpc_message.c:343
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:5466
BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer, DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
Definition: internet.c:2132
unsigned short frag_len
Definition: rpc_defs.h:33
static void prepare_async_request(RpcHttpAsyncData *async_data)
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
int ret
#define ERR(fmt,...)
Definition: debug.h:109
#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)
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 2195 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_http_open().

2199 {
2200  BOOL ret;
2202  RpcPktHdr *hdr;
2203  BYTE *data_from_server;
2204  RpcPktHdr pkt_from_server;
2205  ULONG field1, field3;
2206  BYTE buf[20];
2207 
2208  if (!authorized)
2209  {
2210  /* ask wininet to authorize, if necessary */
2211  status = send_echo_request(out_request, async_data, cancel_event);
2212  if (status != RPC_S_OK) return status;
2213  }
2214  else
2215  rpcrt4_http_async_read(out_request, async_data, cancel_event, buf, sizeof(buf));
2216 
2217  hdr = RPCRT4_BuildHttpConnectHeader(TRUE, connection_uuid, out_pipe_uuid, NULL);
2218  if (!hdr) return RPC_S_OUT_OF_RESOURCES;
2219 
2220  status = insert_content_length_header(out_request, hdr->common.frag_len);
2221  if (status != RPC_S_OK)
2222  {
2223  RPCRT4_FreeHeader(hdr);
2224  return status;
2225  }
2226 
2227  TRACE("sending HTTP connect header to server\n");
2228  prepare_async_request(async_data);
2229  ret = HttpSendRequestW(out_request, NULL, 0, hdr, hdr->common.frag_len);
2230  status = wait_async_request(async_data, ret, cancel_event);
2231  RPCRT4_FreeHeader(hdr);
2232  if (status != RPC_S_OK) return status;
2233 
2234  status = rpcrt4_http_check_response(out_request);
2235  if (status != RPC_S_OK) return status;
2236 
2237  status = rpcrt4_http_read_http_packet(out_request, async_data, cancel_event,
2238  &pkt_from_server, &data_from_server);
2239  if (status != RPC_S_OK) return status;
2240  status = RPCRT4_ParseHttpPrepareHeader1(&pkt_from_server, data_from_server,
2241  &field1);
2242  HeapFree(GetProcessHeap(), 0, data_from_server);
2243  if (status != RPC_S_OK) return status;
2244  TRACE("received (%d) from first prepare header\n", field1);
2245 
2246  for (;;)
2247  {
2248  status = rpcrt4_http_read_http_packet(out_request, async_data, cancel_event,
2249  &pkt_from_server, &data_from_server);
2250  if (status != RPC_S_OK) return status;
2251  if (pkt_from_server.http.flags != 0x0001) break;
2252 
2253  TRACE("http idle packet, waiting for real packet\n");
2254  HeapFree(GetProcessHeap(), 0, data_from_server);
2255  if (pkt_from_server.http.num_data_items != 0)
2256  {
2257  ERR("HTTP idle packet should have no data items instead of %d\n",
2258  pkt_from_server.http.num_data_items);
2259  return RPC_S_PROTOCOL_ERROR;
2260  }
2261  }
2262  status = RPCRT4_ParseHttpPrepareHeader2(&pkt_from_server, data_from_server,
2263  &field1, flow_control_increment,
2264  &field3);
2265  HeapFree(GetProcessHeap(), 0, data_from_server);
2266  if (status != RPC_S_OK) return status;
2267  TRACE("received (0x%08x 0x%08x %d) from second prepare header\n", field1, *flow_control_increment, field3);
2268 
2269  return RPC_S_OK;
2270 }
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)
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
RPC_STATUS RPCRT4_ParseHttpPrepareHeader1(RpcPktHdr *header, unsigned char *data, ULONG *field1)
Definition: rpc_message.c:565
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
VOID RPCRT4_FreeHeader(RpcPktHdr *Header)
Definition: rpc_message.c:402
static RPC_STATUS wait_async_request(RpcHttpAsyncData *async_data, BOOL call_ret, HANDLE cancel_event)
long RPC_STATUS
Definition: rpc.h:52
RpcPktCommonHdr common
Definition: rpc_defs.h:152
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:343
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:5561
unsigned short frag_len
Definition: rpc_defs.h:33
#define RPC_S_PROTOCOL_ERROR
Definition: winerror.h:1039
static void prepare_async_request(RpcHttpAsyncData *async_data)
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
int ret
RPC_STATUS RPCRT4_ParseHttpPrepareHeader2(RpcPktHdr *header, unsigned char *data, ULONG *field1, ULONG *bytes_until_next_packet, ULONG *field3)
Definition: rpc_message.c:590
unsigned char BYTE
Definition: ntddk_ex.h:96
RpcPktHttpHdr http
Definition: rpc_defs.h:159
#define ERR(fmt,...)
Definition: debug.h:109
#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:394
#define RPC_S_OK
Definition: rpcnterr.h:22
static RPC_STATUS insert_content_length_header(HINTERNET request, DWORD len)
static RPC_STATUS rpcrt4_http_read_http_packet ( HINTERNET  request,
RpcHttpAsyncData async_data,
HANDLE  cancel_event,
RpcPktHdr hdr,
BYTE **  data 
)
static

Definition at line 2150 of file rpc_transport.c.

Referenced by rpcrt4_http_prepare_out_pipe().

2152 {
2153  unsigned short data_len;
2154  unsigned int size;
2155 
2156  if (rpcrt4_http_async_read(request, async_data, cancel_event, hdr, sizeof(hdr->common)) < 0)
2157  return RPC_S_SERVER_UNAVAILABLE;
2158  if (hdr->common.ptype != PKT_HTTP || hdr->common.frag_len < sizeof(hdr->http))
2159  {
2160  ERR("wrong packet type received %d or wrong frag_len %d\n",
2161  hdr->common.ptype, hdr->common.frag_len);
2162  return RPC_S_PROTOCOL_ERROR;
2163  }
2164 
2165  size = sizeof(hdr->http) - sizeof(hdr->common);
2166  if (rpcrt4_http_async_read(request, async_data, cancel_event, &hdr->common + 1, size) < 0)
2167  return RPC_S_SERVER_UNAVAILABLE;
2168 
2169  data_len = hdr->common.frag_len - sizeof(hdr->http);
2170  if (data_len)
2171  {
2172  *data = HeapAlloc(GetProcessHeap(), 0, data_len);
2173  if (!*data)
2174  return RPC_S_OUT_OF_RESOURCES;
2175  if (rpcrt4_http_async_read(request, async_data, cancel_event, *data, data_len) < 0)
2176  {
2177  HeapFree(GetProcessHeap(), 0, *data);
2178  return RPC_S_SERVER_UNAVAILABLE;
2179  }
2180  }
2181  else
2182  *data = NULL;
2183 
2184  if (!RPCRT4_IsValidHttpPacket(hdr, *data, data_len))
2185  {
2186  ERR("invalid http packet\n");
2187  HeapFree(GetProcessHeap(), 0, *data);
2188  return RPC_S_PROTOCOL_ERROR;
2189  }
2190 
2191  return RPC_S_OK;
2192 }
static int rpcrt4_http_async_read(HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event, void *buffer, unsigned int count)
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
RpcPktCommonHdr common
Definition: rpc_defs.h:152
smooth NULL
Definition: ftsmooth.c:416
unsigned short frag_len
Definition: rpc_defs.h:33
#define RPC_S_PROTOCOL_ERROR
Definition: winerror.h:1039
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
unsigned char ptype
Definition: rpc_defs.h:30
RpcPktHttpHdr http
Definition: rpc_defs.h:159
#define ERR(fmt,...)
Definition: debug.h:109
#define RPC_S_OUT_OF_RESOURCES
Definition: winerror.h:1032
BOOL RPCRT4_IsValidHttpPacket(RpcPktHdr *hdr, unsigned char *data, unsigned short data_len)
Definition: rpc_message.c:482
#define HeapFree(x, y, z)
Definition: compat.h:394
#define RPC_S_OK
Definition: rpcnterr.h:22
static DWORD rpcrt4_http_timer_calc_timeout ( DWORD last_sent_time)
inlinestatic

Definition at line 1819 of file rpc_transport.c.

Referenced by rpcrt4_http_timer_thread().

1820 {
1822  DWORD cached_last_sent_time = *last_sent_time;
1823  return HTTP_IDLE_TIME - (cur_time - cached_last_sent_time > HTTP_IDLE_TIME ? 0 : cur_time - cached_last_sent_time);
1824 }
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
time_t cur_time
#define HTTP_IDLE_TIME
DWORD DWORD
Definition: winlogon.h:75
static DWORD CALLBACK rpcrt4_http_timer_thread ( PVOID  param)
static

Definition at line 1826 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_http_open().

1827 {
1828  HttpTimerThreadData *data_in = param;
1830  DWORD timeout;
1831 
1832  data = *data_in;
1833  HeapFree(GetProcessHeap(), 0, data_in);
1834 
1835  for (timeout = HTTP_IDLE_TIME;
1838  {
1839  /* are we too soon after last send? */
1840  if (GetTickCount() - *data.last_sent_time < HTTP_IDLE_TIME)
1841  continue;
1843  }
1844 
1846  return 0;
1847 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
#define HTTP_IDLE_TIME
GLbitfield GLuint64 timeout
Definition: glext.h:7164
DWORD DWORD
Definition: winlogon.h:75
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define GetProcessHeap()
Definition: compat.h:395
GLfloat param
Definition: glext.h:5796
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:394
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 931 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_http_get_top_of_tower(), and rpcrt4_ncacn_ip_tcp_get_top_of_tower().

935 {
936  twr_tcp_floor_t *tcp_floor;
937  twr_ipv4_floor_t *ipv4_floor;
938  struct addrinfo *ai;
939  struct addrinfo hints;
940  int ret;
941  size_t size = sizeof(*tcp_floor) + sizeof(*ipv4_floor);
942 
943  TRACE("(%p, %s, %s)\n", tower_data, networkaddr, endpoint);
944 
945  if (!tower_data)
946  return size;
947 
948  tcp_floor = (twr_tcp_floor_t *)tower_data;
949  tower_data += sizeof(*tcp_floor);
950 
951  ipv4_floor = (twr_ipv4_floor_t *)tower_data;
952 
953  tcp_floor->count_lhs = sizeof(tcp_floor->protid);
954  tcp_floor->protid = tcp_protid;
955  tcp_floor->count_rhs = sizeof(tcp_floor->port);
956 
957  ipv4_floor->count_lhs = sizeof(ipv4_floor->protid);
958  ipv4_floor->protid = EPM_PROTOCOL_IP;
959  ipv4_floor->count_rhs = sizeof(ipv4_floor->ipv4addr);
960 
961  hints.ai_flags = AI_NUMERICHOST;
962  /* FIXME: only support IPv4 at the moment. how is IPv6 represented by the EPM? */
963  hints.ai_family = PF_INET;
964  hints.ai_socktype = SOCK_STREAM;
965  hints.ai_protocol = IPPROTO_TCP;
966  hints.ai_addrlen = 0;
967  hints.ai_addr = NULL;
968  hints.ai_canonname = NULL;
969  hints.ai_next = NULL;
970 
971  ret = getaddrinfo(networkaddr, endpoint, &hints, &ai);
972  if (ret)
973  {
974  ret = getaddrinfo("0.0.0.0", endpoint, &hints, &ai);
975  if (ret)
976  {
977  ERR("getaddrinfo failed: %s\n", gai_strerror(ret));
978  return 0;
979  }
980  }
981 
982  if (ai->ai_family == PF_INET)
983  {
984  const struct sockaddr_in *sin = (const struct sockaddr_in *)ai->ai_addr;
985  tcp_floor->port = sin->sin_port;
986  ipv4_floor->ipv4addr = sin->sin_addr.s_addr;
987  }
988  else
989  {
990  ERR("unexpected protocol family %d\n", ai->ai_family);
991  freeaddrinfo(ai);
992  return 0;
993  }
994 
995  freeaddrinfo(ai);
996 
997  return size;
998 }
namespace GUID const ADDRINFOEXW * hints
Definition: sock.c:80
u_short sin_port
Definition: winsock.h:511
#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
struct in_addr sin_addr
Definition: winsock.h:512
#define ERR(fmt,...)
Definition: debug.h:109
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
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 1000 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_http_parse_top_of_tower(), and rpcrt4_ncacn_ip_tcp_parse_top_of_tower().

1005 {
1006  const twr_tcp_floor_t *tcp_floor = (const twr_tcp_floor_t *)tower_data;
1007  const twr_ipv4_floor_t *ipv4_floor;
1008  struct in_addr in_addr;
1009 
1010  TRACE("(%p, %d, %p, %p)\n", tower_data, (int)tower_size, networkaddr, endpoint);
1011 
1012  if (tower_size < sizeof(*tcp_floor))
1013  return EPT_S_NOT_REGISTERED;
1014 
1015  tower_data += sizeof(*tcp_floor);
1016  tower_size -= sizeof(*tcp_floor);
1017 
1018  if (tower_size < sizeof(*ipv4_floor))
1019  return EPT_S_NOT_REGISTERED;
1020 
1021  ipv4_floor = (const twr_ipv4_floor_t *)tower_data;
1022 
1023  if ((tcp_floor->count_lhs != sizeof(tcp_floor->protid)) ||
1024  (tcp_floor->protid != tcp_protid) ||
1025  (tcp_floor->count_rhs != sizeof(tcp_floor->port)) ||
1026  (ipv4_floor->count_lhs != sizeof(ipv4_floor->protid)) ||
1027  (ipv4_floor->protid != EPM_PROTOCOL_IP) ||
1028  (ipv4_floor->count_rhs != sizeof(ipv4_floor->ipv4addr)))
1029  return EPT_S_NOT_REGISTERED;
1030 
1031  if (endpoint)
1032  {
1033  *endpoint = I_RpcAllocate(6 /* sizeof("65535") + 1 */);
1034  if (!*endpoint)
1035  return RPC_S_OUT_OF_RESOURCES;
1036  sprintf(*endpoint, "%u", ntohs(tcp_floor->port));
1037  }
1038 
1039  if (networkaddr)
1040  {
1041  *networkaddr = I_RpcAllocate(INET_ADDRSTRLEN);
1042  if (!*networkaddr)
1043  {
1044  if (endpoint)
1045  {
1046  I_RpcFree(*endpoint);
1047  *endpoint = NULL;
1048  }
1049  return RPC_S_OUT_OF_RESOURCES;
1050  }
1051  in_addr.s_addr = ipv4_floor->ipv4addr;
1052  if (!inet_ntop(AF_INET, &in_addr, *networkaddr, INET_ADDRSTRLEN))
1053  {
1054  ERR("inet_ntop: %u\n", WSAGetLastError());
1055  I_RpcFree(*networkaddr);
1056  *networkaddr = NULL;
1057  if (endpoint)
1058  {
1059  I_RpcFree(*endpoint);
1060  *endpoint = NULL;
1061  }
1062  return EPT_S_NOT_REGISTERED;
1063  }
1064  }
1065 
1066  return RPC_S_OK;
1067 }
void WINAPI I_RpcFree(void *Object)
Definition: rpcrt4_main.c:725
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:109
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:717
#define RPC_S_OK
Definition: rpcnterr.h:22
RPC_STATUS RPCRT4_IsServerListening ( const char protseq,
const char endpoint 
)

Definition at line 3458 of file rpc_transport.c.

Referenced by RpcMgmtIsServerListening().

3459 {
3460  const struct connection_ops *ops;
3461 
3462  ops = rpcrt4_get_conn_protseq_ops(protseq);
3463  if (!ops)
3464  {
3465  FIXME("not supported for protseq %s\n", protseq);
3466  return RPC_S_INVALID_BINDING;
3467  }
3468 
3469  return ops->is_server_listening(endpoint);
3470 }
RPC_STATUS(* is_server_listening)(const char *endpoint)
Definition: rpc_binding.h:110
static const struct connection_ops * rpcrt4_get_conn_protseq_ops(const char *protseq)
#define FIXME(fmt,...)
Definition: debug.h:110
#define RPC_S_INVALID_BINDING
Definition: winerror.h:1013
Definition: nis.h:10
static RpcConnection* rpcrt4_ncacn_http_alloc ( void  )
static

Definition at line 1777 of file rpc_transport.c.

1778 {
1779  RpcConnection_http *httpc;
1780  httpc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*httpc));
1781  if (!httpc) return NULL;
1783  if (!httpc->async_data)
1784  {
1785  HeapFree(GetProcessHeap(), 0, httpc);
1786  return NULL;
1787  }
1788  TRACE("async data = %p\n", httpc->async_data);
1790  httpc->async_data->refs = 1;
1793  httpc->async_data->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": RpcHttpAsyncData.cs");
1794  return &httpc->common;
1795 }
DWORD dwStructSize
Definition: wininet.h:272
RpcConnection common
INTERNET_BUFFERSW inet_buffers
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:597
#define FALSE
Definition: types.h:117
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:697
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
PCRITICAL_SECTION_DEBUG DebugInfo
Definition: winbase.h:859
struct _INTERNET_BUFFERSW INTERNET_BUFFERSW
#define DWORD_PTR
Definition: generated.c:24
RpcHttpAsyncData * async_data
CRITICAL_SECTION cs
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define HeapFree(x, y, z)
Definition: compat.h:394
DWORD_PTR Spare[8/sizeof(DWORD_PTR)]
Definition: winbase.h:852
static void rpcrt4_ncacn_http_cancel_call ( RpcConnection Connection)
static

Definition at line 3122 of file rpc_transport.c.

3123 {
3124  RpcConnection_http *httpc = (RpcConnection_http *) Connection;
3125 
3126  SetEvent(httpc->cancel_event);
3127 }
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
static int rpcrt4_ncacn_http_close ( RpcConnection Connection)
static

Definition at line 3089 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_http_close_read().

3090 {
3091  RpcConnection_http *httpc = (RpcConnection_http *) Connection;
3092 
3093  TRACE("\n");
3094 
3095  SetEvent(httpc->timer_cancelled);
3096  if (httpc->in_request)
3098  httpc->in_request = NULL;
3099  if (httpc->out_request)
3101  httpc->out_request = NULL;
3102  if (httpc->app_info)
3103  InternetCloseHandle(httpc->app_info);
3104  httpc->app_info = NULL;
3105  if (httpc->session)
3106  InternetCloseHandle(httpc->session);
3107  httpc->session = NULL;
3109  if (httpc->cancel_event)
3110  CloseHandle(httpc->cancel_event);
3111  HeapFree(GetProcessHeap(), 0, httpc->servername);
3112  httpc->servername = NULL;
3113 
3114  return 0;
3115 }
#define CloseHandle
Definition: compat.h:398
static ULONG RpcHttpAsyncData_Release(RpcHttpAsyncData *data)
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
Definition: internet.c:1434
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
RpcHttpAsyncData * async_data
#define HeapFree(x, y, z)
Definition: compat.h:394
static void rpcrt4_ncacn_http_close_read ( RpcConnection conn)
static

Definition at line 3117 of file rpc_transport.c.

3118 {
3119  rpcrt4_ncacn_http_close(conn); /* FIXME */
3120 }
static int rpcrt4_ncacn_http_close(RpcConnection *Connection)
static size_t rpcrt4_ncacn_http_get_top_of_tower ( unsigned char tower_data,
const char networkaddr,
const char endpoint 
)
static

Definition at line 3148 of file rpc_transport.c.

3151 {
3152  return rpcrt4_ip_tcp_get_top_of_tower(tower_data, networkaddr,
3154 }
static size_t rpcrt4_ip_tcp_get_top_of_tower(unsigned char *tower_data, const char *networkaddr, unsigned char tcp_protid, const char *endpoint)
#define EPM_PROTOCOL_HTTP
Definition: epm_towers.h:49
Definition: nis.h:10
static RPC_STATUS rpcrt4_ncacn_http_handoff ( RpcConnection old_conn,
RpcConnection new_conn 
)
static

Definition at line 2906 of file rpc_transport.c.

2907 {
2908  assert(0);
2909  return RPC_S_SERVER_UNAVAILABLE;
2910 }
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
#define assert(x)
Definition: debug.h:53
static RPC_STATUS rpcrt4_ncacn_http_is_server_listening ( const char endpoint)
static

Definition at line 3129 of file rpc_transport.c.

3130 {
3131  FIXME("\n");
3132  return RPC_S_ACCESS_DENIED;
3133 }
#define RPC_S_ACCESS_DENIED
Definition: rpcnterr.h:29
#define FIXME(fmt,...)
Definition: debug.h:110
static RPC_STATUS rpcrt4_ncacn_http_open ( RpcConnection Connection)
static

Definition at line 2771 of file rpc_transport.c.

2772 {
2773  RpcConnection_http *httpc = (RpcConnection_http *)Connection;
2774  static const WCHAR wszVerbIn[] = {'R','P','C','_','I','N','_','D','A','T','A',0};
2775  static const WCHAR wszVerbOut[] = {'R','P','C','_','O','U','T','_','D','A','T','A',0};
2776  static const WCHAR wszRpcProxyPrefix[] = {'/','r','p','c','/','r','p','c','p','r','o','x','y','.','d','l','l','?',0};
2777  static const WCHAR wszColon[] = {':',0};
2778  static const WCHAR wszAcceptType[] = {'a','p','p','l','i','c','a','t','i','o','n','/','r','p','c',0};
2779  LPCWSTR wszAcceptTypes[] = { wszAcceptType, NULL };
2780  DWORD flags;
2781  WCHAR *url;
2783  BOOL secure, credentials;
2784  HttpTimerThreadData *timer_data;
2785  HANDLE thread;
2786 
2787  TRACE("(%s, %s)\n", Connection->NetworkAddr, Connection->Endpoint);
2788 
2789  if (Connection->server)
2790  {
2791  ERR("ncacn_http servers not supported yet\n");
2792  return RPC_S_SERVER_UNAVAILABLE;
2793  }
2794 
2795  if (httpc->in_request)
2796  return RPC_S_OK;
2797 
2799 
2800  UuidCreate(&httpc->connection_uuid);
2801  UuidCreate(&httpc->in_pipe_uuid);
2802  UuidCreate(&httpc->out_pipe_uuid);
2803 
2804  status = rpcrt4_http_internet_connect(httpc);
2805  if (status != RPC_S_OK)
2806  return status;
2807 
2808  url = HeapAlloc(GetProcessHeap(), 0, sizeof(wszRpcProxyPrefix) + (strlen(Connection->NetworkAddr) + 1 + strlen(Connection->Endpoint))*sizeof(WCHAR));
2809  if (!url)
2810  return RPC_S_OUT_OF_MEMORY;
2811  memcpy(url, wszRpcProxyPrefix, sizeof(wszRpcProxyPrefix));
2812  MultiByteToWideChar(CP_ACP, 0, Connection->NetworkAddr, -1, url+sizeof(wszRpcProxyPrefix)/sizeof(wszRpcProxyPrefix[0])-1, strlen(Connection->NetworkAddr)+1);
2813  strcatW(url, wszColon);
2814  MultiByteToWideChar(CP_ACP, 0, Connection->Endpoint, -1