ReactOS  0.4.11-dev-201-g2a6aa77
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 *server, 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 1684 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 2394 of file rpc_transport.c.

Referenced by do_authorization().

2395 {
2396  struct authinfo *ret;
2397 
2398  if (!(ret = HeapAlloc(GetProcessHeap(), 0, sizeof(*ret) ))) return NULL;
2399 
2400  SecInvalidateHandle(&ret->cred);
2401  SecInvalidateHandle(&ret->ctx);
2402  memset(&ret->exp, 0, sizeof(ret->exp));
2403  ret->scheme = 0;
2404  ret->attr = 0;
2405  ret->max_token = 0;
2406  ret->data = NULL;
2407  ret->data_len = 0;
2408  ret->finished = FALSE;
2409  return ret;
2410 }
#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 2447 of file rpc_transport.c.

Referenced by do_authorization(), and get_authvalue().

2448 {
2449  unsigned int i;
2450  for (i = 0; i < num_auth_schemes; i++)
2451  {
2452  if (!strncmpiW( header, auth_schemes[i].str, auth_schemes[i].len ) &&
2453  (header[auth_schemes[i].len] == ' ' || !header[auth_schemes[i].len])) return auth_schemes[i].scheme;
2454  }
2455  return 0;
2456 }
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 2679 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_http_open().

2680 {
2681  static const WCHAR authW[] = {'A','u','t','h','o','r','i','z','a','t','i','o','n',':','\r','\n',0};
2682  struct authinfo *info = NULL;
2684  BOOL ret;
2685 
2686  for (;;)
2687  {
2688  status = do_authorization(request, httpc->servername, httpc->common.QOS->qos->u.HttpCredentials, &info);
2689  if (status != RPC_S_OK) break;
2690 
2691  status = insert_authorization_header(request, info->scheme, info->data, info->data_len);
2692  if (status != RPC_S_OK) break;
2693 
2695  ret = HttpSendRequestW(request, NULL, 0, NULL, 0);
2696  status = wait_async_request(httpc->async_data, ret, httpc->cancel_event);
2697  if (status != RPC_S_OK || info->finished) break;
2698 
2699  status = rpcrt4_http_check_response(request);
2700  if (status != RPC_S_OK && status != ERROR_ACCESS_DENIED) break;
2701  drain_content(request, httpc->async_data, httpc->cancel_event);
2702  }
2703 
2706 
2707  destroy_authinfo(info);
2708  return status;
2709 }
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
#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
union _RPC_SECURITY_QOS_V2_W::@3075 u
BOOL WINAPI HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders, DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength)
Definition: http.c:5565
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 2332 of file rpc_transport.c.

Referenced by do_authorization().

2333 {
2334  unsigned int i = 0;
2335  char c0, c1, c2, c3;
2336  const WCHAR *p = base64;
2337 
2338  while (len > 4)
2339  {
2340  if ((c0 = decode_char( p[0] )) > 63) return 0;
2341  if ((c1 = decode_char( p[1] )) > 63) return 0;
2342  if ((c2 = decode_char( p[2] )) > 63) return 0;
2343  if ((c3 = decode_char( p[3] )) > 63) return 0;
2344 
2345  if (buf)
2346  {
2347  buf[i + 0] = (c0 << 2) | (c1 >> 4);
2348  buf[i + 1] = (c1 << 4) | (c2 >> 2);
2349  buf[i + 2] = (c2 << 6) | c3;
2350  }
2351  len -= 4;
2352  i += 3;
2353  p += 4;
2354  }
2355  if (p[2] == '=')
2356  {
2357  if ((c0 = decode_char( p[0] )) > 63) return 0;
2358  if ((c1 = decode_char( p[1] )) > 63) return 0;
2359 
2360  if (buf) buf[i] = (c0 << 2) | (c1 >> 4);
2361  i++;
2362  }
2363  else if (p[3] == '=')
2364  {
2365  if ((c0 = decode_char( p[0] )) > 63) return 0;
2366  if ((c1 = decode_char( p[1] )) > 63) return 0;
2367  if ((c2 = decode_char( p[2] )) > 63) return 0;
2368 
2369  if (buf)
2370  {
2371  buf[i + 0] = (c0 << 2) | (c1 >> 4);
2372  buf[i + 1] = (c1 << 4) | (c2 >> 2);
2373  }
2374  i += 2;
2375  }
2376  else
2377  {
2378  if ((c0 = decode_char( p[0] )) > 63) return 0;
2379  if ((c1 = decode_char( p[1] )) > 63) return 0;
2380  if ((c2 = decode_char( p[2] )) > 63) return 0;
2381  if ((c3 = decode_char( p[3] )) > 63) return 0;
2382 
2383  if (buf)
2384  {
2385  buf[i + 0] = (c0 << 2) | (c1 >> 4);
2386  buf[i + 1] = (c1 << 4) | (c2 >> 2);
2387  buf[i + 2] = (c2 << 6) | c3;
2388  }
2389  i += 3;
2390  }
2391  return i;
2392 }
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 2322 of file rpc_transport.c.

Referenced by decode_base64().

2323 {
2324  if (c >= 'A' && c <= 'Z') return c - 'A';
2325  if (c >= 'a' && c <= 'z') return c - 'a' + 26;
2326  if (c >= '0' && c <= '9') return c - '0' + 52;
2327  if (c == '+') return 62;
2328  if (c == '/') return 63;
2329  return 64;
2330 }
const GLubyte * c
Definition: glext.h:8905
static void destroy_authinfo ( struct authinfo info)
static

Definition at line 2412 of file rpc_transport.c.

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

2413 {
2414  if (!info) return;
2415 
2416  if (SecIsValidHandle(&info->ctx))
2417  DeleteSecurityContext(&info->ctx);
2418  if (SecIsValidHandle(&info->cred))
2419  FreeCredentialsHandle(&info->cred);
2420 
2421  HeapFree(GetProcessHeap(), 0, info->data);
2422  HeapFree(GetProcessHeap(), 0, info);
2423 }
#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 2470 of file rpc_transport.c.

Referenced by authorize_request().

