rscamper 0.2.2

Rust interface to scamper network measurement tool
Documentation
// rscamper - Rust FFI bindings for scamper_owamp.h
//
// Copyright (C) 2026 Dimitrios Giakatos
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 3.

use libc::{c_char, size_t, timeval};
use super::scamper_addr::ScamperAddrT;
use super::scamper_list::{ScamperListT, ScamperCycleT};

#[repr(C)]
pub struct ScamperOwampT {
    _opaque: [u8; 0],
}

#[repr(C)]
pub struct ScamperOwampSchedT {
    _opaque: [u8; 0],
}

#[repr(C)]
pub struct ScamperOwampTxT {
    _opaque: [u8; 0],
}

#[repr(C)]
pub struct ScamperOwampRxT {
    _opaque: [u8; 0],
}

pub const SCAMPER_OWAMP_RESULT_NONE:        u8 = 0;
pub const SCAMPER_OWAMP_RESULT_DONE:        u8 = 1;
pub const SCAMPER_OWAMP_RESULT_HALTED:      u8 = 2;
pub const SCAMPER_OWAMP_RESULT_ERROR:       u8 = 3;
pub const SCAMPER_OWAMP_RESULT_NOCONN:      u8 = 4;
pub const SCAMPER_OWAMP_RESULT_NOTACCEPTED: u8 = 5;
pub const SCAMPER_OWAMP_RESULT_NOMODE:      u8 = 6;
pub const SCAMPER_OWAMP_RESULT_TIMEOUT:     u8 = 7;

pub const SCAMPER_OWAMP_DIR_TX: u8 = 0;
pub const SCAMPER_OWAMP_DIR_RX: u8 = 1;

pub const SCAMPER_OWAMP_FLAG_ZERO: u16 = 0;

pub const SCAMPER_OWAMP_TX_FLAG_NOTSENT: u8 = 0x01;
pub const SCAMPER_OWAMP_TX_FLAG_ERREST:  u8 = 0x02;

pub const SCAMPER_OWAMP_RX_FLAG_DSCP:   u8 = 0x01;
pub const SCAMPER_OWAMP_RX_FLAG_TTL:    u8 = 0x02;
pub const SCAMPER_OWAMP_RX_FLAG_ERREST: u8 = 0x04;

pub const SCAMPER_OWAMP_SCHED_TYPE_FIXED: u8 = 0;
pub const SCAMPER_OWAMP_SCHED_TYPE_EXP:   u8 = 1;

