aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light/src/processor/pit.h
blob: 1f909be3ecb64017d3b72814deb401db0d2044fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
 * Copyright (c) 2017-2019 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 The Pending Interest Table interface
 *
 * Interface for implementing a PIT table
 *
 */

#ifndef pit_h
#define pit_h

#include <src/core/forwarder.h>
#include <src/core/message.h>
#include <src/core/numberSet.h>
#include <src/processor/pitEntry.h>
#include <src/processor/pitVerdict.h>

struct pit;
typedef struct pit PIT;

struct pit {
  void (*release)(PIT **pitPtr);
  PITVerdict (*receiveInterest)(PIT *pit, Message *interestMessage);
  NumberSet *(*satisfyInterest)(PIT *pit, const Message *objectMessage);
  void (*removeInterest)(PIT *pit, const Message *interestMessage);
  PitEntry *(*getPitEntry)(const PIT *pit, const Message *interestMessage);
  void *closure;
};

void *pit_Closure(const PIT *pit);

/**
 * Destroys the PIT table and all entries contained in it.
 *
 * PIT entries are reference counted, so if the user has stored one outside the
 * PIT table it will still be valid.
 *
 * @param [in,out] pitPtr Double pointer to PIT table, will be NULLed
 */
void pit_Release(PIT **pitPtr);

/**
 * @function pit_ReceiveInterest
 * @abstract Receives an interest and adds to PIT table
 * @discussion
 *   If not present, adds entry to the PIT table and returns
 * PIT_VERDICT_NEW_ENTRY. If present and aggregated, returns
 * PIT_VERDICT_EXISTING_ENTRY.
 *
 *   Some aggregated interests may return PIT_VERDICT_NEW_ENTRY if the interest
 * needs to be forwarded again (e.g. the lifetime is extended).
 *
 *   If the PIT stores the message in its table, it will store a reference
 * counted copy.
 *
 * @return Verdict of receiving the interest
 */
PITVerdict pit_ReceiveInterest(PIT *pit, Message *interestMessage);

/**
 * @function pit_SatisfyInterest
 * @abstract Tries to satisfy PIT entries based on the message, returning where
 * to send message
 * @discussion
 *     If matching interests are in the PIT, will return the set of reverse
 * paths to use to forward the content object.
 *
 *     The return value is allocated and must be destroyed.
 *
 * @return Set of ConnectionTable id's to forward the message, may be empty or
 * NULL.  Must be destroyed.
 */
NumberSet *pit_SatisfyInterest(PIT *pit, const Message *objectMessage);

/**
 * @function pit_RemoveInterest
 * @abstract Unconditionally remove the interest from the PIT
 * @discussion
 *   The PIT may store a specific name in several tables.  This function will
 *   remove the interest from the specific table it lives it.  It will not
 *   remove PIT entries in different tables with the same name.
 *
 *   The different tables index interests based on their matching criteria,
 *   such as by name, by name and keyid, etc.
 *
 */
void pit_RemoveInterest(PIT *pit, const Message *interestMessage);

/**
 * @function pit_GetPitEntry
 * @abstract Retrieve the best matching PIT entry for the message.
 * @discussion
 *   Returns a reference counted copy of the entry, must call
 * <code>pitEntry_Destory()</code> on it.
 *
 * @return NULL if not in table, otherwise a reference counted copy of the entry
 */
PitEntry *pit_GetPitEntry(const PIT *pit, const Message *interestMessage);
#endif  // pit_h