2472 {
2473  struct authinfo *info = *auth_ptr;
2476 
2477  if ((!info && !(info = alloc_authinfo()))) return RPC_S_SERVER_UNAVAILABLE;
2478 
2479  switch (creds->AuthnSchemes[0])
2480  {
2482  {
2483  int userlen = WideCharToMultiByte(CP_UTF8, 0, id->User, id->UserLength, NULL, 0, NULL, NULL);
2484  int passlen = WideCharToMultiByte(CP_UTF8, 0, id->Password, id->PasswordLength, NULL, 0, NULL, NULL);
2485 
2486  info->data_len = userlen + passlen + 1;
2487  if (!(info->data = HeapAlloc(GetProcessHeap(), 0, info->data_len)))
2488  {
2489  status = RPC_S_OUT_OF_MEMORY;
2490  break;
2491  }
2492  WideCharToMultiByte(CP_UTF8, 0, id->User, id->UserLength, info->data, userlen, NULL, NULL);
2493  info->data[userlen] = ':';
2494  WideCharToMultiByte(CP_UTF8, 0, id->Password, id->PasswordLength, info->data + userlen + 1, passlen, NULL, NULL);
2495 
2497  info->finished = TRUE;
2498  status = RPC_S_OK;
2499  break;
2500  }
2503  {
2504 
2505  static SEC_WCHAR ntlmW[] = {'N','T','L','M',0}, negotiateW[] = {'N','e','g','o','t','i','a','t','e',0};
2507  SecBufferDesc out_desc, in_desc;
2508  SecBuffer out, in;
2510  SEC_WCHAR *scheme;
2511  int scheme_len;
2512  const WCHAR *p;
2513  WCHAR auth_value[2048];
2514  DWORD size = sizeof(auth_value);
2515  BOOL first = FALSE;
2516 
2517  if (creds->AuthnSchemes[0] == RPC_C_HTTP_AUTHN_SCHEME_NTLM) scheme = ntlmW;
2518  else scheme = negotiateW;
2519  scheme_len = strlenW( scheme );
2520 
2521  if (!*auth_ptr)
2522  {
2523  TimeStamp exp;
2524  SecPkgInfoW *pkg_info;
2525 
2526  ret = AcquireCredentialsHandleW(NULL, scheme, SECPKG_CRED_OUTBOUND, NULL, id, NULL, NULL, &info->cred, &exp);
2527  if (ret != SEC_E_OK) break;
2528 
2529  ret = QuerySecurityPackageInfoW(scheme, &pkg_info);
2530  if (ret != SEC_E_OK) break;
2531 
2532  info->max_token = pkg_info->cbMaxToken;
2533  FreeContextBuffer(pkg_info);
2534  first = TRUE;
2535  }
2536  else
2537  {
2538  if (info->finished || !get_authvalue(request, creds->AuthnSchemes[0], auth_value, size)) break;
2539  if (auth_scheme_from_header(auth_value) != info->scheme)
2540  {
2541  ERR("authentication scheme changed\n");
2542  break;
2543  }
2544  }
2546  in.cbBuffer = 0;
2547  in.pvBuffer = NULL;
2548 
2549  in_desc.ulVersion = 0;
2550  in_desc.cBuffers = 1;
2551  in_desc.pBuffers = &in;
2552 
2553  p = auth_value + scheme_len;
2554  if (!first && *p == ' ')
2555  {
2556  int len = strlenW(++p);
2557  in.cbBuffer = decode_base64(p, len, NULL);
2558  if (!(in.pvBuffer = HeapAlloc(GetProcessHeap(), 0, in.cbBuffer))) break;
2559  decode_base64(p, len, in.pvBuffer);
2560  }
2562  out.cbBuffer = info->max_token;
2563  if (!(out.pvBuffer = HeapAlloc(GetProcessHeap(), 0, out.cbBuffer)))
2564  {
2565  HeapFree(GetProcessHeap(), 0, in.pvBuffer);
2566  break;
2567  }
2568  out_desc.ulVersion = 0;
2569  out_desc.cBuffers = 1;
2570  out_desc.pBuffers = &out;
2571 
2572  ret = InitializeSecurityContextW(first ? &info->cred : NULL, first ? NULL : &info->ctx,
2573  first ? servername : NULL, flags, 0, SECURITY_NETWORK_DREP,
2574  in.pvBuffer ? &in_desc : NULL, 0, &info->ctx, &out_desc,
2575  &info->attr, &info->exp);
2576  HeapFree(GetProcessHeap(), 0, in.pvBuffer);
2577  if (ret == SEC_E_OK)
2578  {
2579  HeapFree(GetProcessHeap(), 0, info->data);
2580  info->data = out.pvBuffer;
2581  info->data_len = out.cbBuffer;
2582  info->finished = TRUE;
2583  TRACE("sending last auth packet\n");
2584  status = RPC_S_OK;
2585  }
2586  else if (ret == SEC_I_CONTINUE_NEEDED)
2587  {
2588  HeapFree(GetProcessHeap(), 0, info->data);
2589  info->data = out.pvBuffer;
2590  info->data_len = out.cbBuffer;
2591  TRACE("sending next auth packet\n");
2592  status = RPC_S_OK;
2593  }
2594  else
2595  {
2596  ERR("InitializeSecurityContextW failed with error 0x%08x\n", ret);
2597  HeapFree(GetProcessHeap(), 0, out.pvBuffer);
2598  break;
2599  }
2600  info->scheme = creds->AuthnSchemes[0];
2601  break;
2602  }
2603  default:
2604  FIXME("scheme %u not supported\n", creds->AuthnSchemes[0]);
2605  break;
2606  }
2607 
2608  if (status != RPC_S_OK)
2609  {
2610  destroy_authinfo(info);
2611  *auth_ptr = NULL;
2612  return status;
2613  }
2614  *auth_ptr = info;
2615  return RPC_S_OK;
2616 }
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
DWORD DWORD
Definition: winlogon.h:84
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 2664 of file rpc_transport.c.

Referenced by authorize_request(), and rpcrt4_ncacn_http_open().

2665 {
2666  DWORD count, len = 0, size = sizeof(len);
2667  char buf[2048];
2668 
2670  if (!len) return;
2671  for (;;)
2672  {
2673  count = min(sizeof(buf), len);
2674  if (rpcrt4_http_async_read(request, async_data, cancel_event, buf, count) <= 0) return;
2675  len -= count;
2676  }
2677 }
#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:84
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 2282 of file rpc_transport.c.

Referenced by insert_authorization_header().

