Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

netio.h File Reference

provides functions to do read/write from/to a socket More...

#include <stdio.h>
#include "errorcodes.h"
#include "comm.h"
#include "def.h"

Go to the source code of this file.

Functions

errorcode readMsg (sock_t sd, comm_type_t type, void *buf, int buf_len)
 reads up to buf_len bytes into buf
errorcode sendMsg (sock_t sd, long type, void *payload, long payload_len)
 creates a message from the type and payload and sents it


Detailed Description

provides functions to do read/write from/to a socket

Author:
Daniel Ferullo (ferullo@.cmu.edu)

Definition in file netio.h.


Function Documentation

errorcode readMsg sock_t  sd,
comm_type_t  type,
void *  buf,
int  buf_len
 

reads up to buf_len bytes into buf

This function checks that as it read messages the length field of the header is correct

THIS FUNCTION CONTAINS A COMPLICATED WHILE LOOP THAT IS WORTH A SECOND LOOK!

Parameters:
sd the socket to read from
type the message type to read
buf the buffer to store the message in (the payload only)
buf_len the length of the buffer
Returns:
SUCCESS, errorcode on failure

Definition at line 35 of file netio.c.

References CHECK_NOT_NEG, checkMsgLen(), COMM_HEADER_LEN, comm_type_t, DBG_ALL, DEBUG, ERROR_NEG_ARG_1, ERROR_NEG_ARG_4, errorcode, and safe_free().

Referenced by helper_fsm_buddy_alloc(), helper_fsm_buddy_port(), helper_fsm_conn2(), helper_fsm_end_buddy_bday(), helper_fsm_end_peer_bday(), helper_fsm_goodbye(), helper_fsm_hello(), helper_fsm_start_buddy_bday(), helper_fsm_start_direct_conn(), helper_fsm_start_peer_bday(), peer_fsm_bday_synack_flood(), peer_fsm_buddy_alloc(), peer_fsm_buddy_port(), peer_fsm_check_port_pred(), peer_fsm_conn_again(), peer_fsm_end_bday(), and peer_fsm_forge_syn_ack().

errorcode sendMsg sock_t  sd,
long  type,
void *  payload,
long  payload_len
 

creates a message from the type and payload and sents it

Parameters:
sd the socket to send on
type the message type
payload a pointer to the payload (can be NULL if payload == 0)
payload_len the length of the payload in bytes
Returns:
SUCCESS, neg on failure

Definition at line 152 of file netio.c.

References CHECK_NOT_NEG, COMM_HEADER_LEN, COMM_LENGTH_LEN, COMM_TYPE_LEN, DBG_NETWORK, DEBUG, ERROR_NEG_ARG_1, ERROR_NEG_ARG_4, errorcode, and safe_free().

Referenced by helper_fsm_buddy_alloc(), helper_fsm_buddy_port(), helper_fsm_conn2(), helper_fsm_end_buddy_bday(), helper_fsm_end_peer_bday(), helper_fsm_hello(), helper_fsm_start_buddy_bday(), helper_fsm_start_direct_conn(), helper_fsm_start_peer_bday(), peer_fsm_bday_synack_flood(), peer_fsm_buddy_alloc(), peer_fsm_check_port_pred(), peer_fsm_conn_again(), peer_fsm_end_bday(), peer_fsm_forge_syn_ack(), peer_fsm_hello(), peer_fsm_reply_bday(), peer_fsm_start_bday(), and peer_fsm_start_direct_conn().


Generated on Wed Mar 30 23:20:48 2005 for NATBLASTER by  doxygen 1.3.9.1