diff options
Diffstat (limited to 'decoders/ftp/ftp_decoder_hash.h')
| -rw-r--r-- | decoders/ftp/ftp_decoder_hash.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/decoders/ftp/ftp_decoder_hash.h b/decoders/ftp/ftp_decoder_hash.h new file mode 100644 index 0000000..f8f5468 --- /dev/null +++ b/decoders/ftp/ftp_decoder_hash.h @@ -0,0 +1,54 @@ +#pragma once +#include <stddef.h> +#include <arpa/inet.h> +#ifdef __cplusplus +extern "C" +{ +#endif +#include "stellar/session.h" +#include "stellar/log.h" +#include "stellar/module.h" +#include "stellar/mq.h" +#include "uthash/uthash.h" +#ifdef __cplusplus +} +#endif + +#define FTP_HASH_STRING_BUF_SIZE (256) +#define FTP_HASH_ITEM_TIMEOUT (30) // seconds + +struct ftp_session_addr /* network order */ +{ + int af_inet; // AF_INET or AF_INET6 + uint16_t sport; + uint16_t dport; + union + { + uint32_t saddr4; + struct in6_addr saddr6; + }; + union + { + uint32_t daddr4; + struct in6_addr daddr6; + }; +} __attribute__((packed)); +typedef struct ftp_session_addr ftp_hash_key_t; + +struct ftp_datalink_htable +{ + UT_hash_handle hh; + struct ftp_datalink_htable *next, *prev; // for timeout fifo list + ftp_hash_key_t hkey; + time_t insert_htable_time; + struct ftp_decoder_exdata *ftp_ext; // data link exdata +}; + +int ftp_hash_add(const ftp_hash_key_t *key, u_int32_t key_len, struct ftp_datalink_htable *new_item); +struct ftp_datalink_htable *ftp_hash_search(const ftp_hash_key_t *key); +void ftp_hash_del(const ftp_hash_key_t *key); +void ftp_session_get_addr(const struct session *sess, struct ftp_session_addr *addr); +void ftp_make_hkey_v4(ftp_hash_key_t *keyv4, uint32_t sip_net, uint32_t dip_net, uint16_t dip_port_net); +void ftp_make_hkey_v6(ftp_hash_key_t *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_session_addr *hkey); +void ftp_session_get_addr(const struct session *sess, struct ftp_session_addr *addr);
\ No newline at end of file |
