src/vfer_packet.h File Reference

Defines packet structures for the protocol. More...

#include <limits.h>
#include <netinet/in.h>
#include <sys/uio.h>
#include "vfer_datagram.h"
#include "vfer.h"

Go to the source code of this file.

Data Structures

struct  ccack_pack
 congestion control ack packet type More...
struct  close_pack
 close packet type More...
struct  data_pack
 data packet type More...
struct  packet
 generic vfer packet type More...
struct  request_pack
 request packet type More...
struct  response_pack
 response packet type More...

Defines

#define CCACK_LENGTH   CCACKH_LENGTH + TOPH_LENGTH
#define CCACKH_LENGTH   22
#define CLOSE_LENGTH   CLOSEH_LENGTH + TOPH_LENGTH
#define CLOSEH_LENGTH   0
#define DATA_LENGTH   DATAH_LENGTH + TOPH_LENGTH
#define DATAACK_LENGTH   DATAACKH_LENGTH + TOPH_LENGTH
#define DATAACKH_LENGTH   DATAH_LENGTH + SYNCH_LENGTH
#define DATAH_LENGTH   10
#define REQUEST_LENGTH   REQUESTH_LENGTH + TOPH_LENGTH
#define REQUESTH_LENGTH   14
#define RESPONSE_LENGTH   RESPONSEH_LENGTH + TOPH_LENGTH
#define RESPONSEH_LENGTH   20
#define TOPH_LENGTH   16

Enumerations

enum  packet_opt { OPT_FRAME_LEN = 1, OPT_SYNC = 2, OPT_VEC = 4 }
enum  packet_type {
  REQUEST = 16, RESPONSE = 32, DATA = 48, CC_ACK = 64,
  DATA_ACK = 96, CLOSE = 112
}

Functions

packetPacket_Form_CCAck (uint32_t opts, uint32_t seq_num, uint32_t last_seq_received, uint16_t packets_lost, uint16_t oldest_frame, uint16_t newest_frame, int32_t delay_delta, int32_t delay, uint32_t bytes_total, uint16_t intervals_frame_num, intervals_t *intervals)
packetPacket_Form_Close (uint32_t opts, uint32_t seq_num)
packetPacket_Form_Data (uint32_t opts, uint32_t seq_num, uint16_t frame_num, uint32_t data_offset, uint32_t frame_len, void *data, int data_len)
packetPacket_Form_Request (uint32_t opts, uint32_t init_seq_num, uint32_t max_frame_size, uint32_t recv_buf_size, uint32_t send_buf_size, uint16_t init_frame_num)
packetPacket_Form_Response (uint32_t opts, uint32_t init_seq_num, uint16_t init_frame_num, uint16_t connection_port, uint32_t max_frame_size, uint32_t recv_buf_size, uint32_t send_buf_size, int32_t request_delay)
uint16_t Packet_Gen_FrameNum ()
uint32_t Packet_Gen_SeqNum ()
void Packet_Print (packet *p)
int Packet_Read (int fd, packet **p, struct sockaddr *addr, socklen_t *addr_len)
int Packet_Read_ICMP (int icmp_fd, void *pmtu)
void Packet_Set_Seq (packet *p, uint32_t seq)
char * Packet_Str (packet *p)
char * Packet_Str_Type (packet *p)
int Packet_Translate_CCAck (packet *p)
int Packet_Translate_Close (packet *p)
int Packet_Translate_Data (packet *p)
int Packet_Translate_Request (packet *p)
int Packet_Translate_Response (packet *p)
int Packet_Write (packet *p, int fd, struct sockaddr *addr, socklen_t addr_len)

Variables

char pack_buf [65536]


Detailed Description

Defines packet structures for the protocol.

Author:
Ivan Beschastnikh
Supports packet.c and defines structures used by c_control.c.

Definition in file vfer_packet.h.


Define Documentation

#define CCACK_LENGTH   CCACKH_LENGTH + TOPH_LENGTH

Definition at line 47 of file vfer_packet.h.

#define CCACKH_LENGTH   22

Definition at line 37 of file vfer_packet.h.

#define CLOSE_LENGTH   CLOSEH_LENGTH + TOPH_LENGTH

Definition at line 48 of file vfer_packet.h.

#define CLOSEH_LENGTH   0

Definition at line 38 of file vfer_packet.h.

#define DATA_LENGTH   DATAH_LENGTH + TOPH_LENGTH

Definition at line 45 of file vfer_packet.h.

#define DATAACK_LENGTH   DATAACKH_LENGTH + TOPH_LENGTH

Definition at line 46 of file vfer_packet.h.

