summaryrefslogtreecommitdiff
path: root/mac/sar/inc/sar_mf.h
blob: 4101f151507b0806edc585e5d1ae4731f777441e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef SAR_MF_H_
#define SAR_MF_H_

/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    sar_mf.h
 * \brief   header for the Mac Frame use.
 * \ingroup mac/sar/inc
 */

#include "mac/pbproc/pbproc.h"
#include "common/defs/ethernet.h"

#define SAR_MF_MFH_SIZE 2
#define SAR_MF_ATS_SIZE 4
#define SAR_MF_ICV_SIZE 4


#define SAR_MF_MAX_SIZE (SAR_MF_MFH_SIZE + SAR_MF_ATS_SIZE + ETH_PACKET_MAX_SIZE + SAR_MF_ICV_SIZE)
#define SAR_MF_MIN_SIZE (SAR_MF_MFH_SIZE + SAR_MF_ATS_SIZE + ETH_PACKET_MIN_SIZE + SAR_MF_ICV_SIZE)

#define SAR_DIV_BY_BLK_SIZE 9

/**
 * Get the type of the MF from the PB at the data adress plus the offset
 * 
 * \param  pb The first pb containing the MF.
 * \param  offset the offset to start reading
 * \return  MF type.
 */
uint mf_get_type (pb_t * pb, uint offset);

/**
 * Test the existance of a MF at the address given by mf and return its length.
 * Will be used to determine if a complete MF is avaliable in the MFS.
 * Test if the MF start in the end of the PB by verifying the offset, if the MFH 
 * is in two PBs.
 * 
 * \param  pb The first pb containing the MF.
 * \param  offset the offset to start reading
 * \param  payload_only request to return only the payload length if true.
 *
 * \return  length of the paylod with the header and icv
 */
uint mf_get_length (pb_t *pb, uint offset, bool payload_length_only);

/**
 * Calculate the number of PB used for the MF
 * 
 * Depends of the mf_get_length function
 * 
 * \param pb the first PB where the MF starts
 * \param offset the offset of the PB where the MF starts
 * \return the quantity of PBs 
 */
uint mf_get_quantity_of_pb (pb_t *pb, uint offset);

/**
 * gets the ATS of a MF in the address pointed by the PB plus the offset
 * 
 * Depends of mf_get_type
 * 
 * \param pb the first PB where the MF starts
 * \param offset the offset of the PB where the MF starts 
 * \return  the ATS of the MF.
 */
u32 mf_get_ats (pb_t *, uint offset);

#endif /*SAR_MF_H_*/