diff options
Diffstat (limited to 'hicn-light/src/hicn/core/pit.h')
-rw-r--r-- | hicn-light/src/hicn/core/pit.h | 71 |
1 files changed, 50 insertions, 21 deletions
diff --git a/hicn-light/src/hicn/core/pit.h b/hicn-light/src/hicn/core/pit.h index 1aedcfab9..5607827fe 100644 --- a/hicn-light/src/hicn/core/pit.h +++ b/hicn-light/src/hicn/core/pit.h @@ -1,7 +1,26 @@ +/* + * Copyright (c) 2017-2020 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file pit.h + * @brief hICN Pending Interest Table (PIT) + */ + #ifndef HICNLIGHT_PIT_H #define HICNLIGHT_PIT_H - #include <hicn/base/khash.h> #include <hicn/core/nexthops.h> #include <hicn/core/msgbuf.h> @@ -10,14 +29,14 @@ #include <hicn/core/ticks.h> typedef struct { - msgbuf_t * msgbuf; + off_t msgbuf_id; nexthops_t ingressIdSet; nexthops_t egressIdSet; fib_entry_t * fib_entry; - Ticks creation_time; - Ticks expiry_time; + Ticks create_ts; + Ticks expire_ts; } pit_entry_t; typedef enum { @@ -30,10 +49,10 @@ typedef enum { #define pit_entry_get_egress(E) (&((E)->egressIdSet)) #define pit_entry_get_fib_entry(E) ((E)->fib_entry) #define pit_entry_set_fib_entry(E, FIB_ENTRY) ((E)->fib_entry = FIB_ENTRY) -#define pit_entry_get_creation_time(E) ((E)->creation_time) -#define pit_entry_get_expiry_time(E) ((E)->expiry_time) -#define pit_entry_set_expiry_time(E, EXPIRY_TIME) \ - (entry)->expiry_time = EXPIRY_TIME +#define pit_entry_get_create_ts(E) ((E)->create_ts) +#define pit_entry_get_expire_ts(E) ((E)->expire_ts) +#define pit_entry_set_expire_ts(E, EXPIRY_TIME) \ + (entry)->expire_ts = EXPIRY_TIME #define pit_entry_ingress_add(E, NH) \ nexthops_add(pit_entry_get_ingress(E), (NH)) @@ -44,26 +63,34 @@ typedef enum { #define pit_entry_egress_add(E, NH) \ nexthops_add(pit_entry_get_egress(E), (NH)) -#define pit_entry_from_msgbuf(E, MSGBUF, EXPIRY_TIME, CREATION_TIME) \ -do { \ - E->msgbuf = MSGBUF; \ - pit_entry_ingress_add(E, msgbuf_get_connection_id(MSGBUF)); \ - E->fib_entry = NULL; \ - E->creation_time = CREATION_TIME; \ - E->expiry_time = EXPIRY_TIME; \ -} while(0) - #define name_hash(name) (name_HashCode(name)) #define name_hash_eq(a, b) (name_hash(b) - name_hash(a)) KHASH_INIT(pit_name, const Name *, unsigned, 0, name_hash, name_hash_eq); typedef struct { + msgbuf_pool_t * msgbuf_pool; + size_t max_size; pit_entry_t * entries; // pool kh_pit_name_t * index_by_name; } pit_t; -pit_t * pit_create(size_t max_elts); +/** + * @brief Allocate a new PIT data structure (extended parameters) + * + * @param init_size Initial size (0 = default) + * @param max_size Maximum size (0 = unbounded) + * + * @return pit_t* Newly allocated PIT data structure + */ +pit_t * _pit_create(size_t init_size, size_t max_size); + +/** + * @brief Allocate a new PIT data structure + * + * @return pit_t* Newly allocated PIT data structure + */ +#define pit_create() _pit_create(0, 0) void pit_free(pit_t * pit); @@ -81,12 +108,14 @@ do { #define pit_at(pit, i) (pit->entries + i) -pit_verdict_t pit_on_interest(pit_t * pit, msgbuf_t * msgbuf); +pit_verdict_t pit_on_interest(pit_t * pit, off_t msgbuf_id); -nexthops_t * pit_on_data(pit_t * pit, const msgbuf_t * msgbuf); +nexthops_t * pit_on_data(pit_t * pit, off_t msgbuf_id); -void pit_remove(pit_t * pit, const msgbuf_t * msgbuf); +void pit_remove(pit_t * pit, off_t msgbuf_id); pit_entry_t * pit_lookup(const pit_t * pit, const msgbuf_t * msgbuf); +#define pit_get_msgbuf_pool(pit) (pit->msgbuf_pool) + #endif /* HICNLIGHT_PIT_H */ |