mirror of https://github.com/OISF/suricata
rust: integrate bindgen to generate Rust bindings to C
Bindgen works by processing a header file which includes all other header files it should generate bindings for. For this I've created bindgen.h which just includes app-layer-protos.h for now as an example. These bindings are then generated and saved in the "suricata-sys" crate and become availale as "suricata_sys::sys". Ticket: #7341pull/12590/head
parent
8f22e55678
commit
21ccc4f307
@ -0,0 +1,54 @@
|
|||||||
|
#[repr(u32)]
|
||||||
|
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||||
|
pub enum AppProtoEnum {
|
||||||
|
ALPROTO_UNKNOWN = 0,
|
||||||
|
ALPROTO_FAILED = 1,
|
||||||
|
ALPROTO_HTTP1 = 2,
|
||||||
|
ALPROTO_FTP = 3,
|
||||||
|
ALPROTO_SMTP = 4,
|
||||||
|
ALPROTO_TLS = 5,
|
||||||
|
ALPROTO_SSH = 6,
|
||||||
|
ALPROTO_IMAP = 7,
|
||||||
|
ALPROTO_JABBER = 8,
|
||||||
|
ALPROTO_SMB = 9,
|
||||||
|
ALPROTO_DCERPC = 10,
|
||||||
|
ALPROTO_IRC = 11,
|
||||||
|
ALPROTO_DNS = 12,
|
||||||
|
ALPROTO_MODBUS = 13,
|
||||||
|
ALPROTO_ENIP = 14,
|
||||||
|
ALPROTO_DNP3 = 15,
|
||||||
|
ALPROTO_NFS = 16,
|
||||||
|
ALPROTO_NTP = 17,
|
||||||
|
ALPROTO_FTPDATA = 18,
|
||||||
|
ALPROTO_TFTP = 19,
|
||||||
|
ALPROTO_IKE = 20,
|
||||||
|
ALPROTO_KRB5 = 21,
|
||||||
|
ALPROTO_QUIC = 22,
|
||||||
|
ALPROTO_DHCP = 23,
|
||||||
|
ALPROTO_SNMP = 24,
|
||||||
|
ALPROTO_SIP = 25,
|
||||||
|
ALPROTO_RFB = 26,
|
||||||
|
ALPROTO_MQTT = 27,
|
||||||
|
ALPROTO_PGSQL = 28,
|
||||||
|
ALPROTO_TELNET = 29,
|
||||||
|
ALPROTO_WEBSOCKET = 30,
|
||||||
|
ALPROTO_LDAP = 31,
|
||||||
|
ALPROTO_DOH2 = 32,
|
||||||
|
ALPROTO_TEMPLATE = 33,
|
||||||
|
ALPROTO_RDP = 34,
|
||||||
|
ALPROTO_HTTP2 = 35,
|
||||||
|
ALPROTO_BITTORRENT_DHT = 36,
|
||||||
|
ALPROTO_POP3 = 37,
|
||||||
|
ALPROTO_HTTP = 38,
|
||||||
|
ALPROTO_MAX_STATIC = 39,
|
||||||
|
}
|
||||||
|
pub type AppProto = u16;
|
||||||
|
extern "C" {
|
||||||
|
#[doc = " \\brief Maps the ALPROTO_*, to its string equivalent.\n\n \\param alproto App layer protocol id.\n\n \\retval String equivalent for the alproto."]
|
||||||
|
pub fn AppProtoToString(alproto: AppProto) -> *const ::std::os::raw::c_char;
|
||||||
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn AppProtoRegisterProtoString(
|
||||||
|
alproto: AppProto, proto_name: *const ::std::os::raw::c_char,
|
||||||
|
);
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
/* Copyright (C) 2025 Open Information Security Foundation
|
||||||
|
*
|
||||||
|
* You can copy, redistribute or modify this Program under the terms of
|
||||||
|
* the GNU General Public License version 2 as published by the Free
|
||||||
|
* Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* version 2 along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
|
* 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file Input to bindgen to generate Rust bindings.
|
||||||
|
*
|
||||||
|
* This file should include every header that should have Rust
|
||||||
|
* bindings generated for it. It is then used by bindgen to generate
|
||||||
|
* the Rust bindings.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SURICATA_BINDGEN_H
|
||||||
|
#define SURICATA_BINDGEN_H
|
||||||
|
|
||||||
|
#include "stdint.h"
|
||||||
|
#include "stdbool.h"
|
||||||
|
|
||||||
|
#include "app-layer-protos.h"
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue