Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

artp.c File Reference

#include <stdio.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdarg.h>
#include <stdlib.h>
#include "artp.h"
#include "structs.h"
#include "options.h"
#include "setting.h"
#include "config.h"
#include "rbuffers.h"
#include "sbuffers.h"
#include "abuffers.h"
#include "rwlocks.h"
#include "net.h"

Functions

int artp_prepare_connection (SID_TYPE sid, struct sockaddr *receiver)
int artp_destroy_connection (SID_TYPE sid, struct sockaddr *receiver)
int artp_send_dgram (struct artp_dgram *dgram, SID_TYPE sid, struct sockaddr *receiver)
int artp_free_dgram (struct artp_dgram *dgram)
int artp_receive_dgram (SID_TYPE sid, struct sockaddr *sender, struct artp_dgram *dgram)
int artp_receive_any_dgram (SID_TYPE *sid, struct sockaddr **sender, struct artp_dgram *dgram)
int artp_get_undlvr_session (SID_TYPE *sid, struct sockaddr *receiver)
int artp_get_sid (struct sockaddr *receiver, SID_TYPE *sid)
int artp_set_session_options (SID_TYPE sid, struct sockaddr *receiver, int use, enum artp_session_options option,...)
int artp_set_session_params (SID_TYPE sid, struct sockaddr *receiver, enum artp_session_params param,...)
int artp_init (int socket, char *filename)

Detailed Description

Active router transport protocol's (ARTP) main library.
Author:
Tomas Rebok
Date:
2004

Function Documentation

int artp_destroy_connection SID_TYPE    sid,
struct sockaddr *    receiver
 

Destroy session. This function destroys previously created session (all its structures and buffers are destroyed, too). This session destroying is made like a garbage collector - each session knows the count of pointers that points to it. When this count is equal to 0, the session is deleted.

Parameters:
sid  session identification number of deleted session
receiver  the pointer to the place where destroying session's receiver is stored
Returns:
zero success.
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).

int artp_free_dgram struct artp_dgram   dgram
 

Free ARTP datagram. This function unallocates space taken by ARTP dgram (the space where points ARTP dgram pointers).

Parameters:
dgram  the pointer to the space where ARTP dgram is stored
Returns:
zero success.
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).

int artp_get_sid struct sockaddr *    receiver,
SID_TYPE *    sid
 

Get available session identification number. This function finds out available session identification number for given receiver.

Parameters:
receiver  the pointer to the place where receiver address is stored
sid  the pointer to the place where found session identification number could be stored
Returns:
zero success
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).

int artp_get_undlvr_session SID_TYPE *    sid,
struct sockaddr *    receiver
 

Get undeliverable session. This function returns the non-established session whose packet couldn't be sent.

Parameters:
sid  the pointer to the place where session identification number could be stored
receiver  the relevant pointer which will be moved to the place where the packet's receiver is stored.
Returns:
zero success.
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).

int artp_init int    sckt,
char *    filename
 

Initialize ARTP library. This function makes necessary initialization steps for proper function of ARTP protocol (starts threads, buffers and other structures initialization, etc.). It MUST be called as a first function! (Before any using of this protocol).

Parameters:
sckt  socket where this protocol should listen on.
filename  the name of a config file (or NULL if no config file is required).
Returns:
zero success.
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).

int artp_prepare_connection SID_TYPE    sid,
struct sockaddr *    receiver
 

Prepare new connection. This function prepares new connection to be established (all necessary structures and buffers are created). Then this new session is inserted to its right position in array of pointers to sessions.

Parameters:
sid  session identification number of creating session.
receiver  the pointer to the place where new session's receiver is stored
Returns:
zero success.
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).

int artp_receive_any_dgram SID_TYPE *    sid,
struct sockaddr **    sender,
struct artp_dgram   dgram
 

Receive ARTP datagram from non-established sessions. This function receives ARTP dgram from non-established session.

Parameters:
sid  the pointer to the place where session identification number could be stored
sender  the relevant pointer which will be moved to the place where the dgram sender is stored.
dgram  the pointer to the place where ARTP dgram information could be saved.
Returns:
zero success.
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).

int artp_receive_dgram SID_TYPE    sid,
struct sockaddr *    sender,
struct artp_dgram   dgram
 

Receive ARTP datagram from established sessions. This function receives ARTP datagram from given sender (sent through given session). This session must be previously established.

Parameters:
sid  session identification number
sender  the pointer to the place where session's sender/receiver is stored
dgram  the pointer to the place where ARTP dgram information could be saved.
Returns:
zero success.
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).

int artp_send_dgram struct artp_dgram   dgram,
SID_TYPE    sid,
struct sockaddr *    receiver
 

Send ARTP datagram. This function sends ARTP datagram to specified receiver through given session. It creates packet header and copies there its payload (the payload is fragmented if necessary). Then it's stored to proper session buffer.

Parameters:
dgram  the pointer to the sending datagram.
sid  session identification number
receiver  the pointer to the place where session receiver is stored
Returns:
zero success.
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).

int artp_set_session_options SID_TYPE    sid,
struct sockaddr *    receiver,
int    use,
enum artp_session_options    option,
...   
 

Set session options. This function sets defined session options. The option value is taken from variable options list (there's taken the first one only). By proper parameter we can say if we want to use this option or not.

Parameters:
sid  the identification number of proper session
receiver  the pointer to the place where session's receiver is stored
use  indicates whether we have to use this option or not. (0 = do not use, 1 = use)
option  the option identifier that we want to set
...  option value
Returns:
zero success.
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).

int artp_set_session_params SID_TYPE    sid,
struct sockaddr *    sender,
enum artp_session_params    param,
...   
 

Set session parameters. This function sets defined session parameters. The parameter value is taken from variable options list (there's taken the first one only).

Parameters:
sid  the identification number of proper session
receiver  the pointer to the place where session's receiver is stored
param  the parameter identifier that we want to set
...  parameter value
Returns:
zero success.
Returns:
nonzero related error code if something failed (for further information see documentation of file errors.h).


Generated on Fri May 21 07:50:25 2004 for Active Router Transport Protocol (ARTP) by doxygen1.2.15