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         }
00066         else if (t->hdr.type==AUTHORIZATION){
00067                 tkn_data_ptr+=(sizeof(Token_Hdr)+sizeof(Authorization));
00068         }else if        (t->hdr.type==MESSAGE){
00069                 tkn_data_ptr+=(sizeof(Token_Hdr)+sizeof(Message)+t->msg.len);
00070         }else {
00071                 WMP_MSG(stderr,"Unknown frame type in get_data_pointer, exiting\n");
00072         }
00073         return tkn_data_ptr;
00074 }
00075 
00076 char * wmp_get_message_data_pointer(wmpFrame * t) {
00077         char * tkn_data_ptr = (char*) t;
00078         if (t->hdr.type != MESSAGE)
00079                 return NULL;
00080         tkn_data_ptr += (sizeof(Token_Hdr) + sizeof(Message));
00081         return tkn_data_ptr;
00082 }
00083 
00084 int wmp_get_frame_total_lenght(wmpFrame * t) {
00085         int size = sizeof(Token_Hdr);
00086         if (t->hdr.type == TOKEN) {
00087                 size += sizeof(Token) + status.N_NODES * status.N_NODES;
00088         } else if (t->hdr.type == AUTHORIZATION) {
00089                 size += sizeof(Authorization);
00090         } else if (t->hdr.type == MESSAGE) {
00091                 if (mBitsIsSet(t->msg.type, AURA_MSG)) {
00092                         size += sizeof(Message) + t->msg.len;
00093                 } else {
00094                         size += sizeof(Authorization);
00095                 }
00096         } else if (t->hdr.type == DROP_TOKEN) {
00097                 size += sizeof(Drop);
00098         }
00099         return size;
00100 }
00101 
00102 
00103 
00104 


ros_rt_wmp
Author(s): Danilo Tardioli, dantard@unizar.es
autogenerated on Mon Oct 6 2014 08:27:10