Skip to content

Instantly share code, notes, and snippets.

wkz@wkz-box:~/code/github/wkz/dtl/src$ make all && ./ply -dD ~/tmp/test.ply
CC compile.o
LINK ply
DEBUG annotate_script: static inference done: 0
DEBUG annotate_script: dynamic inference done: 0
DEBUG annotate_script: location assigment done: 0
ast:
<script> (type:script/none size:0x0 loc:nowhere)
kprobe:netif_rx (type:probe/none size:0x0 loc:nowhere)
= (type:assign/none size:0x0 loc:reg/0)
stdio.h
--
#include <stdio.h>
#define printf(_fmt) printf("LOCAL: " _fmt)
inc1.c
--
#include "stdio.h"
$s:
0
[ 0, 1] 7 ▏
[ 2, 4) 8 ▏
[ 4, 8) 0
[ 8, 16) 682 ██████████▉
[ 16, 32) 120 █▉
[ 32, 64) 0
[ 64, 128) 0
[ 128, 256) 0
@wkz
wkz / lpm.py
Last active September 21, 2016 06:53
lpm
# http://web.mit.edu/devavrat/www/tcam.pdf
import random
import time
class Row(object):
valid = False
ip = None
prefix = None
#include <arpa/inet.h>
#include <assert.h>
#include <errno.h>
#include <ev.h>
#include <linux/udp.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/queue.h>
@wkz
wkz / lisp.c
Created October 21, 2017 22:13
/* {
* @t[0] = time();
* @reads[pid()] = quantize(arg2)
* }
*/
prog->ast =
node_expr("",
node_expr("=",
node_expr("[]",
node_ident("@t"),
@wkz
wkz / printxf.c
Last active August 10, 2024 20:18
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "printxf.h"
struct printxf printxf_default;
@wkz
wkz / moxa-usb-console.md
Created March 13, 2018 09:17
Moxa USB Console on Linux

Moxa's ethernet switches come with a USB console that is not recognized by the Linux kernel. Moxa have drivers available for download on their website, but only for Windows.

The device shows up in lsusb as:

Bus X Device Y: ID 110a:3001 Moxa Technologies Co., Ltd. 
@wkz
wkz / sniff.sh
Created April 28, 2018 15:02
Mirror a set of interfaces to a sniffer interface, ignoring 802.1Q tag information.
#/!bin/sh
# usage: sniff.sh <interface> [<interface>...]
# create a dummy to mirror all traffic to
ip link add dev sniffer type dummy
ip link set dev sniffer up
# intermediate dummy, needed because AF_PACKET-sockets gets the packet
# as seen before any tc-actions have been applied to it.
ip link add dev untag type dummy
@wkz
wkz / kfunc-get.sh
Created June 30, 2022 22:54
fzf + pahole = <3
#!/bin/sh
describe()
{
{
pfunct -f "$1"
echo
pfunct -f "$1" --no_parm_names | awk '
{
gsub("[a-zA-Z0-9_]+\\(","");