LCOV - code coverage report
Current view: top level - AP_Networking - AP_Networking_Backend.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 13 0.0 %
Date: 2026-09-09 11:02:08 Functions: 0 1 0.0 %

          Line data    Source code
       1             : #include "AP_Networking_Backend.h"
       2             : 
       3             : #if AP_NETWORKING_ENABLED
       4             : 
       5             : #if AP_NETWORKING_CAPTURE_ENABLED
       6             : #include <AP_RTC/AP_RTC.h>
       7             : #include <AP_Filesystem/AP_Filesystem.h>
       8             : #include <lwip/tcpip.h>
       9             : #endif
      10             : 
      11             : // add a new route for an interface
      12             : // Returns true if the route is added or the route already exists
      13           0 : bool AP_Networking_Backend::add_route(uint8_t iface_idx, uint32_t dest_ip, uint8_t mask_len)
      14             : {
      15           0 :     const uint32_t netmask = frontend.convert_netmask_bitcount_to_ip(mask_len);
      16           0 :     for (uint8_t i=0; i<AP_NETWORKING_MAX_ROUTES; i++) {
      17           0 :         auto &r = routes[i];
      18           0 :         if (r.enabled && r.iface_idx == iface_idx && r.dest_ip == dest_ip && r.netmask == netmask) {
      19             :             // already have it
      20           0 :             return true;
      21             :         }
      22           0 :         if (!r.enabled) {
      23           0 :             r.iface_idx = iface_idx;
      24           0 :             r.dest_ip = dest_ip;
      25           0 :             r.netmask = netmask;
      26           0 :             r.enabled = true;
      27           0 :             return true;
      28             :         }
      29             :     }
      30           0 :     return false;
      31             : }
      32             : 
      33             : #if AP_NETWORKING_CAPTURE_ENABLED
      34             : 
      35             : /*
      36             :   write a header for the start of a new capture packet
      37             :   capture.sem should be taken before the header is output
      38             :   and held for the whole packet
      39             :   note that len should include the direction byte for PPP data
      40             : 
      41             :   caller must have checked that capture.fd != -1
      42             : */
      43             : void AP_Networking_Backend::capture_header(int fd, uint32_t len)
      44             : {
      45             :     uint64_t utc_usec = 0;
      46             : #if AP_RTC_ENABLED
      47             :     AP::rtc().get_utc_usec(utc_usec);
      48             : #endif
      49             :     if (utc_usec == 0) {
      50             :         utc_usec = AP_HAL::micros64();
      51             :     }
      52             :     const struct pcaprec_hdr {
      53             :         uint32_t ts_sec;
      54             :         uint32_t ts_usec;
      55             :         uint32_t incl_len;
      56             :         uint32_t orig_len;
      57             :     } rec {
      58             :         .ts_sec = uint32_t(utc_usec / 1000000ULL),
      59             :         .ts_usec = uint32_t(utc_usec % 1000000ULL),
      60             :         .incl_len = len,
      61             :         .orig_len = len
      62             :     };
      63             : 
      64             :     AP::FS().write(fd, (const void *)&rec, sizeof(rec));
      65             : }
      66             : #endif // AP_NETWORKING_CAPTURE_ENABLED
      67             : 
      68             : #endif // AP_NETWORKING_ENABLED

Generated by: LCOV version 1.14