2283 {
2284  static const char enc[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2285  UINT i = 0, x;
2286 
2287  while (len > 0)
2288  {
2289  /* first 6 bits, all from bin[0] */
2290  base64[i++] = enc[(bin[0] & 0xfc) >> 2];
2291  x = (bin[0] & 3) << 4;
2292 
2293  /* next 6 bits, 2 from bin[0] and 4 from bin[1] */
2294  if (len == 1)
2295  {
2296  base64[i++] = enc[x];
2297  base64[i++] = '=';
2298  base64[i++] = '=';
2299  break;
2300  }
2301  base64[i++] = enc[x | ((bin[1] & 0xf0) >> 4)];
2302  x = (bin[1] & 0x0f) << 2;
2303 
2304  /* next 6 bits 4 from bin[1] and 2 from bin[2] */
2305  if (len == 2)
2306  {
2307  base64[i++] = enc[x];
2308  base64[i++] = '=';
2309  break;
2310  }
2311  base64[i++] = enc[x | ((bin[2] & 0xc0) >> 6)];
2312 
2313  /* last 6 bits, all from bin [2] */
2314  base64[i++] = enc[bin[2] & 0x3f];
2315  bin += 3;
2316  len -= 3;
2317  }
2318  base64[i] = 0;
2319  return i;
2320 }
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 2458 of file rpc_transport.c.

Referenced by do_authorization().

2459 {
2460  DWORD len, index = 0;
2461  for (;;)
2462  {
2463  len = buflen;
2464  if (!HttpQueryInfoW(request, HTTP_QUERY_WWW_AUTHENTICATE, buffer, &len, &index)) return FALSE;
2465  if (auth_scheme_from_header(buffer) == scheme) break;
2466  }
2467  return TRUE;
2468 }
#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:84
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:61
static BOOL has_credentials ( RpcConnection_http httpc)
static

Definition at line 2711 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_http_open().

2712 {
2715 
2717  return FALSE;
2718 
2719  creds = httpc->common.QOS->qos->u.HttpCredentials;
2721  return FALSE;
2722 
2723  id = creds->TransportCredentials;
2724  if (!id || !id->User || !id->Password) return FALSE;
2725 
2726  return TRUE;
2727 }
#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
#define FALSE
Definition: types.h:117
union _RPC_SECURITY_QOS_V2_W::@3075 u
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 2618 of file rpc_transport.c.

Referenced by authorize_request().

2619 {
2620  static const WCHAR authW[] = {'A','u','t','h','o','r','i','z','a','t','i','o','n',':',' '};
2621  static const WCHAR basicW[] = {'B','a','s','i','c',' '};
2622  static const WCHAR negotiateW[] = {'N','e','g','o','t','i','a','t','e',' '};
2623  static const WCHAR ntlmW[] = {'N','T','L','M',' '};
2624  int scheme_len, auth_len = sizeof(authW) / sizeof(authW[0]), len = ((data_len + 2) * 4) / 3;
2625  const WCHAR *scheme_str;
2626  WCHAR *header, *ptr;
2628 
2629  switch (scheme)
2630  {
2632  scheme_str = basicW;
2633  scheme_len = sizeof(basicW) / sizeof(basicW[0]);
2634  break;
2636  scheme_str = negotiateW;
2637  scheme_len = sizeof(negotiateW) / sizeof(negotiateW[0]);
2638  break;
2640  scheme_str = ntlmW;
2641  scheme_len = sizeof(ntlmW) / sizeof(ntlmW[0]);
2642  break;
2643  default:
2644  ERR("unknown scheme %u\n", scheme);
2645  return RPC_S_SERVER_UNAVAILABLE;
2646  }
2647  if ((header = HeapAlloc(GetProcessHeap(), 0, (auth_len + scheme_len + len + 2) * sizeof(WCHAR))))
2648  {
2649  memcpy(header, authW, auth_len * sizeof(WCHAR));
2650  ptr = header + auth_len;
2651  memcpy(ptr, scheme_str, scheme_len * sizeof(WCHAR));
2652  ptr += scheme_len;
2653  len = encode_base64(data, data_len, ptr);
2654  ptr[len++] = '\r';
2655  ptr[len++] = '\n';
2656  ptr[len] = 0;
2658  status = RPC_S_OK;
2659  HeapFree(GetProcessHeap(), 0, header);
2660  }
2661  return status;
2662 }
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 2106 of file rpc_transport.c.

Referenced by rpcrt4_http_prepare_in_pipe(), and rpcrt4_http_prepare_out_pipe().

2107 {
2108  static const WCHAR fmtW[] =
2109  {'C','o','n','t','e','n','t','-','L','e','n','g','t','h',':',' ','%','u','\r','\n',0};
2110  WCHAR header[sizeof(fmtW) / sizeof(fmtW[0]) + 10];
2111 
2112  sprintfW(header, fmtW, len);
2113  if ((HttpAddRequestHeadersW(request, header, -1, HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD))) return RPC_S_OK;
2114  return RPC_S_SERVER_UNAVAILABLE;
2115 }
__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 361 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_np_is_server_listening(), and rpcrt4_ncalrpc_np_is_server_listening().

362 {
363  return WaitNamedPipeA(pipe_name, 1) ? RPC_S_OK : RPC_S_NOT_LISTENING;
364 }
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 2729 of file rpc_transport.c.

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

2730 {
2731  return httpc->common.QOS &&
2734 }
RpcConnection common
RPC_HTTP_TRANSPORT_CREDENTIALS_W * HttpCredentials
Definition: rpcdce.h:279
union _RPC_SECURITY_QOS_V2_W::@3075 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 server,
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  static const char local[] = ".";
265  char ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
266  char *pipe_name;
267  DWORD bufLen = ARRAYSIZE(ComputerName);
268 
269  GetComputerNameA(ComputerName, &bufLen);
270 
271  if (server == NULL || *server == 0 || stricmp(ComputerName, server) == 0)
272  server = local;
273 
274  /* protseq=ncacn_np: named pipes */
275  pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(server) + strlen(endpoint));
276  strcpy(pipe_name, prefix);
277  strcat(pipe_name, server);
278  strcat(pipe_name, endpoint);
279  return pipe_name;
280 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
BOOL WINAPI GetComputerNameA(LPSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:322
DWORD DWORD
Definition: winlogon.h:84
smooth NULL
Definition: ftsmooth.c:416
_Check_return_ _CRTIMP int __cdecl stricmp(_In_z_ const char *_Str1, _In_z_ const char *_Str2)
const XML_Char * prefix
Definition: expat.h:380
#define local
Definition: zutil.h:30
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:240
Definition: nis.h:10
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define ARRAYSIZE(a)
Definition: rpc_transport.c:63
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 1718 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().

1719 {
1720  ResetEvent(async_data->completion_event);
1721  RpcHttpAsyncData_AddRef(async_data);
1722 }
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 1698 of file rpc_transport.c.

Referenced by prepare_async_request().

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

Definition at line 1703 of file rpc_transport.c.

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

1704 {
1705  ULONG refs = InterlockedDecrement(&data->refs);
1706  if (!refs)
1707  {
1708  TRACE("destroying async data %p\n", data);
1711  data->cs.DebugInfo->Spare[0] = 0;
1712  DeleteCriticalSection(&data->cs);
1713  HeapFree(GetProcessHeap(), 0, data);
1714  }
1715  return refs;
1716 }
#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 3679 of file rpc_transport.c.

3680 {
3681  RPC_PROTSEQ_VECTORA *pvector;
3682  unsigned int i;
3684 
3685  TRACE("(%p)\n", protseqs);
3686 
3687  *protseqs = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_PROTSEQ_VECTORW)+(sizeof(unsigned char*)*ARRAYSIZE(protseq_list)));
3688  if (!*protseqs)
3689  goto end;
3690  pvector = *protseqs;
3691  pvector->Count = 0;
3692  for (i = 0; i < ARRAYSIZE(protseq_list); i++)
3693  {
3694  pvector->Protseq[i] = HeapAlloc(GetProcessHeap(), 0, strlen(protseq_list[i].name)+1);
3695  if (pvector->Protseq[i] == NULL)
3696  goto end;
3697  strcpy((char*)pvector->Protseq[i], protseq_list[i].name);
3698  pvector->Count++;
3699  }
3700  status = RPC_S_OK;
3701 
3702 end:
3703  if (status != RPC_S_OK)
3704  RpcProtseqVectorFreeA(protseqs);
3705  return status;
3706 }
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 3646 of file rpc_transport.c.

3647 {
3648  RPC_PROTSEQ_VECTORW *pvector;
3649  unsigned int i;
3651 
3652  TRACE("(%p)\n", protseqs);
3653 
3654  *protseqs = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_PROTSEQ_VECTORW)+(sizeof(unsigned short*)*ARRAYSIZE(protseq_list)));
3655  if (!*protseqs)
3656  goto end;
3657  pvector = *protseqs;
3658  pvector->Count = 0;
3659  for (i = 0; i < ARRAYSIZE(protseq_list); i++)
3660  {
3661  pvector->Protseq[i] = HeapAlloc(GetProcessHeap(), 0, (strlen(protseq_list[i].name)+1)*sizeof(unsigned short));
3662  if (pvector->Protseq[i] == NULL)
3663  goto end;
3664  MultiByteToWideChar(CP_ACP, 0, (CHAR*)protseq_list[i].name, -1,
3665  (WCHAR*)pvector->Protseq[i], strlen(protseq_list[i].name) + 1);
3666  pvector->Count++;
3667  }
3668  status = RPC_S_OK;
3669 
3670 end:
3671  if (status != RPC_S_OK)
3672  RpcProtseqVectorFreeW(protseqs);
3673  return status;
3674 }
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 3594 of file rpc_transport.c.

Referenced by test_rpc_ncacn_ip_tcp().

3595 {
3596  UNICODE_STRING protseqW;
3597 
3598  if (RtlCreateUnicodeStringFromAsciiz(&protseqW, (char*)protseq))
3599  {
3601  RtlFreeUnicodeString(&protseqW);
3602  return ret;
3603  }
3604  return RPC_S_OUT_OF_MEMORY;
3605 }
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 3577 of file rpc_transport.c.

Referenced by RpcNetworkIsProtseqValidA().

3578 {
3579  char ps[0x10];
3580 
3581  WideCharToMultiByte(CP_ACP, 0, protseq, -1,
3582  ps, sizeof ps, NULL, NULL);
3584  return RPC_S_OK;
3585 
3586  FIXME("Unknown protseq %s\n", debugstr_w(protseq));
3587 
3589 }
#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 3610 of file rpc_transport.c.

Referenced by RpcNetworkInqProtseqsA().

3611 {
3612  TRACE("(%p)\n", protseqs);
3613 
3614  if (*protseqs)
3615  {
3616  unsigned int i;
3617  for (i = 0; i < (*protseqs)->Count; i++)
3618  HeapFree(GetProcessHeap(), 0, (*protseqs)->Protseq[i]);
3619  HeapFree(GetProcessHeap(), 0, *protseqs);
3620  *protseqs = NULL;
3621  }
3622  return RPC_S_OK;
3623 }
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 3628 of file rpc_transport.c.

Referenced by RpcNetworkInqProtseqsW().

3629 {
3630  TRACE("(%p)\n", protseqs);
3631 
3632  if (*protseqs)
3633  {
3634  unsigned int i;
3635  for (i = 0; i < (*protseqs)->Count; i++)
3636  HeapFree(GetProcessHeap(), 0, (*protseqs)->Protseq[i]);
3637  HeapFree(GetProcessHeap(), 0, *protseqs);
3638  *protseqs = NULL;
3639  }
3640  return RPC_S_OK;
3641 }
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 3327 of file rpc_transport.c.