#define DATAACKH_LENGTH   DATAH_LENGTH + SYNCH_LENGTH

Definition at line 40 of file vfer_packet.h.

#define DATAH_LENGTH   10

Definition at line 36 of file vfer_packet.h.

#define REQUEST_LENGTH   REQUESTH_LENGTH + TOPH_LENGTH

Definition at line 43 of file vfer_packet.h.

#define REQUESTH_LENGTH   14

Definition at line 34 of file vfer_packet.h.

#define RESPONSE_LENGTH   RESPONSEH_LENGTH + TOPH_LENGTH

Definition at line 44 of file vfer_packet.h.

#define RESPONSEH_LENGTH   20

Definition at line 35 of file vfer_packet.h.

#define TOPH_LENGTH   16

Definition at line 31 of file vfer_packet.h.


Enumeration Type Documentation

enum packet_opt

Enumerator:
OPT_FRAME_LEN 
OPT_SYNC 
OPT_VEC 

Definition at line 146 of file vfer_packet.h.

enum packet_type

Enumerator:
REQUEST 
RESPONSE 
DATA 
CC_ACK 
DATA_ACK 
CLOSE 

Definition at line 139 of file vfer_packet.h.


Function Documentation

packet* Packet_Form_CCAck ( uint32_t  opts,
uint32_t  seq_num,
uint32_t  last_seq_received,
uint16_t  packets_lost,
uint16_t  oldest_frame,
uint16_t  newest_frame,
int32_t  delay_delta,
int32_t  delay,
uint32_t  bytes_total,
uint16_t  intervals_frame_num,
intervals_t intervals 
)

Forms a CC Ack packet

Parameters:
opts options for the generic header of the packet
seq_num sequence number for the generic header of the packet
last_seq_received last sequence number received by this connection
packets_lost estimated lost number of frags
oldest_frame oldest frame the received of this packet should resend
newest_frame oldest frame the received of this packet should resend
delay_delta current delay on the reverse path (not the path of this ack)
delay current delay for the reverse path
bytes_total total data bytes received by the endpoint
intervals_frame_num the frame number corresponding to the missing data intervals
intervals intervals structure (defined in datagram.h) If intervals->head == 0 then no intervals will be sent in the ack packet
Returns:
NULL on error pointer to an allocated packet on success

Definition at line 304 of file vfer_packet.c.

packet* Packet_Form_Close ( uint32_t  opts,
uint32_t  seq_num 
)

Forms a Close packet

Parameters:
opts options for the generic header of the packet
seq_num sequence number for the generic header of the packet
Returns:
NULL on error pointer to an allocated packet on success

Definition at line 417 of file vfer_packet.c.

packet* Packet_Form_Data ( uint32_t  opts,
uint32_t  seq_num,
uint16_t  frame_num,
uint32_t  data_offset,
uint32_t  frame_len,
void *  data,
int  data_len 
)

Forms a Data packet

Parameters:
opts options for the generic header of the packet
seq_num sequence number for the generic header of the packet
frame_num frame number this data packet carries a frag for
data_offset offset of the data in the frame
frame_len either -1 (do not include in the data header) (opts will be set and send accordingly) or is not -1, in which case it is included in the data header
data data buffer to send in the body of the data packet
data_len tells us how the span of the data buffer pointed to by the data arg
Returns:
NULL on error pointer to an allocated packet on success

Definition at line 240 of file vfer_packet.c.

packet* Packet_Form_Request ( uint32_t  opts,
uint32_t  init_seq_num,
uint32_t  max_frame_size,
uint32_t  recv_buf_size,
uint32_t  send_buf_size,
uint16_t  init_frame_num 
)

Forms a Request packet

Parameters:
opts options for the generic header of the packet
init_seq_num initial sequence number for the sender's half of connection
max_frame_size maximum frame size the sender is willing to receive
recv_buf_size receive buffer size at the sender
send_buf_size sending buffer size at the sender
init_frame_num initial frame number for the sender's half of connection
Returns:
NULL on error pointer to an allocated packet on success

Definition at line 134 of file vfer_packet.c.

packet* Packet_Form_Response ( uint32_t  opts,
uint32_t  init_seq_num,
uint16_t  init_frame_num,
uint16_t  connection_port,
uint32_t  max_frame_size,
uint32_t  recv_buf_size,
uint32_t  send_buf_size,
int32_t  request_delay 
)

Forms a Response packet

Parameters:
opts options for the generic header of the packet
init_seq_num initial sequence number for the sender's half of connection
init_frame_num initial frame number for the sender's half of connection
connection_port the connection port to which the sender should connect and use for the remained of this connection
max_frame_size maximum frame size the sender is willing to receive
recv_buf_size receive buffer size at the sender
send_buf_size sending buffer size at the sender
request_delay the delay computed for the request packet
Returns:
NULL on error pointer to an allocated packet on success

