#include "../strategycode/sec.h"
#include "fib.h"
#include "packet.h"
#include "pit.h"
Go to the source code of this file.
◆ SgCtx_FibScratchT
| #define SgCtx_FibScratchT |
( |
| ctx, |
|
|
| T ) |
Value: __extension__({ \
(T*)(ctx)->fibEntryDyn->scratch; \
})
@ FibScratchSize
Definition enum.h:9
Access FIB entry scratch area as T* type.
◆ SgCtx_PitScratchT
| #define SgCtx_PitScratchT |
( |
| ctx, |
|
|
| T ) |
Value: __extension__({ \
(T*)(ctx)->pitEntry->scratch; \
})
@ PitScratchSize
Definition pit-const.h:11
Access PIT entry scratch area as T* type.
◆ SgGetJSONScalar
| #define SgGetJSONScalar |
( |
| ctx, |
|
|
| path, |
|
|
| dflt ) |
Value: __extension__({ \
int64_t value = (dflt); \
char pathA[] = (path); \
value; \
})
@ SGJSON_SCALAR
Definition api.h:137
Retrieve JSON parameter integer scalar value.
- Parameters
-
| path | JSON property path, using '.' separator for nested path. |
| dflt | default value. |
- Returns
- retrieved or default value.
◆ SgGetJSONSlice
| #define SgGetJSONSlice |
( |
| dst, |
|
|
| ctx, |
|
|
| path, |
|
|
| dflt ) |
Value: __extension__({ \
int64_t length = (0); \
char pathA[] = (path); \
for (int64_t i = 0; i < RTE_DIM((dst)); ++i) { \
int64_t value = (dflt); \
if (i < length) { \
SgGetJSON((ctx), pathA, i, &value); \
} \
(dst)[i] = value; \
} \
length; \
})
@ SGJSON_LEN
Definition api.h:138
Retrieve JSON parameter integer array.
- Parameters
-
| dst | destination array. |
| path | JSON property path, using '.' separator for nested path. |
| dflt | default value. |
- Returns
- retrieved length.
◆ SGINIT_SCHEMA
| #define SGINIT_SCHEMA |
( |
| ... | ) |
|
Value: char SgJSONSchema[] __attribute__((section(
SGSEC_SCHEMA), used)) = #__VA_ARGS__;
#define SGSEC_SCHEMA
Definition sec.h:8
Declare JSON schema.
A strategy should provide a JSON schema if it accepts parameters. Input parameters are validated against this schema prior to calling SgInit .
◆ SgCtx
| typedef struct SgCtx SgCtx |
Context of strategy invocation.
◆ SgEvent
Indicate why the strategy program is invoked.
◆ SgForwardInterestResult
◆ SgGlobal
| typedef struct SgGlobal SgGlobal |
Global static parameters.
◆ anonymous enum
| Enumerator |
|---|
| SGJSON_SCALAR | |
| SGJSON_LEN | |
◆ SgFibNexthopIt_InitCtx()
Iterate over FIB nexthops passing ctx->nhFlt.
- See also
- SgFibNexthopIt
◆ SgForwardInterest()
Forward an Interest to a nexthop.
- Precondition
- Not available in
SGEVT_DATA .
◆ SgGetJSON()
| bool SgGetJSON |
( |
SgCtx * | ctx, |
|
|
const char * | path, |
|
|
int | index, |
|
|
int64_t * | dst ) |
Retrieve JSON parameter integer value.
- Parameters
-
| path | JSON property path, using '.' separator for nested path. Due to eBPF loader limitation, this string should be written as a mutable char[] allocated on stack. A string literal may cause "resolve_xsym(.L.str) error -2". |
| index | index into JSON array, or SGJSON_SCALAR to retrieve scalar value, or SGJSON_LEN to retrieve array length. |
| dst | destination pointer. |
- Returns
- whether success.
- Precondition
- Only available in
SgInit .
◆ SgInit()
| uint64_t SgInit |
( |
SgCtx * | ctx | ) |
|
The strategy initialization procedure.
- Returns
- status code, ignored but may appear in logs.
A strategy should implement this function if it accepts parameters. This is called when a strategy is activated on a FIB entry. It should populate FIB entry scratch area according to JSON parameters.
◆ SgMain()
| uint64_t SgMain |
( |
SgCtx * | ctx | ) |
|
The strategy dataplane program.
- Returns
- status code, ignored but may appear in logs.
Every strategy must implement this function.
◆ SgRandInt()
| uint32_t SgRandInt |
( |
SgCtx * | ctx, |
|
|
uint32_t | max ) |
Generate a random integer.
- Parameters
-
- Returns
- uniformly distributed random number r, where 0 <= r < max .
◆ SgReturnNacks()
Return Nacks downstream and erase PIT entry.
- Precondition
- Only available in
SGEVT_INTEREST .
◆ SgSetTimer()
Set a timer to invoke strategy after a duration.
- Parameters
-
| after | duration in TSC unit, cannot exceed PIT entry expiration time. |
- Precondition
- Not available in
SGEVT_DATA .
Strategy program will be invoked again with SGEVT_TIMER after after . However, the timer would be cancelled if strategy program is invoked for any other event, a different timer is set, or the strategy choice has been changed.
◆ SgTscFromMillis()
Convert milliseconds to TscDuration.
◆ SGEVT_DATA
◆ SGEVT_INTEREST
◆ SGEVT_NACK
◆ SGEVT_NONE
◆ SGEVT_TIMER
◆ SGFWDI_ALLOCERR
◆ SGFWDI_BADFACE
face is down or FaceID is invalid
◆ SGFWDI_HOPZERO
HopLimit has become zero.
◆ SGFWDI_NONONCE
upstream has rejected all nonces
◆ SGFWDI_OK
◆ SGFWDI_SUPPRESSED