rscamper 0.2.2

Rust interface to scamper network measurement tool
Documentation
// rscamper - Rust FFI bindings for scamper_http.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, c_int, size_t, timeval};
use super::scamper_addr::ScamperAddrT;
use super::scamper_list::{ScamperListT, ScamperCycleT};

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

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

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

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

pub const SCAMPER_HTTP_STOP_NONE:     u8 = 0;
pub const SCAMPER_HTTP_STOP_HALTED:   u8 = 1;
pub const SCAMPER_HTTP_STOP_NOCONN:   u8 = 2;
pub const SCAMPER_HTTP_STOP_DONE:     u8 = 3;
pub const SCAMPER_HTTP_STOP_ERROR:    u8 = 4;
pub const SCAMPER_HTTP_STOP_TIMEOUT:  u8 = 5;
pub const SCAMPER_HTTP_STOP_INSECURE: u8 = 6;

unsafe extern "C" {
    pub fn scamper_http_free(http: *mut ScamperHttpT);

    pub fn scamper_http_list_get(http: *const ScamperHttpT) -> *mut ScamperListT;
    pub fn scamper_http_cycle_get(http: *const ScamperHttpT) -> *mut ScamperCycleT;
    pub fn scamper_http_userid_get(http: *const ScamperHttpT) -> u32;
    pub fn scamper_http_src_get(http: *const ScamperHttpT) -> *mut ScamperAddrT;
    pub fn scamper_http_dst_get(http: *const ScamperHttpT) -> *mut ScamperAddrT;
    pub fn scamper_http_sport_get(http: *const ScamperHttpT) -> u16;
    pub fn scamper_http_dport_get(http: *const ScamperHttpT) -> u16;
    pub fn scamper_http_errmsg_get(http: *const ScamperHttpT) -> *const c_char;
    pub fn scamper_http_start_get(http: *const ScamperHttpT) -> *const timeval;
    pub fn scamper_http_stop_get(http: *const ScamperHttpT) -> u8;
    pub fn scamper_http_stop_tostr(
        http: *const ScamperHttpT,
        buf: *mut c_char,
        len: size_t,
    ) -> *mut c_char;
    pub fn scamper_http_type_get(http: *const ScamperHttpT) -> u8;
    pub fn scamper_http_type_tostr(
        http: *const ScamperHttpT,
        buf: *mut c_char,
        len: size_t,
    ) -> *mut c_char;
    pub fn scamper_http_host_get(http: *const ScamperHttpT) -> *const c_char;
    pub fn scamper_http_file_get(http: *const ScamperHttpT) -> *const c_char;

    pub fn scamper_http_bufc_get(http: *const ScamperHttpT) -> u32;
    pub fn scamper_http_buf_get(http: *const ScamperHttpT, i: u32) -> *mut ScamperHttpBufT;
    pub fn scamper_http_buf_free(htb: *mut ScamperHttpBufT);
    pub fn scamper_http_buf_use(htb: *mut ScamperHttpBufT) -> *mut ScamperHttpBufT;
    pub fn scamper_http_buf_tv_get(htb: *const ScamperHttpBufT) -> *const timeval;
    pub fn scamper_http_buf_data_get(htb: *const ScamperHttpBufT) -> *const u8;
    pub fn scamper_http_buf_len_get(htb: *const ScamperHttpBufT) -> u16;
    pub fn scamper_http_buf_is_tx(htb: *const ScamperHttpBufT) -> c_int;
    pub fn scamper_http_buf_is_rx(htb: *const ScamperHttpBufT) -> c_int;
    pub fn scamper_http_buf_is_tls(htb: *const ScamperHttpBufT) -> c_int;
    pub fn scamper_http_buf_is_hdr(htb: *const ScamperHttpBufT) -> c_int;
    pub fn scamper_http_buf_is_data(htb: *const ScamperHttpBufT) -> c_int;
    pub fn scamper_http_buf_dir_tostr(
        htb: *const ScamperHttpBufT,
        buf: *mut c_char,
        len: size_t,
    ) -> *mut c_char;
    pub fn scamper_http_buf_type_tostr(
        htb: *const ScamperHttpBufT,
        buf: *mut c_char,
        len: size_t,
    ) -> *mut c_char;

    pub fn scamper_http_status_code_get(http: *const ScamperHttpT, status: *mut u16) -> c_int;
    pub fn scamper_http_url_len_get(http: *const ScamperHttpT, len: *mut size_t) -> c_int;
    pub fn scamper_http_url_get(http: *const ScamperHttpT, buf: *mut c_char, len: size_t) -> c_int;
    pub fn scamper_http_rx_hdr_len_get(http: *const ScamperHttpT, len: *mut size_t) -> c_int;
    pub fn scamper_http_rx_hdr_get(
        http: *const ScamperHttpT,
        buf: *mut u8,
        len: size_t,
    ) -> c_int;
    pub fn scamper_http_rx_data_len_get(http: *const ScamperHttpT, len: *mut size_t) -> c_int;
    pub fn scamper_http_rx_data_get(
        http: *const ScamperHttpT,
        buf: *mut u8,
        len: size_t,
    ) -> c_int;
    pub fn scamper_http_tx_hdr_len_get(http: *const ScamperHttpT, len: *mut size_t) -> c_int;
    pub fn scamper_http_tx_hdr_get(
        http: *const ScamperHttpT,
        buf: *mut u8,
        len: size_t,
    ) -> c_int;

    pub fn scamper_http_tx_hdr_name_get(
        http: *const ScamperHttpT,
        name: *const c_char,
        value: *mut *mut c_char,
    ) -> c_int;
    pub fn scamper_http_rx_hdr_name_get(
        http: *const ScamperHttpT,
        name: *const c_char,
        value: *mut *mut c_char,
    ) -> c_int;

    pub fn scamper_http_rx_hdr_fields_get(
        http: *const ScamperHttpT,
    ) -> *mut ScamperHttpHdrFieldsT;
    pub fn scamper_http_tx_hdr_fields_get(
        http: *const ScamperHttpT,
    ) -> *mut ScamperHttpHdrFieldsT;

    pub fn scamper_http_hdr_fields_free(htfs: *mut ScamperHttpHdrFieldsT);
    pub fn scamper_http_hdr_fields_count_get(htfs: *const ScamperHttpHdrFieldsT) -> size_t;
    pub fn scamper_http_hdr_fields_get(
        htfs: *const ScamperHttpHdrFieldsT,
        x: size_t,
    ) -> *mut ScamperHttpHdrFieldT;
    pub fn scamper_http_hdr_field_name_get(htf: *const ScamperHttpHdrFieldT) -> *const c_char;
    pub fn scamper_http_hdr_field_value_get(htf: *const ScamperHttpHdrFieldT) -> *const c_char;
}