17#ifndef P4C_UBPF_TEST_H
18#define P4C_UBPF_TEST_H
24#define MAX_PRINTF_LENGTH 80
32static inline void ubpf_printf_test(
const char *fmt, ...) {
35 char str[MAX_PRINTF_LENGTH];
36 if (vsnprintf(str, MAX_PRINTF_LENGTH, fmt, args) >= 0)
41static inline void *ubpf_packet_data_test(
void *ctx) {
46static inline void *ubpf_adjust_head_test(
void *ctx,
int offset) {
51 }
else if (offset > 0) {
52 dp->data = realloc(dp->data, dp->size_ + offset);
53 memcpy((
char *) dp->data + offset, dp->data, dp->size_);
57 int ofs = abs(offset);
58 memcpy(dp->data, (
char *) dp->data + ofs, dp->size_ - ofs);
59 dp->data = realloc(dp->data, dp->size_ - ofs);
65static inline uint32_t ubpf_truncate_packet_test(
void *ctx,
int maxlen)
73 if (maxlen >= dp->size_) {
76 cutlen = dp->size_ - maxlen;
77 dp->data = realloc(dp->data, maxlen);
Definition ubpf_test.h:27