Referenced by RPCRT4_ReleaseConnection(), and RPCRT4_server_thread().

3328 {
3329  TRACE("(Connection == ^%p)\n", Connection);
3330  if (SecIsValidHandle(&Connection->ctx))
3331  {
3332  DeleteSecurityContext(&Connection->ctx);
3333  SecInvalidateHandle(&Connection->ctx);
3334  }
3335  rpcrt4_conn_close(Connection);
3336  return RPC_S_OK;
3337 }
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:1059
smooth NULL
Definition: ftsmooth.c:416
#define RPC_S_DUPLICATE_ENDPOINT
Definition: winerror.h:1048
#define TRACE(s)
Definition: solgame.cpp:4
#define PIPE_ACCESS_DUPLEX
Definition: winbase.h:164
#define PIPE_READMODE_MESSAGE
Definition: winbase.h:170
#define RPC_MAX_PACKET_SIZE
Definition: rpc_defs.h:184
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define RPC_S_OK
Definition: rpcnterr.h:22
#define RPC_S_CANT_CREATE_ENDPOINT
Definition: winerror.h:1031
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 502 of file rpc_transport.c.

503 {
504  RpcConnection_np *connection = (RpcConnection_np *)conn;
505  CancelIoEx(connection->pipe, NULL);
506 }
smooth NULL
Definition: ftsmooth.c:416
static int rpcrt4_conn_np_close ( RpcConnection conn)
static

Definition at line 467 of file rpc_transport.c.

468 {
469  RpcConnection_np *connection = (RpcConnection_np *) conn;
470  if (connection->pipe)
471  {
472  FlushFileBuffers(connection->pipe);
473  CloseHandle(connection->pipe);
474  connection->pipe = 0;
475  }
476  if (connection->listen_event)
477  {
478  CloseHandle(connection->listen_event);
479  connection->listen_event = 0;
480  }
481  if (connection->event_cache)
482  {
483  CloseHandle(connection->event_cache);
484  connection->event_cache = 0;
485  }
486  return 0;
487 }
#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 489 of file rpc_transport.c.

490 {
491  RpcConnection_np *connection = (RpcConnection_np*)conn;
493 
494  connection->read_closed = TRUE;
495 #ifdef __REACTOS__ /* FIXME: We should also cancel I/O for other threads */
496  NtCancelIoFile(connection->pipe, &io_status);
497 #else
498  NtCancelIoFileEx(connection->pipe, &connection->io_status, &io_status);
499 #endif
500 }
#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 331 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_np_handoff(), and rpcrt4_ncalrpc_handoff().

332 {
333  /* because of the way named pipes work, we'll transfer the connected pipe
334  * to the child, then reopen the server binding to continue listening */
335 
336  new_npc->pipe = old_npc->pipe;
337  old_npc->pipe = 0;
338  assert(!old_npc->listen_event);
339 }
#define assert(x)
Definition: debug.h:53
static RPC_STATUS rpcrt4_conn_np_impersonate_client ( RpcConnection conn)
static

Definition at line 627 of file rpc_transport.c.

628 {
629  RpcConnection_np *npc = (RpcConnection_np *)conn;
630  BOOL ret;
631 
632  TRACE("(%p)\n", conn);
633 
634  if (conn->AuthInfo && SecIsValidHandle(&conn->ctx))
636 
637  ret = ImpersonateNamedPipeClient(npc->pipe);
638  if (!ret)
639  {
641  WARN("ImpersonateNamedPipeClient failed with error %u\n", error);
642  switch (error)
643  {
646  }
647  }
648  return RPC_S_OK;
649 }
BOOL WINAPI ImpersonateNamedPipeClient(HANDLE hNamedPipe)
Definition: security.c:899
#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:1059
#define ERROR_CANNOT_IMPERSONATE
Definition: winerror.h:849
DWORD DWORD
Definition: winlogon.h:84
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 409 of file rpc_transport.c.

410 {
411  RpcConnection_np *connection = (RpcConnection_np *) conn;
412  HANDLE event;
414 
415  event = get_np_event(connection);
416  if (!event)
417  return -1;
418 
419  if (connection->read_closed)
420  status = STATUS_CANCELLED;
421  else
422  status = NtReadFile(connection->pipe, event, NULL, NULL, &connection->io_status, buffer, count, NULL, NULL);
423  if (status == STATUS_PENDING)
424  {
425  /* check read_closed again before waiting to avoid a race */
426  if (connection->read_closed)
427  {
429 #ifdef __REACTOS__ /* FIXME: We should also cancel I/O for other threads */
430  NtCancelIoFile(connection->pipe, &io_status);
431 #else
432  NtCancelIoFileEx(connection->pipe, &connection->io_status, &io_status);
433 #endif
434  }
436  status = connection->io_status.u.Status;
437  }
438  release_np_event(connection, event);
439  return status && status != STATUS_BUFFER_OVERFLOW ? -1 : connection->io_status.Information;
440 }
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:61
#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 651 of file rpc_transport.c.

652 {
653  BOOL ret;
654 
655  TRACE("(%p)\n", conn);
656 
657  if (conn->AuthInfo && SecIsValidHandle(&conn->ctx))
658  return RPCRT4_default_revert_to_self(conn);
659 
660  ret = RevertToSelf();
661  if (!ret)
662  {
663  WARN("RevertToSelf failed with error %u\n", GetLastError());
665  }
666  return RPC_S_OK;
667 }
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:1483
#define SecIsValidHandle(x)
Definition: sspi.h:63
#define WARN(fmt,...)
Definition: debug.h:111
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#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 508 of file rpc_transport.c.

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

Definition at line 442 of file rpc_transport.c.

443 {
444  RpcConnection_np *connection = (RpcConnection_np *) conn;
446  HANDLE event;
448 
449  event = get_np_event(connection);
450  if (!event)
451  return -1;
452 
453  status = NtWriteFile(connection->pipe, event, NULL, NULL, &io_status, buffer, count, NULL, NULL);
454  if (status == STATUS_PENDING)
455  {
457  status = io_status.u.Status;
458  }
459  release_np_event(connection, event);
460  if (status)
461  return -1;
462 
463  assert(io_status.Information == count);
464  return count;
465 }
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:61
#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:1059
#define RPC_C_IMP_LEVEL_ANONYMOUS
Definition: rpcdce.h:174
#define RPC_C_IMP_LEVEL_IDENTIFY
Definition: rpcdce.h:175
#define NMPWAIT_USE_DEFAULT_WAIT
Definition: winbase.h:134
#define RPC_C_IMP_LEVEL_IMPERSONATE
Definition: rpcdce.h:176
DWORD DWORD
Definition: winlogon.h:84
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:61
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 3403 of file rpc_transport.c.

Referenced by RPCRT4_server_thread().

3404 {
3405  HANDLE event = NULL;
3406 
3407  if (connection->ref > 1)
3408  event = connection->wait_release = CreateEventW(NULL, TRUE, FALSE, NULL);
3409 
3410  RPCRT4_ReleaseConnection(connection);
3411 
3412  if(event)
3413  {
3415  CloseHandle(event);
3416  }
3417 }
#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:61
#define INFINITE
Definition: serial.h:102
static RpcConnection* rpcrt4_conn_tcp_alloc ( void  )
static

Definition at line 1152 of file rpc_transport.c.

1153 {
1154  RpcConnection_tcp *tcpc;
1156  if (tcpc == NULL)
1157  return NULL;
1158  tcpc->sock = -1;
1159  if (!rpcrt4_sock_wait_init(tcpc))
1160  {
1161  HeapFree(GetProcessHeap(), 0, tcpc);
1162  return NULL;
1163  }
1164  return &tcpc->common;
1165 }
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 1502 of file rpc_transport.c.

1503 {
1504  RpcConnection_tcp *connection = (RpcConnection_tcp *) conn;
1505 
1506  TRACE("%p\n", connection);
1507 
1508  SetEvent(connection->cancel_event);
1509 }
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 1482 of file rpc_transport.c.

