Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

pproxy.c File Reference


Detailed Description

Push proxy HTTP management.

Author:
Raphael Manfredi
Date:
2003

#include "common.h"
#include "pproxy.h"
#include "http.h"
#include "hosts.h"
#include "version.h"
#include "sockets.h"
#include "ioheader.h"
#include "bsched.h"
#include "routing.h"
#include "gmsg.h"
#include "uploads.h"
#include "ggep.h"
#include "ggep_type.h"
#include "gnet_stats.h"
#include "lib/url.h"
#include "settings.h"
#include "token.h"
#include "downloads.h"
#include "features.h"
#include "lib/misc.h"
#include "lib/atoms.h"
#include "lib/getline.h"
#include "lib/header.h"
#include "lib/glib-missing.h"
#include "lib/endian.h"
#include "lib/tm.h"
#include "lib/walloc.h"
#include "if/gnet_property_priv.h"
#include "lib/override.h"

Defines

#define CPROXY_MAGIC   0xc8301U

Functions

void send_pproxy_error (struct pproxy *pp, int code, const gchar *msg,...) G_GNUC_PRINTF(3
 Send error message to requestor.
void pproxy_error_remove (struct pproxy *pp, int code, const gchar *msg,...) G_GNUC_PRINTF(3
 Utility routine.
void pproxy_free_resources (struct pproxy *pp)
 Get rid of all the resources attached to the push-proxy struct.
void send_pproxy_error_v (struct pproxy *pp, const gchar *ext, int code, const gchar *msg, va_list ap)
 The vectorized (message-wise) version of send_pproxy_error().
void pproxy_remove_v (struct pproxy *pp, const gchar *reason, va_list ap)
 The vectorized (message-wise) version of pproxy_remove().
void pproxy_remove (struct pproxy *pp, const gchar *reason,...)
 Remove push proxy entry, log reason.
void pproxy_timer (time_t now)
 Push proxy timer.
pproxypproxy_create (struct gnutella_socket *s)
 pproxy_create
gboolean get_params (struct pproxy *pp, const gchar *request, const gchar **guid_atom, guint32 *file_idx, gboolean *supports_tls)
 Extract GUID for push-proxyfication from the HTTP request line.
array build_push (guint8 ttl, guint8 hops, const gchar *guid, host_addr_t addr_v4, host_addr_t addr_v6, guint16 port, guint32 file_idx, gboolean supports_tls)
 Builds a push request to send.
const gchar * validate_vendor (gchar *vendor, gchar *token, const host_addr_t addr)
 Validate vendor.
void pproxy_request (struct pproxy *pp, header_t *header)
 Called once all the HTTP headers have been read to proceed with the push proxyfication.
pproxyPPROXY (gpointer obj)
void err_line_too_long (gpointer obj)
void err_header_error_tell (gpointer obj, gint error)
void err_header_error (gpointer obj, gint error)
void err_input_exception (gpointer obj)
void err_input_buffer_full (gpointer obj)
void err_header_read_error (gpointer obj, gint error)
void err_header_read_eof (gpointer obj)
void err_header_extra_data (gpointer obj)
void call_pproxy_request (gpointer obj, header_t *header)
void pproxy_add (struct gnutella_socket *s)
 Create new push-proxy request and begin reading HTTP headers.
void pproxy_close (void)
 Called a shutdown time.
void cproxy_free (struct cproxy *cp)
 Free the structure and all its dependencies.
void cproxy_http_error_ind (struct http_async *handle, http_errtype_t type, gpointer v)
 HTTP async callback for error notifications.
gboolean cproxy_http_header_ind (struct http_async *handle, header_t *header, gint code, const gchar *message)
 HTTP async callback for header reception notification.
size_t cproxy_build_request (struct http_async *unused_handle, gchar *buf, size_t len, const gchar *verb, const gchar *path, const gchar *unused_host, guint16 unused_port)
 Redefines the HTTP request building.
void cproxy_http_newstate (struct http_async *handle, http_state_t newstate)
 Invoked when the state of the HTTP async request changes.
cproxycproxy_create (struct download *d, const host_addr_t addr, guint16 port, const gchar *guid, guint32 file_idx)
 Create client proxy.
void cproxy_reparent (struct download *d, struct download *cd)
 Updates the proxy structures to point to the right download when a download was cloned.

Variables

GSList * pproxies = NULL
 Currently active push-proxy requests.
const struct io_error pproxy_io_error


Define Documentation

#define CPROXY_MAGIC   0xc8301U
 


Function Documentation

struct array build_push guint8  ttl,
guint8  hops,
const gchar *  guid,
host_addr_t  addr_v4,
host_addr_t  addr_v6,
guint16  port,
guint32  file_idx,
gboolean  supports_tls
 

Builds a push request to send.

We set TTL=max_ttl-1 and hops=1 since it does not come from our node really. The file ID may be set to 0, but it should be ignored when the GIV is received anyway.

Parameters:
size_ptr no document
ttl the TTL to use for the packet header.
hops the hops value to use for the packet header.
guid the hops value to use for the packet header.
addr the host address the receiving peer should connect to.
port the port number the receiving peer should connect to.
file_idx the file index this push is for.
Returns:
A pointer to a static buffer holding the created Gnutella PUSH packet on success, an empty array on failure.

void call_pproxy_request gpointer  obj,
header_t header
[static]
 

size_t cproxy_build_request struct http_async unused_handle,
gchar *  buf,
size_t  len,
const gchar *  verb,
const gchar *  path,
const gchar *  unused_host,
guint16  unused_port
[static]
 

Redefines the HTTP request building.

See http_async_build_request() for the model and details about the various parameters.

Returns:
length of generated request.

struct cproxy* cproxy_create struct download d,
const host_addr_t  addr,
guint16  port,
const gchar *  guid,
guint32  file_idx
 

Create client proxy.

Returns:
NULL if problem during connection.

void cproxy_free struct cproxy cp  ) 
 

Free the structure and all its dependencies.

void cproxy_http_error_ind struct http_async handle,
http_errtype_t  type,
gpointer  v
[static]
 

HTTP async callback for error notifications.

gboolean cproxy_http_header_ind struct http_async handle,
header_t header,
gint  code,
const gchar *  message
[static]
 

HTTP async callback for header reception notification.

Returns:
whether processing can continue.

void cproxy_http_newstate struct http_async handle,
http_state_t  newstate
[static]
 

Invoked when the state of the HTTP async request changes.

void cproxy_reparent struct download d,
struct download cd
 

Updates the proxy structures to point to the right download when a download was cloned.

void err_header_error gpointer  obj,
gint  error
[static]
 

void err_header_error_tell gpointer  obj,
gint  error
[static]
 

void err_header_extra_data gpointer  obj  )  [static]
 