Definition at line 183 of file vfer_packet.c.

uint16_t Packet_Gen_FrameNum (  )  [inline]

Generates a random (2 bytes) frame number

Returns:
generated frame number

Definition at line 1037 of file vfer_packet.c.

uint32_t Packet_Gen_SeqNum (  )  [inline]

Generates a random (4 byte) sequence number.

Returns:
generated sequence number

Definition at line 1048 of file vfer_packet.c.

void Packet_Print ( packet p  ) 

Prints a description of the packet onto stdout

Parameters:
p packet pointer

Definition at line 107 of file vfer_packet.c.

int Packet_Read ( int  fd,
packet **  p,
struct sockaddr *  addr,
socklen_t *  addr_len 
)

Reads from a file descriptor into an iov buffer.

Does minor validation of the generic header. Returns either an error or the packet_type of the received packet. Set iov as return by reference.

Parameters:
fd file descriptor to which to write the buffer
p packet strucutre to read the packet into
addr pointer that is either NULL or address to which we send the iov
addr_len pointer to be set by reference to length of addr param
Returns:
0 on success (p contains a valid packet) errno on syscall error -1 received packet has incorrect length (validation err) -2 received packet has incorrect type (validation err) -3 received packet has incorrect version (validation err) -4 on unknown packet type -5 on error (shutdown socket) -6 on error (ALLOC macro) -7 on error (other) - such as mismatched recv sizes (see below)

Definition at line 789 of file vfer_packet.c.

int Packet_Read_ICMP ( int  icmp_fd,
void *  pmtu 
)

Reads ICMP packets and makes any necessary adjustments to the path MTU.

Parameters:
icmp_fd file descriptor of icmp socket
pmtu pmtu structure to modify if we read an ICMP packet
Returns:
0 on success (p contains a valid packet) -1 no ICMP packets to be read

Definition at line 913 of file vfer_packet.c.

void Packet_Set_Seq ( packet p,
uint32_t  seq 
) [inline]

Sets the sequence number in the packet header

Parameters:
p pointer to the packet in which to set the header
seq sequence number to set in the header

Definition at line 618 of file vfer_packet.c.

char* Packet_Str ( packet p  ) 

Create a string description of the packet

Parameters:
p packet pointer
Returns:
string describing the packet parameter

Definition at line 75 of file vfer_packet.c.

char* Packet_Str_Type ( packet p  ) 

String type of packet

Parameters:
p packet pointer
Returns:
string describing the type of the packet parameter

Definition at line 53 of file vfer_packet.c.

int Packet_Translate_CCAck ( packet p  ) 

Fills in the cc_ack union memeber with values from a raw packet

Parameters:
p packet pointer to traslate
Returns:
0 on success -1 packet with incorrect length

Definition at line 543 of file vfer_packet.c.

int Packet_Translate_Close ( packet p  ) 

Fills in the close union memeber with values from a raw packet

Parameters:
p packet pointer to traslate
Returns:
0 on success -1 packet with incorrect length

Definition at line 601 of file vfer_packet.c.

int Packet_Translate_Data ( packet p  ) 

Fills in the data union memeber with values from a raw packet

Parameters:
p packet pointer to traslate
Returns:
0 on success -1 packet with incorrect length

Definition at line 502 of file vfer_packet.c.

int Packet_Translate_Request ( packet p  ) 

Fills in the request union memeber with values from a raw packet

Parameters:
p packet pointer to traslate
Returns:
0 on success -1 packet with incorrect length

Definition at line 437 of file vfer_packet.c.

int Packet_Translate_Response ( packet p  ) 

Fills in the response union memeber with values from a raw packet

Parameters:
p packet pointer to traslate
Returns:
0 on success -1 packet with incorrect length

Definition at line 466 of file vfer_packet.c.

int Packet_Write ( packet p,
int  fd,
struct sockaddr *  addr,
socklen_t  addr_len 
)

Writes a packet of a certain length to a file descriptor.

Parameters:
p packet structure containing the packet to write out
fd file descriptor to which to write the buffer
addr is the address to send the packet to (eg. for unconnected sockets - used in server.c Server_Accept() )
addr_len is the length of the addr param
Returns:
0 on success errno generated by sendmsg or writev on error

Definition at line 956 of file vfer_packet.c.


Variable Documentation

char pack_buf[65536]

Definition at line 192 of file vfer_packet.h.


Generated on Tue Aug 8 16:07:21 2006 for VFER by  doxygen 1.4.7