frames.c
Go to the documentation of this file.
00001 /*------------------------------------------------------------------------
00002  *---------------------           RT-WMP              --------------------
00003  *------------------------------------------------------------------------
00004  *                                                         V7.0B  11/05/10
00005  *
00006  *
00007  *  File: ./src/core/routing/basic/frames.c
00008  *  Authors: Danilo Tardioli
00009  *  ----------------------------------------------------------------------
00010  *  Copyright (C) 2000-2010, Universidad de Zaragoza, SPAIN
00011  *
00012  *  Contact Addresses: Danilo Tardioli                   dantard@unizar.es
00013  *
00014  *  RT-WMP is free software; you can  redistribute it and/or  modify it
00015  *  under the terms of the GNU General Public License  as published by the
00016  *  Free Software Foundation;  either  version 2, or (at  your option) any
00017  *  later version.
00018  *
00019  *  RT-WMP  is distributed  in the  hope  that  it will be   useful, but
00020  *  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
00021  *  MERCHANTABILITY  or  FITNESS FOR A  PARTICULAR PURPOSE.    See the GNU
00022  *  General Public License for more details.
00023  *
00024  *  You should have received  a  copy of  the  GNU General Public  License
00025  *  distributed with RT-WMP;  see file COPYING.   If not,  write to the
00026  *  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
00027  *  02111-1307, USA.
00028  *
00029  *  As a  special exception, if you  link this  unit  with other  files to
00030  *  produce an   executable,   this unit  does  not  by  itself cause  the
00031  *  resulting executable to be covered by the  GNU General Public License.
00032  *  This exception does  not however invalidate  any other reasons why the
00033  *  executable file might be covered by the GNU Public License.
00034  *
00035  *----------------------------------------------------------------------*/
00036 
00037 #include "core/include/global.h"
00038 #include "core/include/frames.h"
00039 #include "config/compiler.h"
00040 
00041 #define TOKEN_ROUTING_INFO_SIZE status.N_NODES*status.N_NODES
00042 #define AUTH_ROUTING_INFO_SIZE 0
00043 #define MSG_ROUTING_INFO_SIZE  0
00044 
00045 char * wmp_get_frame_tail_pointer(wmpFrame * t){
00046 
00047         char * tkn_data_ptr =(char*)t;
00048         if (t->hdr.type==TOKEN){
00049                 tkn_data_ptr+=(sizeof(Token_Hdr)+sizeof(Token)+status.N_NODES*status.N_NODES);
00050         }
00051         else if (t->hdr.type==AUTHORIZATION){
00052                 tkn_data_ptr+=(sizeof(Token_Hdr)+sizeof(Authorization));
00053         }else if        (t->hdr.type==MESSAGE){
00054                 tkn_data_ptr+=(sizeof(Token_Hdr)+sizeof(Message)+t->msg.len);
00055         }else {
00056                 WMP_MSG(stderr,"Unknown frame type in get_data_pointer, exiting\n");
00057         }
00058         return tkn_data_ptr;
00059 }
00060 
00061 char * wmp_get_frame_routing_pointer(wmpFrame * t){
00062         char * tkn_data_ptr =(char*)t;
00063         if (t->hdr.type==TOKEN){
00064                 tkn_data_ptr+=(sizeof(Token_Hdr)+sizeof(Token));
00065         } else if       (t->hdr.type==AUTHORIZATION){
00066                 tkn_data_ptr+=(sizeof(Token_Hdr)+sizeof(Authorization));
00067         }else if        (t->hdr.type==MESSAGE){
00068                 tkn_data_ptr+=(sizeof(Token_Hdr)+sizeof(Message));
00069         }else {
00070                 WMP_MSG(stderr,"Unknown frame type in get_data_pointer, exiting\n");
00071         }
00072         return tkn_data_ptr;
00073 }
00074 
00075 char * wmp_get_frame_routing_pointer_new_tree(wmpFrame * t){
00076         char * tkn_data_ptr =(char*)t;
00077         tkn_data_ptr+=(sizeof(Token_Hdr)+sizeof(Token)+2*status.N_NODES);
00078         return tkn_data_ptr;
00079 }
00080 
00081 char * wmp_get_frame_routing_pointer_status(wmpFrame * t){
00082         char * tkn_data_ptr =(char*)t;
00083         tkn_data_ptr+=(sizeof(Token_Hdr)+sizeof(Token)+status.N_NODES);
00084         return tkn_data_ptr;
00085 }
00086 
00087 char * wmp_get_message_data_pointer(wmpFrame * t){
00088         char * tkn_data_ptr =(char*)t;
00089         if (t->hdr.type!=MESSAGE) return NULL;
00090         tkn_data_ptr+=(sizeof(Token_Hdr)+sizeof(Message)+status.N_NODES);
00091         return tkn_data_ptr;
00092 }
00093 
00094 int wmp_get_frame_total_lenght(wmpFrame * t){
00095         int size=sizeof(Token_Hdr);
00096         if (t->hdr.type==TOKEN){
00097                 size+=sizeof(Token) + 3*status.N_NODES;
00098         } else if (t->hdr.type==AUTHORIZATION){
00099                 size+=sizeof(Authorization) + status.N_NODES;
00100         } else if (t->hdr.type==MESSAGE){
00101                 size+=sizeof(Message) + status.N_NODES + t->msg.len;
00102         } else if (t->hdr.type==DROP_TOKEN){
00103                 size+=sizeof(Drop);
00104         } else {
00105                 size+=0;
00106         }
00107 #ifdef ENABLE_BC_SUPPORT
00108         if (t->hdr.bc_type!=0){
00109                 size+=t->hdr.bc_len;
00110         }
00111 #endif
00112         return size;
00113 }
00114 
00115 
00116 
00117 


ros_rt_wmp
Author(s): Danilo Tardioli, dantard@unizar.es
autogenerated on Fri Jan 3 2014 12:07:54