ITS
api.cpp File Reference
#include <api.h>
Include dependency graph for api.cpp:

Go to the source code of this file.

Functions

void empty_buffer (FILE *stream)
 
bool read_stdin (char *msg, int length, FILE *stream)
 
void format (unsigned char *msg, unsigned long v, int l)
 format Format a number in byte array. More...
 
unsigned long long int split (const unsigned char *msg, int begin, int end)
 split Extract number from byte array. More...
 
void split (const unsigned char *msg, int begin, int end, char *out)
 split Extract sub byte array from byte array More...
 
void read_opts (const unsigned char *msg, int nOptions, bool *opts)
 
void clear_string (char *s, int n)
 
void print_hexa (const unsigned char *msg, int l, FILE *stream)
 print_hexa Print a byte array. More...
 
QByteArray hexa2bin (QByteArray src)
 
QByteArray split (QByteArray src, int begin, int end)
 
QString printBitString (BIT_STRING_t b)
 printBitString Print a BIT_STRING into a QString. More...
 
int validate_unsigned_int (cfg_t *cfg, cfg_opt_t *opt)
 validate_unsigned_int Check if an option is an unsigned int More...
 
BIT_STRING_t makeBitString (int nbits, cfg_t *cfg, const char *opt_name)
 makeBitString Generate a BIT_STRING from configuration. More...
 
quint64 circAtLat (long l)
 circAtLat Compute the circumference at a latitude. More...
 
unsigned int diameter (long begin, long end, quint64 circ)
 diameter Compute the distance between two point on the same latitude. More...
 
double dist (qint32 x1, qint32 y1, qint32 x2, qint32 y2)
 dist This function calculate the euclidian distance between two points ([x1, y1], [x2, y2]). More...
 
double f (long x, long y, double lengthA, double lengthB, e_shape shape)
 f Compute the f function. More...
 
int g (double dist_r, double dist_f, double dist_fr, int angleThreshold)
 g Compute the g function. More...
 

Function Documentation

◆ circAtLat()

quint64 circAtLat ( long  l)

circAtLat Compute the circumference at a latitude.

Parameters
lThe latitude.
Returns
The circumference.

Definition at line 211 of file api.cpp.

References EARTH_RADIUS.

Referenced by GeoNet::advancedForwarding(), GeoNet::contentionBasedForwardingAlgorithm(), GeoNet::gacPacketProcessing(), GeoNet::gbcPacketProcessing(), denMessageTableForwarding::inRelevanceArea(), GeoNet::sendGAC(), and GeoNet::simpleForwardingAlgorithm().

Here is the caller graph for this function:

◆ clear_string()

void clear_string ( char *  s,
int  n 
)

Definition at line 84 of file api.cpp.

◆ diameter()

unsigned int diameter ( long  begin,
long  end,
quint64  circ 
)

diameter Compute the distance between two point on the same latitude.

Parameters
beginThe first point.
endThe seconde point.
circThe circumference at the latitude.
Returns
The distance between the two point.

Definition at line 220 of file api.cpp.

Referenced by GeoNet::advancedForwarding(), GeoNet::contentionBasedForwardingAlgorithm(), GeoNet::gacPacketProcessing(), GeoNet::gbcPacketProcessing(), denMessageTableForwarding::inRelevanceArea(), GeoNet::sendGAC(), and GeoNet::simpleForwardingAlgorithm().

Here is the caller graph for this function:

◆ dist()

double dist ( qint32  x1,
qint32  y1,
qint32  x2,
qint32  y2 
)

dist This function calculate the euclidian distance between two points ([x1, y1], [x2, y2]).

Parameters
x1X1 is the latitude of the first point.
y1Y1 is the longitude of the first point.
x2X2 is the latitude of the second point.
y2Y2 is the longitude of the second point.
Returns
Return the distance between the two points

Definition at line 228 of file api.cpp.

Referenced by GeoNet::advancedForwarding(), GeoNet::CBFUnicast(), caBasicService::checkCamGeneration(), GeoNet::contentionBasedForwardingAlgorithm(), and GeoNet::greedy().

Here is the caller graph for this function:

◆ empty_buffer()

void empty_buffer ( FILE *  stream)

Definition at line 3 of file api.cpp.

Referenced by read_stdin().

Here is the caller graph for this function:

◆ f()

double f ( long  x,
long  y,
double  lengthA,
double  lengthB,
e_shape  shape 
)

f Compute the f function.

Parameters
xThe x position of the point.
yThe y position of the point.
lengthAThe length of the semi minor axis.
lengthBThe length of the semi major axis.
shapeThe shape of the area.
Returns
  • 1 for x = 0 and y = 0 (at the center point)
  • > 0 inside the geographical area
  • 0 at the border of the geographical area
  • -1 outside the geographical area
See also
ETSI EN 302 636-4-1 v1.2.1 (2014-07)

Definition at line 236 of file api.cpp.

References shape_circle, shape_ellipse, shape_none, and shape_rectangle.

Referenced by GeoNet::advancedForwarding(), ber_tlv_tag_fwrite(), GeoNet::contentionBasedForwardingAlgorithm(), GeoNet::gacPacketProcessing(), GeoNet::gbcPacketProcessing(), denMessageTableForwarding::inRelevanceArea(), GeoNet::sendGAC(), AppDenmResultData::setFailureNotification(), and GeoNet::simpleForwardingAlgorithm().