1483 {
1484  RpcConnection_tcp *connection = (RpcConnection_tcp *) conn;
1485 
1486  TRACE("%d\n", connection->sock);
1487 
1488  if (connection->sock != -1)
1489  closesocket(connection->sock);
1490  connection->sock = -1;
1491  CloseHandle(connection->sock_event);
1492  CloseHandle(connection->cancel_event);
1493  return 0;
1494 }
#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 1496 of file rpc_transport.c.

1497 {
1498  RpcConnection_tcp *connection = (RpcConnection_tcp *) conn;
1499  shutdown(connection->sock, SD_RECEIVE);
1500 }
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 1396 of file rpc_transport.c.

1397 {
1398  int ret;
1399  struct sockaddr_in address;
1400  socklen_t addrsize;
1403  u_long nonblocking;
1404 
1405  addrsize = sizeof(address);
1406  ret = accept(server->sock, (struct sockaddr*) &address, &addrsize);
1407  if (ret < 0)
1408  {
1409  ERR("Failed to accept a TCP connection: error %d\n", ret);
1410  return RPC_S_OUT_OF_RESOURCES;
1411  }
1412 
1413  nonblocking = 1;
1414  ioctlsocket(ret, FIONBIO, &nonblocking);
1415  client->sock = ret;
1416 
1418  ret = getnameinfo((struct sockaddr*)&address, addrsize, client->common.NetworkAddr, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST);
1419  if (ret != 0)
1420  {
1421  ERR("Failed to retrieve the IP address, error %d\n", ret);
1422  return RPC_S_OUT_OF_RESOURCES;
1423  }
1424 
1425  TRACE("Accepted a new TCP connection from %s\n", client->common.NetworkAddr);
1426  return RPC_S_OK;
1427 }
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 1511 of file rpc_transport.c.

1512 {
1513  FIXME("\n");
1514  return RPC_S_ACCESS_DENIED;
1515 }
#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 1429 of file rpc_transport.c.

1431 {
1432  RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
1433  int bytes_read = 0;
1434  while (bytes_read != count)
1435  {
1436  int r = recv(tcpc->sock, (char *)buffer + bytes_read, count - bytes_read, 0);
1437  if (!r)
1438  return -1;
1439  else if (r > 0)
1440  bytes_read += r;
1441  else if (WSAGetLastError() == WSAEINTR)
1442  continue;
1443  else if (WSAGetLastError() != WSAEWOULDBLOCK)
1444  {
1445  WARN("recv() failed: %u\n", WSAGetLastError());
1446  return -1;
1447  }
1448  else
1449  {
1450  if (!rpcrt4_sock_wait_for_recv(tcpc))
1451  return -1;
1452  }
1453  }
1454  TRACE("%d %p %u -> %d\n", tcpc->sock, buffer, count, bytes_read);
1455  return bytes_read;
1456 }
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 1517 of file rpc_transport.c.

1518 {
1519  RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
1520 
1521  TRACE("%p\n", Connection);
1522 
1523  if (!rpcrt4_sock_wait_for_recv(tcpc))
1524  return -1;
1525  return 0;
1526 }
#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 1458 of file rpc_transport.c.

1460 {
1461  RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
1462  int bytes_written = 0;
1463  while (bytes_written != count)
1464  {
1465  int r = send(tcpc->sock, (const char *)buffer + bytes_written, count - bytes_written, 0);
1466  if (r >= 0)
1467  bytes_written += r;
1468  else if (WSAGetLastError() == WSAEINTR)
1469  continue;
1470  else if (WSAGetLastError() != WSAEWOULDBLOCK)
1471  return -1;
1472  else
1473  {
1474  if (!rpcrt4_sock_wait_for_send(tcpc))
1475  return -1;
1476  }
1477  }
1478  TRACE("%d %p %u -> %d\n", tcpc->sock, buffer, count, bytes_written);
1479  return bytes_written;
1480 }
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 3339 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().

3342 {
3343  static LONG next_id;
3344  const struct connection_ops *ops;
3345  RpcConnection* NewConnection;
3346 
3347  ops = rpcrt4_get_conn_protseq_ops(Protseq);
3348  if (!ops)
3349  {
3350  FIXME("not supported for protseq %s\n", Protseq);
3352  }
3353 
3354  NewConnection = ops->alloc();
3355  NewConnection->ref = 1;
3356  NewConnection->server = server;
3357  NewConnection->ops = ops;
3358  NewConnection->NetworkAddr = RPCRT4_strdupA(NetworkAddr);
3359  NewConnection->Endpoint = RPCRT4_strdupA(Endpoint);
3360  NewConnection->NetworkOptions = RPCRT4_strdupW(NetworkOptions);
3361  NewConnection->CookieAuth = RPCRT4_strdupW(CookieAuth);
3362  NewConnection->MaxTransmissionSize = RPC_MAX_PACKET_SIZE;
3363  NewConnection->NextCallId = 1;
3364 
3365  SecInvalidateHandle(&NewConnection->ctx);
3366  if (AuthInfo) RpcAuthInfo_AddRef(AuthInfo);
3367  NewConnection->AuthInfo = AuthInfo;
3368  NewConnection->auth_context_id = InterlockedIncrement( &next_id );
3369  if (QOS) RpcQualityOfService_AddRef(QOS);
3370  NewConnection->QOS = QOS;
3371 
3372  list_init(&NewConnection->conn_pool_entry);
3373  list_init(&NewConnection->protseq_entry);
3374 
3375  TRACE("connection: %p\n", NewConnection);
3376  *Connection = NewConnection;
3377 
3378  return RPC_S_OK;
3379 }
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 3308 of file rpc_transport.c.

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

3309 {
3310  unsigned int i;
3311  for(i=0; i<ARRAYSIZE(conn_protseq_list); i++)
3312  if (!strcmp(conn_protseq_list[i].name, protseq))
3313  return &conn_protseq_list[i];
3314  return NULL;
3315 }
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 3299 of file rpc_transport.c.

Referenced by alloc_serverprotoseq().

3300 {
3301  unsigned int i;
3302  for(i=0; i<ARRAYSIZE(protseq_list); i++)
3303  if (!strcmp(protseq_list[i].name, protseq))
3304  return &protseq_list[i];
3305  return NULL;
3306 }
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 3419 of file rpc_transport.c.

Referenced by RPCRT4_io_thread(), and RPCRT4_server_thread().

3420 {
3421  LONG ref = InterlockedIncrement(&connection->ref);
3422  TRACE("%p ref=%u\n", connection, ref);
3423  return connection;
3424 }
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 2045 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().

2047 {
2048  char *buf = buffer;
2049  BOOL ret;
2050  unsigned int bytes_left = count;
2052 
2053  async_data->inet_buffers.lpvBuffer = HeapAlloc(GetProcessHeap(), 0, count);
2054 
2055  while (bytes_left)
2056  {
2057  async_data->inet_buffers.dwBufferLength = bytes_left;
2058  prepare_async_request(async_data);
2059  ret = InternetReadFileExW(req, &async_data->inet_buffers, IRF_ASYNC, 0);
2060  status = wait_async_request(async_data, ret, cancel_event);
2061  if (status != RPC_S_OK)
2062  {
2063  if (status == RPC_S_CALL_CANCELLED)
2064  TRACE("call cancelled\n");
2065  break;
2066  }
2067 
2068  if (!async_data->inet_buffers.dwBufferLength)
2069  break;
2070  memcpy(buf, async_data->inet_buffers.lpvBuffer,
2071  async_data->inet_buffers.dwBufferLength);
2072 
2073  bytes_left -= async_data->inet_buffers.dwBufferLength;
2074  buf += async_data->inet_buffers.dwBufferLength;
2075  }
2076 
2077  HeapFree(GetProcessHeap(), 0, async_data->inet_buffers.lpvBuffer);
2078  async_data->inet_buffers.lpvBuffer = NULL;
2079 
2080  TRACE("%p %p %u -> %u\n", req, buffer, count, status);
2081  return status == RPC_S_OK ? count : -1;
2082 }
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:2270
#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 1884 of file rpc_transport.c.

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

