This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tango-tsg-service-chaining-…/common/include/session_table.h

44 lines
1.2 KiB
C
Raw Permalink Normal View History

#ifndef _SESSION_TABLE_H
#define _SESSION_TABLE_H
2024-07-16 17:25:55 +08:00
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdint.h>
#include <sys/types.h>
2023-11-13 16:56:31 +08:00
#include "tuple.h"
typedef void fn_free_cb(void *args);
struct session_table;
struct session_table *session_table_create();
void session_table_destory(struct session_table *table);
void session_table_reset(struct session_table *table);
uint64_t session_table_count(struct session_table *table);
// addr : deep copy
// value : shallow copy (malloc by user, free by free_cb)
// Note : addr must be initialized by memset(0) before use !!!
// return 0 : suceess
// return -1 : key exists
int session_table_insert(struct session_table *table, uint64_t id, const struct four_tuple *addr, void *value, const fn_free_cb *free_cb);
// return 0 : success
// return -1 : key not exists
int session_table_delete_by_id(struct session_table *table, uint64_t id);
int session_table_delete_by_addr(struct session_table *table, const struct four_tuple *addr);
// return NULL : key not exists
// return value : success
void *session_table_search_by_id(struct session_table *table, uint64_t id);
void *session_table_search_by_addr(struct session_table *table, const struct four_tuple *addr);
2024-07-16 17:25:55 +08:00
#ifdef __cplusplus
}
#endif
#endif