client/client.c File Reference

#include "io.h"
#include "errors.h"

Include dependency graph for client.c:

Go to the source code of this file.

Data Structures

struct  Proxy

Defines

#define IDLE_PING_TIMEOUT   20000
#define check_err(T, N, M)   if(!(T)) { error(conn, UTU_ERR_##N, bfromcstr(M)); check(T,M); }
#define FD_SWAP(fd1, fds1, fd2, fds2)   FD_SET(fd1, fds1); FD_CLR(fd2, fds2)
#define PROXY_HANDLE_EVENT(side, readfd, readfn, writefd, writefn)

Enumerations

enum  { HUB = 0, LISTENER = 1 }

Functions

void Proxy_destroy (Proxy *conn)
int Proxy_listener_send (Proxy *conn, Node *header, Node *body)
void error (Proxy *conn, UtuMendicantErrorCode code, bstring message)
void Proxy_dump_invalid_state (Proxy *conn)
int Proxy_confirm_key (CryptState *state)
int Proxy_final_verify (Proxy *conn)
void Proxy_timeout (void *p)
int Proxy_hub_send (Proxy *conn, Node *header, Node *body)
NodeProxy_hub_recv (Proxy *conn, Node **header)
NodeProxy_listener_recv (Proxy *conn, Node **header)
int Proxy_event_loop (Proxy *conn)
int Proxy_connect (Proxy *conn)
int Proxy_listen (Proxy *conn, bstring sock_name)
int Proxy_configure (Proxy *conn)
int main (int argc, char **argv)


Define Documentation

#define check_err ( T,
N,
 )     if(!(T)) { error(conn, UTU_ERR_##N, bfromcstr(M)); check(T,M); }

Like the normal check macro but handles sending stackish formatted errors back to the listener.

Definition at line 23 of file client.c.

Referenced by Proxy_configure(), Proxy_connect(), Proxy_event_loop(), Proxy_final_verify(), Proxy_hub_recv(), Proxy_hub_send(), Proxy_listen(), and Proxy_listener_send().

#define FD_SWAP ( fd1,
fds1,
fd2,
fds2   )     FD_SET(fd1, fds1); FD_CLR(fd2, fds2)

Definition at line 206 of file client.c.

#define IDLE_PING_TIMEOUT   20000

Definition at line 17 of file client.c.

Referenced by Proxy_event_loop(), and Proxy_timeout().

#define PROXY_HANDLE_EVENT ( side,
readfd,
readfn,
writefd,
writefn   ) 

Value:

if(FD_ISSET(readfd, &readmask)) {\
    body[side] = readfn(conn, &header[side]);\
    check_err(header[side] && body[side], IO, "message read failure");\
    FD_SWAP(writefd, &writeset, readfd, &readset);\
  }\
\
  if(FD_ISSET(writefd, &writemask)) {\
    check_err(writefn(conn, header[side], body[side]), IO, "message write failure");\
    FD_SWAP(readfd, &readset, writefd, &writeset);\
  }

Definition at line 208 of file client.c.

Referenced by Proxy_event_loop().


Enumeration Type Documentation

anonymous enum

Enumerator:
HUB 
LISTENER 

Definition at line 221 of file client.c.


Function Documentation

void error ( Proxy conn,
UtuMendicantErrorCode  code,
bstring  message 
)

Writes an error in stackish format to the stderr so the controlling process can read it.

Definition at line 69 of file client.c.

References Node_cons(), and Proxy_listener_send().

Here is the call graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 374 of file client.c.

References bdestroy(), bfromcstr(), check, ensure, Proxy_configure(), Proxy_connect(), Proxy_destroy(), Proxy_event_loop(), and Proxy_listen().

Here is the call graph for this function:

int Proxy_configure ( Proxy conn  ) 

Definition at line 336 of file client.c.

References bdestroy(), blength, check_err, Proxy::client, ensure, Proxy::fd, Proxy::host, Proxy::key, log, Proxy::name, Node_decons(), Node_destroy(), and readnodes().

Referenced by main().

Here is the call graph for this function:

int Proxy_confirm_key ( CryptState state  ) 

Definition at line 94 of file client.c.

References assert_mem, biseq(), CRYPT_THEIR_KEY, CryptState_export_key(), CryptState::data, fail, Proxy::host, Proxy::host_given_key, log, on_fail, and Proxy_dump_invalid_state().

Referenced by Proxy_connect().

Here is the call graph for this function:

