flute.c File Reference

FLUTE sender and receiver. More...

#include <stdlib.h>
#include <assert.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <ctype.h>
#include <time.h>
#include <string.h>
#include <stdio.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <process.h>
#include <io.h>
#include <direct.h>
#include "../alclib/alc_session.h"
#include "../alclib/alc_tx.h"
#include "../alclib/alc_rx.h"
#include "flute.h"
#include "fdt_gen.h"
#include "receiver.h"
#include "sender.h"
#include "uri.h"
#include "padding_encoding.h"
#include "mad_zlib.h"
#include "mad_md5.h"
#include "display.h"
#include "http_file_repair.h"
#include "flute_file_repair.h"
#include "apd.h"

Include dependency graph for flute.c:

Go to the source code of this file.

Functions

int name_incomplete_objects (flute_receiver_t *receiver)
void add_missing_block (flute_receiver_report_t *report, unsigned long long first, unsigned long long last)
void copy_file_name (char **file_name, flute_receiver_t *r, unsigned long long toi)
void copy_md5 (char **md5, flute_receiver_t *r, unsigned long long toi)
void build_report (arguments_t *a, flute_receiver_t *r, flute_receiver_report_t **report)
unsigned int random_number (int max)
int flute_sender (arguments_t *a, int *s_id, unsigned long long *session_size)
int flute_receiver (arguments_t *a, int *s_id)
int flute_receiver_report (arguments_t *a, int *s_id, flute_receiver_report_t **report)
void free_receiver_report (flute_receiver_report_t *report)
unsigned long long flute_session_size (arguments_t *a, int *s_id)
void set_flute_session_state (int s_id, enum alc_session_states state)
void set_all_flute_sessions_state (enum alc_session_states state)
void set_flute_session_base_rate (int s_id, int base_tx_rate)
int start_up_flute (void)
void shut_down_flute (arguments_t *anArguments)
void shut_down_flute2 (void)


Detailed Description

FLUTE sender and receiver.

Author
peltotal
Date
2007/02/28 08:58:01
Revision
1.83

MAD-FLUTELIB: Implementation of FLUTE protocol. Copyright (c) 2003-2007 TUT - Tampere University of Technology main authors/contacts: jani.peltotalo@tut.fi and sami.peltotalo@tut.fi

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

In addition, as a special exception, TUT - Tampere University of Technology gives permission to link the code of this program with the OpenSSL library (or with modified versions of OpenSSL that use the same license as OpenSSL), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than OpenSSL. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.

Definition in file flute.c.


Function Documentation

void add_missing_block ( flute_receiver_report_t report,
unsigned long long  first,
unsigned long long  last 
)

This is a private function which adds missing bytes information with receiver reporting.

Parameters:
report pointer to structure containing receiver information
first first missing byte
last last missing byte

Definition at line 280 of file flute.c.

References missing_block::first, missing_block::last, flute_receiver_report::mb_list, and missing_block::next.

Referenced by build_report().

Here is the caller graph for this function:

void build_report ( arguments_t a,
flute_receiver_t r,
flute_receiver_report_t **  report 
)

This is a private function which builds the receiver report.

Parameters:
a arguments structure where command line arguments are parsed
r pointer to structure containing receiver information
report stores receiver report.

Definition at line 335 of file flute.c.

References add_missing_block(), arguments::alc_a, trans_obj::block_list, block_ready_to_decode(), trans_obj::bs, copy_file_name(), copy_md5(), trans_obj::es_len, flute_receiver_report::file_name, get_session_obj_list(), trans_block::k, trans_obj::len, flute_receiver_report::mb_list, flute_receiver_report::md5, blocking_struct::N, trans_obj::next, flute_receiver_report::next, object_completed(), flute_receiver::s_id, trans_obj::toi, and alc_arguments::verbosity.

Referenced by flute_receiver_report().

Here is the call graph for this function:

Here is the caller graph for this function:

void copy_file_name ( char **  file_name,
flute_receiver_t r,
unsigned long long  toi 
)

This is a private function which copies file name with receiver reporting.

Parameters:
file_name name of the file
r pointer to structure containing receiver information
toi transport object identifier

Definition at line 299 of file flute.c.

References flute_receiver::fdt, file, find_file_with_toi(), and file::location.

Referenced by build_report().

Here is the call graph for this function:

Here is the caller graph for this function:

void copy_md5 ( char **  md5,
flute_receiver_t r,
unsigned long long  toi 
)

This is a private function which copies MD5 with receiver reporting.