1885 {
1886  BOOL ret;
1888  DWORD size;
1889  DWORD index;
1890  WCHAR buf[32];
1891  WCHAR *status_text = buf;
1892  TRACE("\n");
1893 
1894  index = 0;
1895  size = sizeof(status_code);
1896  ret = HttpQueryInfoW(hor, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, &status_code, &size, &index);
1897  if (!ret)
1898  return GetLastError();
1899  if (status_code == HTTP_STATUS_OK)
1900  return RPC_S_OK;
1901  index = 0;
1902  size = sizeof(buf);
1903  ret = HttpQueryInfoW(hor, HTTP_QUERY_STATUS_TEXT, status_text, &size, &index);
1904  if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
1905  {
1906  status_text = HeapAlloc(GetProcessHeap(), 0, size);
1907  ret = HttpQueryInfoW(hor, HTTP_QUERY_STATUS_TEXT, status_text, &size, &index);
1908  }
1909 
1910  ERR("server returned: %d %s\n", status_code, ret ? debugstr_w(status_text) : "<status text unavailable>");
1911  if(status_text != buf) HeapFree(GetProcessHeap(), 0, status_text);
1912 
1913  if (status_code == HTTP_STATUS_DENIED)
1914  return ERROR_ACCESS_DENIED;
1915  return RPC_S_SERVER_UNAVAILABLE;
1916 }
#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:1059
DWORD DWORD
Definition: winlogon.h:84
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 1859 of file rpc_transport.c.

Referenced by rpcrt4_http_internet_connect().

1865 {
1866  RpcHttpAsyncData *async_data = (RpcHttpAsyncData *)dwContext;
1867 
1868  switch (dwInternetStatus)
1869  {
1871  TRACE("INTERNET_STATUS_REQUEST_COMPLETED\n");
1872  if (async_data)
1873  {
1874  INTERNET_ASYNC_RESULT *async_result = lpvStatusInformation;
1875 
1876  async_data->async_result = async_result->dwResult ? ERROR_SUCCESS : async_result->dwError;
1877  SetEvent(async_data->completion_event);
1878  RpcHttpAsyncData_Release(async_data);
1879  }
1880  break;
1881  }
1882 }
#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 1918 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_http_open().

