From 2ee4770462185daec28e8bb424c8e188e194c996 Mon Sep 17 00:00:00 2001 From: lijia Date: Mon, 22 Jul 2024 10:34:56 +0800 Subject: Initial commit --- src/ftp_decoder_hash.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/ftp_decoder_hash.h (limited to 'src/ftp_decoder_hash.h') diff --git a/src/ftp_decoder_hash.h b/src/ftp_decoder_hash.h new file mode 100644 index 0000000..21a702f --- /dev/null +++ b/src/ftp_decoder_hash.h @@ -0,0 +1,38 @@ +#pragma once +#ifdef __cplusplus +extern "C" +{ +#endif +#include +#include +#include +#include +#ifdef __cplusplus +} +#endif +#include +#include + +/* + for ftp passive mode, source port is random, so we can't use tuple4 to identify data link. + so always set source port to 0! +*/ +struct ftp_link_key +{ + enum session_addr_type addr_type; + int __pad__; + union + { + struct session_addr_ipv4 tuplev4; + struct session_addr_ipv6 tuplev6; + }; +} __attribute__((packed)); + +int ftp_hash_add(void *handle, const void *key, u_int32_t key_len, void *value); +void *ftp_hash_search(void *handle, const struct ftp_link_key *hkey); +void ftp_hash_del(void *handle, const struct ftp_link_key *hkey); +void ftp_declare_datalink_free(void *data); +void ftp_make_hkey_v4(struct session_addr_ipv4 *keyv4, uint32_t sip_net, uint32_t dip_net, uint16_t dip_port_net); +void ftp_make_hkey_v6(struct session_addr_ipv6 *keyv6, const struct in6_addr *sip, const struct in6_addr *dip, uint16_t dip_port_net); +const char *ftp_hash_key_to_str(const struct ftp_link_key *hkey); +int ftp_build_hashkey_from_session(struct session *sess, struct ftp_link_key *hkey); \ No newline at end of file -- cgit v1.2.3