Parameters:
md5 MD5 of the file
r pointer to structure containing receiver information
toi transport object identifier

Definition at line 317 of file flute.c.

References flute_receiver::fdt, file, find_file_with_toi(), and file::md5.

Referenced by build_report().

Here is the call graph for this function:

Here is the caller graph for this function:

int flute_receiver ( arguments_t a,
int *  s_id 
)

This function is flute receiver's "main function".

Parameters:
a arguments structure where command line arguments are parsed
s_id stores session identifier
Returns:
0 when state is SClosed, -1 in error cases, -2 when state is SExiting, -3 when state is STxStopped, -4 when MD5 check error occurs, -5 when state is SExiting in start time waiting period

Definition at line 739 of file flute.c.

References flute_receiver_report().

Referenced by main(), and start_flute_process().

Here is the call graph for this function:

Here is the caller graph for this function:

int flute_receiver_report ( arguments_t a,
int *  s_id,
flute_receiver_report_t **  report 
)

This function is flute receiver's "main function" with receiver reporting.

Parameters:
a arguments structure where command line arguments are parsed
s_id stores session identifier
report stores receiver report.
Returns:
0 when state is SClosed, -1 in error cases, -2 when state is SExiting, -3 when state is STxStopped, -4 when MD5 check error occurs, -5 when state is SExiting in start time waiting period

Definition at line 743 of file flute.c.

References flute_receiver::accept_expired_fdt_inst, alc_arguments::accept_expired_fdt_inst, add_alc_channel(), alc_arguments::addr, alc_arguments::addr_family, alc_arguments::addr_type, arguments::alc_a, apd, alc_arguments::base_dir, apd::bmFileRepair, build_report(), alc_arguments::cc_id, close_alc_session(), chunk::data, decode_apd_config(), FALSE, flute_receiver::fdt, fdt_thread(), file, fdt::file_list, arguments::file_path, arguments::file_table_output, flute_receiver::file_uri_table, FILE_URI_TABLE_SIZE, flute_file_repair(), FreeAPD(), FreeFDT(), get_alc_session(), get_session_state(), alc_session::handle_rx_thread, http_file_repair(), increase_ipv6_address(), alc_arguments::intface, alc_arguments::intface_name, file::location, MAX_CHANNELS_IN_SESSION, MAX_PATH_LENGTH, MAX_PORT_LENGTH, alc_arguments::nb_channel, file::next, serviceURI::next, Null, postFileRepair::offsetTime, open_alc_session(), arguments::open_file, parse_sdp_file(), alc_arguments::port, apd::postFileRepair, serviceURI::prev, random_number(), postFileRepair::randomTimePeriod, receiver_file_table_output_thread(), receiver_in_fdt_based_mode(), receiver_in_object_mode(), receiver_in_ui_mode(), remove_alc_channels(), arguments::repair, RLC, flute_receiver::rx_automatic, arguments::rx_automatic, arguments::rx_object, alc_session::rx_thread_id, flute_receiver::s_id, arguments::sdp_file, postFileRepair::serviceURI_List, bmFileRepair::sessionDescriptionURI, set_session_state(), SExiting, chunk::size, alc_arguments::start_time, file::status, alc_arguments::stop_time, TRUE, serviceURI::URI, flute_receiver::verbosity, alc_arguments::verbosity, flute_receiver::wildcard_token, and write_to_buffer().

Referenced by flute_receiver().

Here is the call graph for this function:

Here is the caller graph for this function:

int flute_sender ( arguments_t a,
int *  s_id,
unsigned long long *  session_size 
)

This function is flute sender's "main function".

Parameters:
a arguments structure where command line arguments are parsed
s_id stores session identifier
session_size stores session size
Returns:
0 in success, -1 in error cases, -2 when state is SExiting, -3 if session end time passed

session_size = get_session_sent_bytes(*s_id);

Definition at line 423 of file flute.c.