void err_header_read_eof gpointer  obj  )  [static]
 

void err_header_read_error gpointer  obj,
gint  error
[static]
 

void err_input_buffer_full gpointer  obj  )  [static]
 

void err_input_exception gpointer  obj  )  [static]
 

void err_line_too_long gpointer  obj  )  [static]
 

gboolean get_params struct pproxy pp,
const gchar *  request,
const gchar **  guid_atom,
guint32 *  file_idx,
gboolean *  supports_tls
[static]
 

Extract GUID for push-proxyfication from the HTTP request line.

Extract file index if present (otherwise 0 will be used).

Fills the GUID atom into `guid_atom' and the file index into `file_idx'.

Returns:
TRUE if OK, FALSE if we could not figure it out, in which case we also return an error to the calling party.

struct pproxy* PPROXY gpointer  obj  )  [inline, static]
 

void pproxy_add struct gnutella_socket s  ) 
 

Create new push-proxy request and begin reading HTTP headers.

void pproxy_close void   ) 
 

Called a shutdown time.

struct pproxy* pproxy_create struct gnutella_socket s  )  [static]
 

pproxy_create

void pproxy_error_remove struct pproxy pp,
int  code,
const gchar *  msg,
  ...
[static]
 

Utility routine.

Cancel the request, sending back the HTTP error message.

void pproxy_free_resources struct pproxy pp  )  [static]
 

Get rid of all the resources attached to the push-proxy struct.

But not the structure itself.

void pproxy_remove struct pproxy pp,
const gchar *  reason,
  ...
 

Remove push proxy entry, log reason.

If no status has been sent back on the HTTP stream yet, give them a 400 error with the reason.

void pproxy_remove_v struct pproxy pp,
const gchar *  reason,
va_list  ap
[static]
 

The vectorized (message-wise) version of pproxy_remove().

void pproxy_request struct pproxy pp,
header_t header
[static]
 

Called once all the HTTP headers have been read to proceed with the push proxyfication.

void pproxy_timer time_t  now  ) 
 

Push proxy timer.

void send_pproxy_error struct pproxy pp,
int  code,
const gchar *  msg,
  ...
[static]
 

Send error message to requestor.

This can only be done once per connection.

void send_pproxy_error_v struct pproxy pp,
const gchar *  ext,
int  code,
const gchar *  msg,
va_list  ap
[static]
 

The vectorized (message-wise) version of send_pproxy_error().

const gchar* validate_vendor gchar *  vendor,
gchar *  token,
const host_addr_t  addr
[static]
 

Validate vendor.

Returns:
atom, or NULL.


Variable Documentation

GSList* pproxies = NULL [static]
 

Currently active push-proxy requests.

const struct io_error pproxy_io_error [static]
 

Initial value:

 {
    err_line_too_long,
    err_header_error_tell,
    err_header_error,
    err_input_exception,
    err_input_buffer_full,
    err_header_read_error,
    err_header_read_eof,
    err_header_extra_data,
}


Generated on Sat Jun 30 17:53:29 2007 for gtk-gnutella by  doxygen 1.3.9.1