1919 {
1920  static const WCHAR wszUserAgent[] = {'M','S','R','P','C',0};
1921  LPWSTR proxy = NULL;
1922  LPWSTR user = NULL;
1923  LPWSTR password = NULL;
1924  LPWSTR servername = NULL;
1925  const WCHAR *option;
1927 
1928  if (httpc->common.QOS &&
1930  {
1931  const RPC_HTTP_TRANSPORT_CREDENTIALS_W *http_cred = httpc->common.QOS->qos->u.HttpCredentials;
1932  if (http_cred->TransportCredentials)
1933  {
1934  WCHAR *p;
1935  const SEC_WINNT_AUTH_IDENTITY_W *cred = http_cred->TransportCredentials;
1936  ULONG len = cred->DomainLength + 1 + cred->UserLength;
1937  user = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
1938  if (!user)
1939  return RPC_S_OUT_OF_RESOURCES;
1940  p = user;
1941  if (cred->DomainLength)
1942  {
1943  memcpy(p, cred->Domain, cred->DomainLength * sizeof(WCHAR));
1944  p += cred->DomainLength;
1945  *p = '\\';
1946  p++;
1947  }
1948  memcpy(p, cred->User, cred->UserLength * sizeof(WCHAR));
1949  p[cred->UserLength] = 0;
1950 
1951  password = RPCRT4_strndupW(cred->Password, cred->PasswordLength);
1952  }
1953  }
1954 
1955  for (option = httpc->common.NetworkOptions; option;
1956  option = (strchrW(option, ',') ? strchrW(option, ',')+1 : NULL))
1957  {
1958  static const WCHAR wszRpcProxy[] = {'R','p','c','P','r','o','x','y','=',0};
1959  static const WCHAR wszHttpProxy[] = {'H','t','t','p','P','r','o','x','y','=',0};
1960 
1961  if (!strncmpiW(option, wszRpcProxy, sizeof(wszRpcProxy)/sizeof(wszRpcProxy[0])-1))
1962  {
1963  const WCHAR *value_start = option + sizeof(wszRpcProxy)/sizeof(wszRpcProxy[0])-1;
1964  const WCHAR *value_end;
1965  const WCHAR *p;
1966 
1967  value_end = strchrW(option, ',');
1968  if (!value_end)
1969  value_end = value_start + strlenW(value_start);
1970  for (p = value_start; p < value_end; p++)
1971  if (*p == ':')
1972  {
1973  port = atoiW(p+1);
1974  value_end = p;
1975  break;
1976  }
1977  TRACE("RpcProxy value is %s\n", debugstr_wn(value_start, value_end-value_start));
1978  servername = RPCRT4_strndupW(value_start, value_end-value_start);
1979  }
1980  else if (!strncmpiW(option, wszHttpProxy, sizeof(wszHttpProxy)/sizeof(wszHttpProxy[0])-1))
1981  {
1982  const WCHAR *value_start = option + sizeof(wszHttpProxy)/sizeof(wszHttpProxy[0])-1;
1983  const WCHAR *value_end;
1984 
1985  value_end = strchrW(option, ',');
1986  if (!value_end)
1987  value_end = value_start + strlenW(value_start);
1988  TRACE("HttpProxy value is %s\n", debugstr_wn(value_start, value_end-value_start));
1989  proxy = RPCRT4_strndupW(value_start, value_end-value_start);
1990  }
1991  else
1992  FIXME("unhandled option %s\n", debugstr_w(option));
1993  }
1994 
1997  if (!httpc->app_info)
1998  {
1999  HeapFree(GetProcessHeap(), 0, password);
2000  HeapFree(GetProcessHeap(), 0, user);
2001  HeapFree(GetProcessHeap(), 0, proxy);
2002  HeapFree(GetProcessHeap(), 0, servername);
2003  ERR("InternetOpenW failed with error %d\n", GetLastError());
2004  return RPC_S_SERVER_UNAVAILABLE;
2005  }
2007 
2008  /* if no RpcProxy option specified, set the HTTP server address to the
2009  * RPC server address */
2010  if (!servername)
2011  {
2012  servername = HeapAlloc(GetProcessHeap(), 0, (strlen(httpc->common.NetworkAddr) + 1)*sizeof(WCHAR));
2013  if (!servername)
2014  {
2015  HeapFree(GetProcessHeap(), 0, password);
2016  HeapFree(GetProcessHeap(), 0, user);
2017  HeapFree(GetProcessHeap(), 0, proxy);
2018  return RPC_S_OUT_OF_RESOURCES;
2019  }
2020  MultiByteToWideChar(CP_ACP, 0, httpc->common.NetworkAddr, -1, servername, strlen(httpc->common.NetworkAddr) + 1);
2021  }
2022 
2023  port = (httpc->common.QOS &&
2027 
2028  httpc->session = InternetConnectW(httpc->app_info, servername, port, user, password,
2029  INTERNET_SERVICE_HTTP, 0, 0);
2030 
2031  HeapFree(GetProcessHeap(), 0, password);
2032  HeapFree(GetProcessHeap(), 0, user);
2033  HeapFree(GetProcessHeap(), 0, proxy);
2034 
2035  if (!httpc->session)
2036  {
2037  ERR("InternetConnectW failed with error %d\n", GetLastError());
2038  HeapFree(GetProcessHeap(), 0, servername);
2039  return RPC_S_SERVER_UNAVAILABLE;
2040  }
2041  httpc->servername = servername;
2042  return RPC_S_OK;
2043 }
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:1059
RPC_HTTP_TRANSPORT_CREDENTIALS_W * HttpCredentials
Definition: rpcdce.h:279
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
#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
union _RPC_SECURITY_QOS_V2_W::@3075 u
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:2098
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:1281
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:1002
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 1814 of file rpc_transport.c.

Referenced by rpcrt4_http_timer_thread().

1815 {
1816  HINTERNET in_request = param;
1817  RpcPktHdr *idle_pkt;
1818 
1820  0, 0);
1821  if (idle_pkt)
1822  {
1823  DWORD bytes_written;
1824  InternetWriteFile(in_request, idle_pkt, idle_pkt->common.frag_len, &bytes_written);
1825  RPCRT4_FreeHeader(idle_pkt);
1826  }
1827 }
VOID RPCRT4_FreeHeader(RpcPktHdr *Header)
Definition: rpc_message.c:402
DWORD DWORD
Definition: winlogon.h:84
RpcPktCommonHdr common
Definition: rpc_defs.h:152
BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer, DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
Definition: internet.c:2135
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 2118 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_http_open().

2121 {
2122  BOOL ret;
2124  RpcPktHdr *hdr;
2125  INTERNET_BUFFERSW buffers_in;
2126  DWORD bytes_written;
2127 
2128  if (!authorized)
2129  {
2130  /* ask wininet to authorize, if necessary */
2131  status = send_echo_request(in_request, async_data, cancel_event);
2132  if (status != RPC_S_OK) return status;
2133  }
2134  memset(&buffers_in, 0, sizeof(buffers_in));
2135  buffers_in.dwStructSize = sizeof(buffers_in);
2136  /* FIXME: get this from the registry */
2137  buffers_in.dwBufferTotal = 1024 * 1024 * 1024; /* 1Gb */
2138  status = insert_content_length_header(in_request, buffers_in.dwBufferTotal);
2139  if (status != RPC_S_OK) return status;
2140 
2141  prepare_async_request(async_data);
2142  ret = HttpSendRequestExW(in_request, &buffers_in, NULL, 0, 0);
2143  status = wait_async_request(async_data, ret, cancel_event);
2144  if (status != RPC_S_OK) return status;
2145 
2146  TRACE("sending HTTP connect header to server\n");
2147  hdr = RPCRT4_BuildHttpConnectHeader(FALSE, connection_uuid, in_pipe_uuid, association_uuid);
2148  if (!hdr) return RPC_S_OUT_OF_RESOURCES;
2149  ret = InternetWriteFile(in_request, hdr, hdr->common.frag_len, &bytes_written);
2150  RPCRT4_FreeHeader(hdr);
2151  if (!ret)
2152  {
2153  ERR("InternetWriteFile failed with error %d\n", GetLastError());
2154  return RPC_S_SERVER_UNAVAILABLE;
2155  }
2156 
2157  return RPC_S_OK;
2158 }
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:1059
static RPC_STATUS wait_async_request(RpcHttpAsyncData *async_data, BOOL call_ret, HANDLE cancel_event)
DWORD DWORD
Definition: winlogon.h:84
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:5470
BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer, DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
Definition: internet.c:2135
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 2205 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_http_open().

2209 {
2210  BOOL ret;
2212  RpcPktHdr *hdr;
2213  BYTE *data_from_server;
2214  RpcPktHdr pkt_from_server;
2215  ULONG field1, field3;
2216  BYTE buf[20];
2217 
2218  if (!authorized)
2219  {
2220  /* ask wininet to authorize, if necessary */
2221  status = send_echo_request(out_request, async_data, cancel_event);
2222  if (status != RPC_S_OK) return status;
2223  }
2224  else
2225  rpcrt4_http_async_read(out_request, async_data, cancel_event, buf, sizeof(buf));
2226 
2227  hdr = RPCRT4_BuildHttpConnectHeader(TRUE, connection_uuid, out_pipe_uuid, NULL);
2228  if (!hdr) return RPC_S_OUT_OF_RESOURCES;
2229 
2230  status = insert_content_length_header(out_request, hdr->common.frag_len);
2231  if (status != RPC_S_OK)
2232  {
2233  RPCRT4_FreeHeader(hdr);
2234  return status;
2235  }
2236 
2237  TRACE("sending HTTP connect header to server\n");
2238  prepare_async_request(async_data);
2239  ret = HttpSendRequestW(out_request, NULL, 0, hdr, hdr->common.frag_len);
2240  status = wait_async_request(async_data, ret, cancel_event);
2241  RPCRT4_FreeHeader(hdr);
2242  if (status != RPC_S_OK) return status;
2243 
2244  status = rpcrt4_http_check_response(out_request);
2245  if (status != RPC_S_OK) return status;
2246 
2247  status = rpcrt4_http_read_http_packet(out_request, async_data, cancel_event,
2248  &pkt_from_server, &data_from_server);
2249  if (status != RPC_S_OK) return status;
2250  status = RPCRT4_ParseHttpPrepareHeader1(&pkt_from_server, data_from_server,
2251  &field1);
2252  HeapFree(GetProcessHeap(), 0, data_from_server);
2253  if (status != RPC_S_OK) return status;
2254  TRACE("received (%d) from first prepare header\n", field1);
2255 
2256  for (;;)
2257  {
2258  status = rpcrt4_http_read_http_packet(out_request, async_data, cancel_event,
2259  &pkt_from_server, &data_from_server);
2260  if (status != RPC_S_OK) return status;
2261  if (pkt_from_server.http.flags != 0x0001) break;
2262 
2263  TRACE("http idle packet, waiting for real packet\n");
2264  HeapFree(GetProcessHeap(), 0, data_from_server);
2265  if (pkt_from_server.http.num_data_items != 0)
2266  {
2267  ERR("HTTP idle packet should have no data items instead of %d\n",
2268  pkt_from_server.http.num_data_items);
2269  return RPC_S_PROTOCOL_ERROR;
2270  }
2271  }
2272  status = RPCRT4_ParseHttpPrepareHeader2(&pkt_from_server, data_from_server,
2273  &field1, flow_control_increment,
2274  &field3);
2275  HeapFree(GetProcessHeap(), 0, data_from_server);
2276  if (status != RPC_S_OK) return status;
2277  TRACE("received (0x%08x 0x%08x %d) from second prepare header\n", field1, *flow_control_increment, field3);
2278 
2279  return RPC_S_OK;
2280 }
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:5565
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 2160 of file rpc_transport.c.

Referenced by rpcrt4_http_prepare_out_pipe().

2162 {
2163  unsigned short data_len;
2164  unsigned int size;
2165 
2166  if (rpcrt4_http_async_read(request, async_data, cancel_event, hdr, sizeof(hdr->common)) < 0)
2167  return RPC_S_SERVER_UNAVAILABLE;
2168  if (hdr->common.ptype != PKT_HTTP || hdr->common.frag_len < sizeof(hdr->http))
2169  {
2170  ERR("wrong packet type received %d or wrong frag_len %d\n",
2171  hdr->common.ptype, hdr->common.frag_len);
2172  return RPC_S_PROTOCOL_ERROR;
2173  }
2174 
2175  size = sizeof(hdr->http) - sizeof(hdr->common);
2176  if (rpcrt4_http_async_read(request, async_data, cancel_event, &hdr->common + 1, size) < 0)
2177  return RPC_S_SERVER_UNAVAILABLE;
2178 
2179  data_len = hdr->common.frag_len - sizeof(hdr->http);
2180  if (data_len)
2181  {
2182  *data = HeapAlloc(GetProcessHeap(), 0, data_len);
2183  if (!*data)
2184  return RPC_S_OUT_OF_RESOURCES;
2185  if (rpcrt4_http_async_read(request, async_data, cancel_event, *data, data_len) < 0)
2186  {
2187  HeapFree(GetProcessHeap(), 0, *data);
2188  return RPC_S_SERVER_UNAVAILABLE;
2189  }
2190  }
2191  else
2192  *data = NULL;
2193 
2194  if (!RPCRT4_IsValidHttpPacket(hdr, *data, data_len))
2195  {
2196  ERR("invalid http packet\n");
2197  HeapFree(GetProcessHeap(), 0, *data);
2198  return RPC_S_PROTOCOL_ERROR;
2199  }
2200 
2201  return RPC_S_OK;
2202 }
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 1829 of file rpc_transport.c.

Referenced by rpcrt4_http_timer_thread().

1830 {
1832  DWORD cached_last_sent_time = *last_sent_time;
1833  return HTTP_IDLE_TIME - (cur_time - cached_last_sent_time > HTTP_IDLE_TIME ? 0 : cur_time - cached_last_sent_time);
1834 }
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
time_t cur_time
#define HTTP_IDLE_TIME
DWORD DWORD
Definition: winlogon.h:84
static DWORD CALLBACK rpcrt4_http_timer_thread ( PVOID  param)
static

Definition at line 1836 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_http_open().

1837 {
1838  HttpTimerThreadData *data_in = param;
1840  DWORD timeout;
1841 
1842  data = *data_in;
1843  HeapFree(GetProcessHeap(), 0, data_in);
1844 
1845  for (timeout = HTTP_IDLE_TIME;
1848  {
1849  /* are we too soon after last send? */
1850  if (GetTickCount() - *data.last_sent_time < HTTP_IDLE_TIME)
1851  continue;
1853  }
1854 
1856  return 0;
1857 }
#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:84
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 941 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_http_get_top_of_tower(), and rpcrt4_ncacn_ip_tcp_get_top_of_tower().

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

Referenced by rpcrt4_ncacn_http_parse_top_of_tower(), and rpcrt4_ncacn_ip_tcp_parse_top_of_tower().

1015 {
1016  const twr_tcp_floor_t *tcp_floor = (const twr_tcp_floor_t *)tower_data;
1017  const twr_ipv4_floor_t *ipv4_floor;
1018  struct in_addr in_addr;
1019 
1020  TRACE("(%p, %d, %p, %p)\n", tower_data, (int)tower_size, networkaddr, endpoint);
1021 
1022  if (tower_size < sizeof(*tcp_floor))
1023  return EPT_S_NOT_REGISTERED;
1024 
1025  tower_data += sizeof(*tcp_floor);
1026  tower_size -= sizeof(*tcp_floor);
1027 
1028  if (tower_size < sizeof(*ipv4_floor))
1029  return EPT_S_NOT_REGISTERED;
1030 
1031  ipv4_floor = (const twr_ipv4_floor_t *)tower_data;
1032 
1033  if ((tcp_floor->count_lhs != sizeof(tcp_floor->protid)) ||
1034  (tcp_floor->protid != tcp_protid) ||
1035  (tcp_floor->count_rhs != sizeof(tcp_floor->port)) ||
1036  (ipv4_floor->count_lhs != sizeof(ipv4_floor->protid)) ||
1037  (ipv4_floor->protid != EPM_PROTOCOL_IP) ||
1038  (ipv4_floor->count_rhs != sizeof(ipv4_floor->ipv4addr)))
1039  return EPT_S_NOT_REGISTERED;
1040 
1041  if (endpoint)
1042  {
1043  *endpoint = I_RpcAllocate(6 /* sizeof("65535") + 1 */);
1044  if (!*endpoint)
1045  return RPC_S_OUT_OF_RESOURCES;
1046  sprintf(*endpoint, "%u", ntohs(tcp_floor->port));
1047  }
1048 
1049  if (networkaddr)
1050  {
1051  *networkaddr = I_RpcAllocate(INET_ADDRSTRLEN);
1052  if (!*networkaddr)
1053  {
1054  if (endpoint)
1055  {
1056  I_RpcFree(*endpoint);
1057  *endpoint = NULL;
1058  }
1059  return RPC_S_OUT_OF_RESOURCES;
1060  }
1061  in_addr.s_addr = ipv4_floor->ipv4addr;
1062  if (!inet_ntop(AF_INET, &in_addr, *networkaddr, INET_ADDRSTRLEN))
1063  {
1064  ERR("inet_ntop: %u\n", WSAGetLastError());
1065  I_RpcFree(*networkaddr);
1066  *networkaddr = NULL;
1067  if (endpoint)
1068  {
1069  I_RpcFree(*endpoint);
1070  *endpoint = NULL;
1071  }
1072  return EPT_S_NOT_REGISTERED;
1073  }
1074  }
1075 
1076  return RPC_S_OK;
1077 }
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 3468 of file rpc_transport.c.

Referenced by RpcMgmtIsServerListening().

3469 {
3470  const struct connection_ops *ops;
3471 
3472  ops = rpcrt4_get_conn_protseq_ops(protseq);
3473  if (!ops)
3474  {
3475  FIXME("not supported for protseq %s\n", protseq);
3476  return RPC_S_INVALID_BINDING;
3477  }
3478 
3479  return ops->is_server_listening(endpoint);
3480 }
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 1787 of file rpc_transport.c.

1788 {
1789  RpcConnection_http *httpc;
1790  httpc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*httpc));
1791  if (!httpc) return NULL;
1793  if (!httpc->async_data)
1794  {
1795  HeapFree(GetProcessHeap(), 0, httpc);
1796  return NULL;
1797  }
1798  TRACE("async data = %p\n", httpc->async_data);
1800  httpc->async_data->refs = 1;
1803  httpc->async_data->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": RpcHttpAsyncData.cs");
1804  return &httpc->common;
1805 }
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 3132 of file rpc_transport.c.

