Skip to content

Commit

Permalink
facilities: add support for Release 2 CAMs
Browse files Browse the repository at this point in the history
  • Loading branch information
riebl committed Oct 17, 2024
1 parent 9ca0d3b commit a272104
Show file tree
Hide file tree
Showing 9 changed files with 740 additions and 473 deletions.
13 changes: 13 additions & 0 deletions vanetza/asn1/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM alpine:3 AS base

FROM base AS build
ARG ASN1C_REPO=https://github.com/mouse07410/asn1c.git
ARG ASN1C_VERSION=18e5650
RUN apk add --no-cache autoconf automake bison build-base flex gcc git libtool
RUN git clone $ASN1C_REPO /asn1c-source && cd /asn1c-source && git checkout ${ASN1C_VERSION}
WORKDIR /asn1c-source
RUN autoreconf -iv && ./configure --prefix /asn1c && make -j $(nproc) install

FROM base AS runtime
ENV ASN1C_FLAGS="-fcompound-names -fincludes-quoted -no-gen-example"
COPY --from=build /asn1c /asn1c
477 changes: 33 additions & 444 deletions vanetza/facilities/cam_functions.cpp

Large diffs are not rendered by default.

38 changes: 29 additions & 9 deletions vanetza/facilities/cam_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@

#include <vanetza/asn1/its/AltitudeConfidence.h>
#include <vanetza/asn1/its/AltitudeValue.h>
#include <vanetza/asn1/its/Heading.h>
#include <vanetza/asn1/its/ReferencePosition.h>
#include <vanetza/common/position_fix.hpp>
#include <vanetza/security/cam_ssp.hpp>
#include <vanetza/units/angle.hpp>
#include <vanetza/units/length.hpp>

// forward declaration of asn1c generated struct
struct BasicVehicleContainerLowFrequency;
struct Heading;
struct ReferencePosition;
struct Vanetza_ITS2_BasicVehicleContainerLowFrequency;
struct Vanetza_ITS2_Heading;
struct Vanetza_ITS2_ReferencePosition;

namespace vanetza
{

// forward declaration of CAM message wrapper
namespace asn1 { class Cam; }
// forward declaration of CAM message wrappers
namespace asn1 {
namespace r1 { class Cam; }
namespace r2 { class Cam; }
}

namespace facilities
{
Expand All @@ -30,6 +36,7 @@ class PathHistory;
* \param ASN.1 CAM container (destination)
*/
void copy(const PathHistory&, BasicVehicleContainerLowFrequency&);
void copy(const PathHistory&, Vanetza_ITS2_BasicVehicleContainerLowFrequency&);

/**
* Check if difference of two given heading values is within a limit
Expand All @@ -40,6 +47,8 @@ void copy(const PathHistory&, BasicVehicleContainerLowFrequency&);
*/
bool similar_heading(const Heading& a, const Heading& b, units::Angle limit);
bool similar_heading(const Heading& a, units::Angle b, units::Angle limit);
bool similar_heading(const Vanetza_ITS2_Heading& a, const Vanetza_ITS2_Heading&b, units::Angle limit);
bool similar_heading(const Vanetza_ITS2_Heading& a, units::Angle b, units::Angle limit);
bool similar_heading(units::Angle a, units::Angle b, units::Angle limit);

/**
Expand All @@ -48,28 +57,37 @@ bool similar_heading(units::Angle a, units::Angle b, units::Angle limit);
* \param b another position
* \return distance between given positions (or NaN if some position is unavailable)
*/
units::Length distance(const ReferencePosition_t& a, const ReferencePosition_t& b);
units::Length distance(const ReferencePosition_t& a, units::GeoAngle lat, units::GeoAngle lon);
units::Length distance(const ReferencePosition& a, const ReferencePosition& b);
units::Length distance(const ReferencePosition& a, units::GeoAngle lat, units::GeoAngle lon);
units::Length distance(const Vanetza_ITS2_ReferencePosition& a, const Vanetza_ITS2_ReferencePosition& b);
units::Length distance(const Vanetza_ITS2_ReferencePosition& a, units::GeoAngle lat, units::GeoAngle lon);

/**
* Check if ASN.1 data element indicates unavailable value
* \return true if value is available
*/
bool is_available(const Heading&);
bool is_available(const ReferencePosition_t&);
bool is_available(const Vanetza_ITS2_Heading&);
bool is_available(const ReferencePosition&);
bool is_available(const Vanetza_ITS2_ReferencePosition&);

/**
* Copy position information into a ReferencePosition structure from CDD
*/
void copy(const PositionFix&, ReferencePosition&);
void copy(const PositionFix&, Vanetza_ITS2_ReferencePosition&);

/**
* Convert altitude to AltitudeValue from CDD
*
* It is safe to cast AltitudeValue_t to Vanetza_ITS2_AltitudeValue_t.
*/
AltitudeValue_t to_altitude_value(units::Length);

/**
* Convert altitude confidence to AltitudeConfidence from CDD
*
* It is safe to cast AltitudeConfidence_t to Vanetza_ITS2_AltitudeConfidence_t.
*/
AltitudeConfidence_t to_altitude_confidence(units::Length);

Expand All @@ -79,7 +97,8 @@ AltitudeConfidence_t to_altitude_confidence(units::Length);
* \param ssp CA service specific permissions
* \return true if no forbidden data elements are included
*/
bool check_service_specific_permissions(const asn1::Cam& cam, security::CamPermissions ssp);
bool check_service_specific_permissions(const asn1::r1::Cam& cam, security::CamPermissions ssp);
bool check_service_specific_permissions(const asn1::r2::Cam& cam, security::CamPermissions ssp);

/**
* Print CAM content with indentation of nested fields
Expand All @@ -91,7 +110,8 @@ bool check_service_specific_permissions(const asn1::Cam& cam, security::CamPermi
* This function is an idea of Erik de Britto e Silva (erikbritto@github)
* from University of Antwerp - [email protected]
*/
void print_indented(std::ostream& os, const asn1::Cam& cam, const std::string& indent = "\t", unsigned start = 0);
void print_indented(std::ostream& os, const asn1::r1::Cam& cam, const std::string& indent = "\t", unsigned start = 0);
void print_indented(std::ostream& os, const asn1::r2::Cam& cam, const std::string& indent = "\t", unsigned start = 0);

} // namespace facilities
} // namespace vanetza
Expand Down
Loading

0 comments on commit a272104

Please sign in to comment.