diff --git a/libraries/GCS_MAVLink/GCS.h b/libraries/GCS_MAVLink/GCS.h index 459add9b05..652dd6fea0 100644 --- a/libraries/GCS_MAVLink/GCS.h +++ b/libraries/GCS_MAVLink/GCS.h @@ -129,6 +129,7 @@ public: AP_HAL::UARTDriver *get_uart() { return _port; } virtual uint8_t sysid_my_gcs() const = 0; + virtual bool sysid_enforce() const { return false; } static const struct AP_Param::GroupInfo var_info[]; @@ -278,7 +279,7 @@ protected: // overridable method to check for packet acceptance. Allows for // enforcement of GCS sysid - virtual bool accept_packet(const mavlink_status_t &status, mavlink_message_t &msg) { return true; } + bool accept_packet(const mavlink_status_t &status, mavlink_message_t &msg); virtual AP_Rally *get_rally() const = 0; virtual AP_AdvancedFailsafe *get_advanced_failsafe() const { return nullptr; }; virtual AP_VisualOdom *get_visual_odom() const { return nullptr; } diff --git a/libraries/GCS_MAVLink/GCS_Common.cpp b/libraries/GCS_MAVLink/GCS_Common.cpp index 4171f09cab..3a566ef8e7 100644 --- a/libraries/GCS_MAVLink/GCS_Common.cpp +++ b/libraries/GCS_MAVLink/GCS_Common.cpp @@ -3945,6 +3945,24 @@ uint32_t GCS_MAVLINK::correct_offboard_timestamp_usec_to_ms(uint64_t offboard_us return corrected_us / 1000U; } +/* + return true if we will accept this packet. Used to implement SYSID_ENFORCE + */ +bool GCS_MAVLINK::accept_packet(const mavlink_status_t &status, + mavlink_message_t &msg) +{ + if (!sysid_enforce()) { + return true; + } + if (msg.msgid == MAVLINK_MSG_ID_RADIO || + msg.msgid == MAVLINK_MSG_ID_RADIO_STATUS) { + return true; + } + + return (msg.sysid == sysid_my_gcs()); +} + + GCS &gcs() { return *GCS::instance();