unsafe extern "C" {
    pub fn scamper_owamp_tojson(
        owamp: *const ScamperOwampT,
        len: *mut size_t,
    ) -> *mut c_char;
    pub fn scamper_owamp_free(owamp: *mut ScamperOwampT);
    pub fn scamper_owamp_list_get(owamp: *const ScamperOwampT) -> *mut ScamperListT;
    pub fn scamper_owamp_cycle_get(owamp: *const ScamperOwampT) -> *mut ScamperCycleT;
    pub fn scamper_owamp_userid_get(owamp: *const ScamperOwampT) -> u32;
    pub fn scamper_owamp_dst_get(owamp: *const ScamperOwampT) -> *mut ScamperAddrT;
    pub fn scamper_owamp_src_get(owamp: *const ScamperOwampT) -> *mut ScamperAddrT;
    pub fn scamper_owamp_dport_get(owamp: *const ScamperOwampT) -> u16;
    pub fn scamper_owamp_flags_get(owamp: *const ScamperOwampT) -> u16;
    pub fn scamper_owamp_start_get(owamp: *const ScamperOwampT) -> *const timeval;
    pub fn scamper_owamp_startat_get(owamp: *const ScamperOwampT) -> *const timeval;
    pub fn scamper_owamp_wait_timeout_get(owamp: *const ScamperOwampT) -> *const timeval;
    pub fn scamper_owamp_schedc_get(owamp: *const ScamperOwampT) -> u32;
    pub fn scamper_owamp_sched_get(
        owamp: *const ScamperOwampT,
        i: u32,
    ) -> *mut ScamperOwampSchedT;
    pub fn scamper_owamp_attempts_get(owamp: *const ScamperOwampT) -> u32;
    pub fn scamper_owamp_pktsize_get(owamp: *const ScamperOwampT) -> u16;
    pub fn scamper_owamp_dir_get(owamp: *const ScamperOwampT) -> u8;
    pub fn scamper_owamp_dir_tostr(
        owamp: *const ScamperOwampT,
        buf: *mut c_char,
        len: size_t,
    ) -> *mut c_char;
    pub fn scamper_owamp_dscp_get(owamp: *const ScamperOwampT) -> u8;
    pub fn scamper_owamp_ttl_get(owamp: *const ScamperOwampT) -> u8;
    pub fn scamper_owamp_hsrtt_get(owamp: *const ScamperOwampT) -> *const timeval;
    pub fn scamper_owamp_result_get(owamp: *const ScamperOwampT) -> u8;
    pub fn scamper_owamp_result_tostr(
        owamp: *const ScamperOwampT,
        buf: *mut c_char,
        len: size_t,
    ) -> *mut c_char;
    pub fn scamper_owamp_errmsg_get(owamp: *const ScamperOwampT) -> *mut c_char;
    pub fn scamper_owamp_udp_sport_get(owamp: *const ScamperOwampT) -> u16;
    pub fn scamper_owamp_udp_dport_get(owamp: *const ScamperOwampT) -> u16;
    pub fn scamper_owamp_txc_get(owamp: *const ScamperOwampT) -> u32;
    pub fn scamper_owamp_tx_get(owamp: *const ScamperOwampT, i: u32) -> *mut ScamperOwampTxT;

    pub fn scamper_owamp_tx_use(tx: *mut ScamperOwampTxT) -> *mut ScamperOwampTxT;
    pub fn scamper_owamp_tx_free(tx: *mut ScamperOwampTxT);
    pub fn scamper_owamp_tx_sched_get(tx: *const ScamperOwampTxT) -> *const timeval;
    pub fn scamper_owamp_tx_stamp_get(tx: *const ScamperOwampTxT) -> *const timeval;
    pub fn scamper_owamp_tx_seq_get(tx: *const ScamperOwampTxT) -> u32;
    pub fn scamper_owamp_tx_errest_get(tx: *const ScamperOwampTxT) -> u16;
    pub fn scamper_owamp_tx_flags_get(tx: *const ScamperOwampTxT) -> u16;
    pub fn scamper_owamp_tx_rxc_get(tx: *const ScamperOwampTxT) -> u8;
    pub fn scamper_owamp_tx_rx_get(
        tx: *const ScamperOwampTxT,
        i: u8,
    ) -> *mut ScamperOwampRxT;

    pub fn scamper_owamp_rx_use(rx: *mut ScamperOwampRxT) -> *mut ScamperOwampRxT;
    pub fn scamper_owamp_rx_free(rx: *mut ScamperOwampRxT);
    pub fn scamper_owamp_rx_stamp_get(rx: *const ScamperOwampRxT) -> *const timeval;
    pub fn scamper_owamp_rx_errest_get(rx: *const ScamperOwampRxT) -> u16;
    pub fn scamper_owamp_rx_flags_get(rx: *const ScamperOwampRxT) -> u8;
    pub fn scamper_owamp_rx_dscp_get(rx: *const ScamperOwampRxT) -> u8;
    pub fn scamper_owamp_rx_ttl_get(rx: *const ScamperOwampRxT) -> u8;

    pub fn scamper_owamp_sched_use(sched: *mut ScamperOwampSchedT) -> *mut ScamperOwampSchedT;
    pub fn scamper_owamp_sched_free(sched: *mut ScamperOwampSchedT);
    pub fn scamper_owamp_sched_type_tostr(
        sched: *const ScamperOwampSchedT,
        buf: *mut c_char,
        len: size_t,
    ) -> *mut c_char;
    pub fn scamper_owamp_sched_type_get(sched: *const ScamperOwampSchedT) -> u8;
    pub fn scamper_owamp_sched_tv_get(sched: *const ScamperOwampSchedT) -> *const timeval;
}