References add_alc_channel(), alc_arguments::addr, alc_arguments::addr_family, alc_arguments::addr_type, arguments::alc_a, alc_arguments::base_dir, alc_arguments::cc_id, close_alc_session(), arguments::complete_fdt, flute_sender::fdt, arguments::fdt_file, alc_arguments::fec_enc_id, alc_arguments::fec_inst_id, alc_arguments::fec_ratio, arguments::file_path, arguments::file_table_output, FreeFDT(), generate_fdt(), get_alc_session(), get_session_sent_bytes(), alc_session::handle_tx_thread, increase_ipv6_address(), alc_arguments::intface, alc_arguments::intface_name, MAX_CHANNELS_IN_SESSION, MAX_PATH_LENGTH, MAX_PORT_LENGTH, alc_arguments::nb_channel, Null, open_alc_session(), parse_sdp_file(), alc_arguments::port, REED_SOL_FEC_INST_ID, arguments::repair, RLC, flute_sender::s_id, SB_SYS_FEC_ENC_ID, arguments::sdp_file, send_session_close_packet(), arguments::send_session_close_packets, sender_file_table_output_thread(), sender_in_fdt_based_mode(), set_session_state(), SExiting, alc_arguments::stop_time, TRUE, alc_arguments::tsi, alc_session::tx_thread_id, and alc_arguments::verbosity.

Referenced by flute_session_size(), main(), and start_flute_process().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned long long flute_session_size ( arguments_t a,
int *  s_id 
)

This function calculates the amount of data that the FLUTE sender will send (including UDP/IP).

Parameters:
a pointer to the argument struct
s_id session identifier
Returns:
session size in bytes

Definition at line 1586 of file flute.c.

References arguments::alc_a, alc_arguments::calculate_session_size, alc_arguments::cc_id, arguments::cont, flute_sender(), alc_arguments::nb_tx, Null, TRUE, and alc_arguments::verbosity.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

void free_receiver_report ( flute_receiver_report_t report  ) 

This function frees receiver report structure.

Parameters:
report pointer to receiver report structure.

Definition at line 1569 of file flute.c.

References flute_receiver_report::file_name, flute_receiver_report::mb_list, flute_receiver_report::md5, missing_block::next, and flute_receiver_report::next.

int name_incomplete_objects ( flute_receiver_t receiver  ) 

This is a private function which names all uncompleted objects.

Parameters:
receiver pointer to structure containing receiver information
Returns:
0 in success, -1 in error cases

Definition at line 85 of file flute.c.

References file::content_len, file::encoding, flute_receiver::fdt, file, fdt::file_list, free_object(), free_uri(), get_alc_session(), get_session_basedir(), get_session_obj_list(), get_uri_host_and_path(), file::location, MAX_PATH_LENGTH, trans_obj::next, file::next, alc_session::obj_list, PAD_SUFFIX, padding_decoder(), parse_uri(), flute_receiver::s_id, trans_obj::tmp_filename, trans_obj::toi, and file::toi.

Here is the call graph for this function:

unsigned int random_number ( int  max  ) 

This function returns a random number between zero and max.

Parameters:
max maximum number for random number
Returns:
random number between zero and max

Definition at line 418 of file flute.c.

Referenced by flute_receiver_report().

Here is the caller graph for this function:

void set_all_flute_sessions_state ( enum alc_session_states  state  ) 

This function sets the session state for all opened sessions.

Parameters:
state new state

Definition at line 1634 of file flute.c.

References set_all_sessions_state().

Referenced by signal_handler().

Here is the call graph for this function:

Here is the caller graph for this function:

void set_flute_session_base_rate ( int  s_id,
int  base_tx_rate 
)

This function sets new base rate for the session.

Parameters:
s_id session identifier
base_tx_rate new transmission rate for the base channel

Definition at line 1639 of file flute.c.

References update_session_tx_rate().

Here is the call graph for this function:

void set_flute_session_state ( int  s_id,
enum alc_session_states  state 
)

This function sets the session state for the session.

Parameters:
s_id session identifier
state new state

Definition at line 1629 of file flute.c.

References set_session_state().

Referenced by signal_handler().

Here is the call graph for this function:

Here is the caller graph for this function:

void shut_down_flute ( arguments_t anArguments  ) 

This function performs all operations to shut-down the library.

Parameters:
anArguments pointer to argument structure

Definition at line 1667 of file flute.c.

References arguments::log_fd, release_fdt_parser(), release_session_handler(), arguments::sdp, arguments::sdp_file, sdp_message_free(), sf_free(), and arguments::src_filt.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

void shut_down_flute2 ( void   ) 

This function performs all operations to shut-down the library.

Definition at line 1691 of file flute.c.

References release_fdt_parser(), and release_session_handler().

Here is the call graph for this function:

int start_up_flute ( void   ) 

This function performs all operations to start-up the library.

Returns:
0 in success, -1 otherwise

Definition at line 1643 of file flute.c.

References initialize_fdt_parser(), and initialize_session_handler().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Fri Mar 9 20:02:27 2007 for MAD-FCL by  doxygen 1.5.0