int Proxy_connect ( Proxy conn  ) 

Definition at line 260 of file client.c.

References assert_mem, bdata, bdestroy(), check_err, Proxy::client, CryptState_create(), CryptState_init(), CryptState_initiator_process_response(), CryptState_initiator_send_final(), CryptState_initiator_start(), CryptState::data, ensure, Proxy::host, Proxy::key, log, Proxy::name, Node_bstr(), Node_destroy(), Proxy_confirm_key(), Proxy_final_verify(), readnodes(), Proxy::state, tcp_client(), and write_header_node().

Referenced by main().

Here is the call graph for this function:

void Proxy_destroy ( Proxy conn  ) 

Definition at line 44 of file client.c.

References assert_mem, bdestroy(), Proxy::client, CryptState_destroy(), Proxy::fd, Proxy::host, Proxy::host_given_key, Proxy::key, Proxy::name, and Proxy::state.

Referenced by main().

Here is the call graph for this function:

void Proxy_dump_invalid_state ( Proxy conn  ) 

Definition at line 75 of file client.c.

References bdata, bformat(), CryptState_fingerprint_bstr(), error, Proxy::host, Proxy::host_given_key, CryptPeer::name, Proxy::state, CryptState::them, and UTU_ERR_PEER_VERIFY.

Referenced by Proxy_confirm_key(), and Proxy_final_verify().

Here is the call graph for this function:

int Proxy_event_loop ( Proxy conn  ) 

Definition at line 223 of file client.c.

References assert_mem, check_err, Proxy::client, Proxy::fd, Proxy::host, HUB, IDLE_PING_TIMEOUT, LISTENER, on_fail, PROXY_HANDLE_EVENT, Proxy_hub_recv(), Proxy_hub_send(), Proxy_listener_recv(), Proxy_listener_send(), Proxy_timeout(), timeout(), and tselect().

Referenced by main().

Here is the call graph for this function:

int Proxy_final_verify ( Proxy conn  ) 

Definition at line 113 of file client.c.

References assert_mem, biseq(), check_err, Proxy::client, CRYPT_MY_KEY, CryptState_export_key(), Proxy::host, Proxy::host_given_key, log, CryptState::me, CryptPeer::name, Proxy::name, Node_cons(), on_fail, Proxy_dump_invalid_state(), Proxy_listener_send(), Proxy::state, and CryptState::them.

Referenced by Proxy_connect().

Here is the call graph for this function:

Node* Proxy_hub_recv ( Proxy conn,
Node **  header 
)

Definition at line 169 of file client.c.

References assert_mem, bdestroy(), check_err, CryptState_decrypt_node(), ensure, Proxy::host, CryptState::me, Node_bstr(), Node_destroy(), readnodes(), CryptPeer::skey, and Proxy::state.

Referenced by Proxy_event_loop().

Here is the call graph for this function:

int Proxy_hub_send ( Proxy conn,
Node header,
Node body 
)

Definition at line 148 of file client.c.

References assert_mem, bdestroy(), check_err, check_then, CryptState_encrypt_node(), ensure, Proxy::host, Node_bstr(), Node_destroy(), CryptPeer::skey, Proxy::state, CryptState::them, and write_header_node().

Referenced by Proxy_event_loop().

Here is the call graph for this function:

int Proxy_listen ( Proxy conn,
bstring  sock_name 
)

Definition at line 322 of file client.c.

References bdata, check_err, Proxy::client, Proxy::fd, log, on_fail, and unix_client().

Referenced by main().

Here is the call graph for this function:

Node* Proxy_listener_recv ( Proxy conn,
Node **  header 
)

Definition at line 199 of file client.c.

References Proxy::client, Proxy::fd, and readnodes().

Referenced by Proxy_event_loop().

Here is the call graph for this function:

int Proxy_listener_send ( Proxy conn,
Node header,
Node body 
)

Definition at line 187 of file client.c.

References assert_mem, check_err, Proxy::client, ensure, Proxy::fd, Node_destroy(), and writenodes().

Referenced by error(), Proxy_event_loop(), and Proxy_final_verify().

Here is the call graph for this function:

void Proxy_timeout ( void *  p  ) 

Definition at line 140 of file client.c.

References assert_mem, IDLE_PING_TIMEOUT, and timeout().

Referenced by Proxy_event_loop().

Here is the call graph for this function:


Generated on Tue Apr 10 01:00:18 2007 for Utu by  doxygen 1.5.1