TSG-13347 Steering Service开发流表
This commit is contained in:
50
common/include/stream_table.h
Normal file
50
common/include/stream_table.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef _STREAM_TABLE_H
|
||||
#define _STREAM_TABLE_H
|
||||
|
||||
#ifdef __cpluscplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "uthash.h"
|
||||
#include "stream_addr.h"
|
||||
|
||||
// Note: key_streamaddr must be initialized by memset(0) before use !!!
|
||||
|
||||
typedef void fn_free_cb(void *args);
|
||||
|
||||
struct stream_node
|
||||
{
|
||||
uint64_t key_streamid; /* first key */
|
||||
struct stream_addr key_streamaddr; /* second key */
|
||||
|
||||
void *val_data;
|
||||
fn_free_cb *val_freecb;
|
||||
|
||||
UT_hash_handle hh1; /* handle for first hash table */
|
||||
UT_hash_handle hh2; /* handle for second hash table */
|
||||
};
|
||||
|
||||
struct stream_table;
|
||||
|
||||
struct stream_table *stream_table_create();
|
||||
void stream_table_destory(struct stream_table *table);
|
||||
|
||||
// key_streamaddr : deep copy
|
||||
// val_data : shallow copy (malloc by user, free by val_freecb)
|
||||
int stream_table_insert(struct stream_table *table, uint64_t key_streamid, const struct stream_addr *key_streamaddr, void *val_data, const fn_free_cb *val_freecb);
|
||||
|
||||
int stream_table_delete_by_streamid(struct stream_table *table, uint64_t key_streamid);
|
||||
int stream_table_delete_by_streamaddr(struct stream_table *table, const struct stream_addr *key_streamaddr);
|
||||
|
||||
struct stream_node *stream_table_search_by_streamid(struct stream_table *table, uint64_t key_streamid);
|
||||
struct stream_node *stream_table_search_by_streamaddr(struct stream_table *table, const struct stream_addr *key_streamaddr);
|
||||
|
||||
#ifdef __cpluscplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user