Skip to content

Commit

Permalink
examples/frame: add show random option
Browse files Browse the repository at this point in the history
  • Loading branch information
quarium committed Nov 26, 2024
1 parent 69c0cc1 commit 4fb8634
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions examples/frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ static unsigned additional_framer = 0;
static bool decode = false;
static bool dump_date = false;
static bool dump_size = false;
static bool dump_random = false;

struct pid {
struct uchain uchain;
Expand Down Expand Up @@ -160,6 +161,11 @@ static int catch_uref(struct uprobe *uprobe, struct upipe *upipe,
UBASE_SIGNATURE_CHECK(args, UPIPE_PROBE_UREF_SIGNATURE);
struct uref *uref = va_arg(args, struct uref *);

if (dump_random) {
if (ubase_check(uref_flow_get_random(uref)))
upipe_notice_va(upipe, "random");
}

if (dump_date)
uref_dump_clock_dbg(uref, upipe->uprobe);

Expand Down Expand Up @@ -455,6 +461,7 @@ enum {
OPT_PID,
OPT_DATE,
OPT_SIZE,
OPT_RANDOM,
};

static struct option options[] = {
Expand All @@ -469,6 +476,7 @@ static struct option options[] = {
{ "pid", required_argument, NULL, OPT_PID },
{ "date", no_argument, NULL, OPT_DATE },
{ "size", no_argument, NULL, OPT_SIZE },
{ "random", no_argument, NULL, OPT_RANDOM },
{ NULL, 0, NULL, 0 },
};

Expand Down Expand Up @@ -544,6 +552,10 @@ int main(int argc, char *argv[])
dump_size = true;
break;

case OPT_RANDOM:
dump_random = true;
break;

default:
fprintf(stderr, "unknown option -%c\n", opt);
break;
Expand Down

0 comments on commit 4fb8634

Please sign in to comment.