3133 {
3134  RpcConnection_http *httpc = (RpcConnection_http *) Connection;
3135 
3136  SetEvent(httpc->cancel_event);
3137 }
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
static int rpcrt4_ncacn_http_close ( RpcConnection Connection)
static

Definition at line 3099 of file rpc_transport.c.

Referenced by rpcrt4_ncacn_http_close_read().

3100 {
3101  RpcConnection_http *httpc = (RpcConnection_http *) Connection;
3102 
3103  TRACE("\n");
3104 
3105  SetEvent(httpc->timer_cancelled);
3106  if (httpc->in_request)
3108  httpc->in_request = NULL;
3109  if (httpc->out_request)
3111  httpc->out_request = NULL;
3112  if (httpc->app_info)
3113  InternetCloseHandle(httpc->app_info);
3114  httpc->app_info = NULL;
3115  if (httpc->session)
3116  InternetCloseHandle(httpc->session);
3117  httpc->session = NULL;
3119  if (httpc->cancel_event)
3120  CloseHandle(httpc->cancel_event);
3121  HeapFree(GetProcessHeap(), 0, httpc->servername);
3122  httpc->servername = NULL;
3123 
3124  return 0;
3125 }
#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:1437
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 3127 of file rpc_transport.c.

3128 {
3129  rpcrt4_ncacn_http_close(conn); /* FIXME */
3130 }
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 3158 of file rpc_transport.c.

3161 {
3162  return rpcrt4_ip_tcp_get_top_of_tower(tower_data, networkaddr,
3164 }
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 2916 of file rpc_transport.c.

2917 {
2918  assert(0);
2919  return RPC_S_SERVER_UNAVAILABLE;
2920 }
#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 3139 of file rpc_transport.c.

3140 {
3141  FIXME("\n");
3142  return RPC_S_ACCESS_DENIED;
3143 }
#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 2781 of file rpc_transport.c.

2782 {
2783  RpcConnection_http *httpc = (RpcConnection_http *)Connection;
2784  static const WCHAR wszVerbIn[] = {'R','P','C','_','I','N','_','D','A','T','A',0};
2785  static const WCHAR wszVerbOut[] = {'R','P','C','_','O','U','T','_','D','A','T','A',0};
2786  static const WCHAR wszRpcProxyPrefix[] = {'/','r','p','c','/','r','p','c','p','r','o','x','y','.','d','l','l','?',0};
2787  static const WCHAR wszColon[] = {':',0};
2788  static const WCHAR wszAcceptType[] = {'a','p','p','l','i','c','a','t','i','o','n','/','r','p','c',0};
2789  LPCWSTR wszAcceptTypes[] = { wszAcceptType, NULL };
2790  DWORD flags;
2791  WCHAR *url;
2793  BOOL secure, credentials;
2794  HttpTimerThreadData *timer_data;
2795  HANDLE thread;
2796 
2797  TRACE("(%s, %s)\n", Connection->NetworkAddr, Connection->Endpoint);
2798 
2799  if (Connection->server)
2800  {
2801  ERR("ncacn_http servers n