Here is the caller graph for this function:

◆ format()

void format ( unsigned char *  msg,
unsigned long  v,
int  l 
)

format Format a number in byte array.

Parameters
msgThe byte array.
vThe number to format.
lThe intended byte number.
Warning
This function erase the previous byte array value.
Note
To put a number in msg[x], use it with &msg[x].

Definition at line 35 of file api.cpp.

Referenced by SecurityProfile_CAM::secureHeader(), and GeoNet::send().

Here is the caller graph for this function:

◆ g()

int g ( double  dist_r,
double  dist_f,
double  dist_fr,
int  angleThreshold 
)

g Compute the g function.

Parameters
dist_rDistance to the router.
dist_fDistance to the forwarder.
dist_frFSR.
angleThresholdANGLE_TH.
Returns
  • +1 for (DIST_R < DIST_F) AND (DITS_F < DIST_MAX) AND (FSR < ANGLE_TH)
  • -1 otherwise
See also
ETSI EN 302 636-4-1 v1.2.1 (2014-07)

Definition at line 272 of file api.cpp.

References itsGnDefaultMaxCommunicationRange.

Referenced by GeoNet::advancedForwarding(), constr_GenerationDeltaTime(), cpy_GenerationDeltaTime(), make_GenerationDeltaTime(), and setGenerationDeltaTime().

Here is the caller graph for this function:

◆ hexa2bin()

QByteArray hexa2bin ( QByteArray  src)

Definition at line 107 of file api.cpp.

◆ makeBitString()

BIT_STRING_t makeBitString ( int  nbits,
cfg_t *  cfg,
const char *  opt_name 
)

makeBitString Generate a BIT_STRING from configuration.

Parameters
nbitsNumber of bits needed.
cfgThe configuration.
opt_nameThe option name.
Returns
The generated BIT_STRING.

Definition at line 198 of file api.cpp.

References BIT_STRING_s::bits_unused, BIT_STRING_s::buf, and BIT_STRING_s::size.

Referenced by ParameterCAN::read(), ParameterApplication::read(), and ParameterConfiguration::read().

Here is the caller graph for this function:

◆ print_hexa()

void print_hexa ( const unsigned char *  msg,
int  l,
FILE *  stream = stdout 
)

print_hexa Print a byte array.

Parameters
msgThe byte array
lThe byte array length
stdoutThe output stream.

Definition at line 89 of file api.cpp.

References NEW_LINE, and OCTET.

Referenced by denTriggeringManagement::AppDENM_cancellation(), denReceptionManagement::AppDENM_negation(), denTriggeringManagement::AppDENM_trigger(), caReceptionManagement::decodeCam(), and UpperTester::readPendingDatagrams().

Here is the caller graph for this function:

◆ printBitString()

QString printBitString ( BIT_STRING_t  b)

printBitString Print a BIT_STRING into a QString.

Parameters
bThe BIT_STRING to print.
Returns
The printed BIT_STRING.

Definition at line 175 of file api.cpp.

References BIT_STRING_s::bits_unused, BIT_STRING_s::buf, and BIT_STRING_s::size.

Referenced by ParameterCAN::readDebug(), ParameterApplication::readDebug(), and ParameterConfiguration::readDebug().

Here is the caller graph for this function:

◆ read_opts()

void read_opts ( const unsigned char *  msg,
int  nOptions,
bool *  opts 
)

Definition at line 76 of file api.cpp.

◆ read_stdin()

bool read_stdin ( char *  msg,
int  length,
FILE *  stream 
)

Definition at line 11 of file api.cpp.

References empty_buffer().

Here is the call graph for this function:

◆ split() [1/3]

unsigned long long int split ( const unsigned char *  msg,
int  begin,
int  end 
)

split Extract number from byte array.

Parameters
msgThe byte array.
beginStart bit.
endEnd bit
Returns
The extracted number
Note
The interval is [begin ; end[.

Definition at line 47 of file api.cpp.

Referenced by Facilities::getNetworkAndTransportLayerIndication().

Here is the caller graph for this function:

◆ split() [2/3]

void split ( const unsigned char *  msg,
int  begin,
int  end,
char *  out 
)

split Extract sub byte array from byte array

Parameters
msgThe byte array.
beginStart of the value.
endEnd of the value
outThe extracted byte array
Note
The interval is [begin ; end[.

Definition at line 68 of file api.cpp.

◆ split() [3/3]

QByteArray split ( QByteArray  src,
int  begin,
int  end 
)

Definition at line 127 of file api.cpp.

◆ validate_unsigned_int()

int validate_unsigned_int ( cfg_t *  cfg,
cfg_opt_t *  opt 
)

validate_unsigned_int Check if an option is an unsigned int

Parameters
cfgConfiguration file.
optParameter list.
Returns
0 if success, -1 otherwise.

Definition at line 186 of file api.cpp.

Referenced by ParameterUpperTester::read(), ParameterGPS::read(), ParameterCAN::read(), ParameterApplication::read(), and ParameterConfiguration::read().

Here is the caller graph for this function: