Skip to content

Instantly share code, notes, and snippets.

View bave's full-sized avatar

inoue.tomoya bave

View GitHub Profile
@bave
bave / dns_packet_parse.c
Last active March 18, 2020 00:46
How to use {libresolv, libbind}.
/*
* # Advance preparation are required.
* # ipfw add divert 10000 udp from me to [nameserver_ip] via [IF]
* # ipfw add divert 10000 udp from [nameserver_ip] to me via [IF]
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
@bave
bave / tfo.py
Created August 19, 2013 14:41
A test program of TCP Fast Open. (supported by greater than or equal to linux 3.7 kernel )
#!/usr/bin/env python
# you must preset following command.
# sudo sysctl -w net.ipv4.tcp_fastopen=3
import sys
import socket
PORT = 10443
@bave
bave / gist:e3abb7ddea9913c58168
Last active March 28, 2018 09:15
linux netmap patch script
#!/usr/bin/env sh
cd /tmp
apt-get update
apt-get -y install git build-essential
apt-get -y install linux-source linux-headers-generic
tar xvf /usr/src/linux-source-`uname -r | awk 'BEGIN { FS="-" } { print $1 }'`.tar.bz2 -C /usr/src
git clone https://github.com/luigirizzo/netmap.git
cd netmap/LINUX
SRC_VAR=/usr/src/linux-source-`uname -r | awk 'BEGIN { FS="-" } { print $1 }'`
./configure --kernel-sources=${SRC_VAR}
@bave
bave / gist:c5c218db8b54fa9b90fe
Created October 18, 2014 19:08
customize-freebsd-live-cd
#!/bin/sh
#fetch freebsd-live.iso
mkdir hoge
bsdtar -C hoge -pxvf freebsd-live.iso
cd hoge
# --------
# 書き換え
# --------
mkisofs -v -b boot/cdboot -no-emul-boot -r -J -V "FREEBSD_INSTALL" -o ../freebsd_customize.iso ./
@bave
bave / pktgen_sample.sh
Created May 19, 2015 16:30
pktgen script sample
#!/bin/sh
#modprobe pktgen
ETH="eth0"
CLONE_SKB="clone_skb 10"
PKT_SIZE="64"
DELAY="0"
SRC_MAC="00:26:2d:08:8b:25"
DST_MAC="00:26:2d:08:99:fb"
@bave
bave / gist:20893af9bd2c52190add
Last active January 24, 2016 12:54
freebsd: kernel proc and thread on kernel module
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get install htop
sudo apt-get install build-essential
sudo apt-get install libncurses-dev
sudo apt-get install libssl-dev
sudo apt-get install bc
sudo apt-get install linux-source
sudo -s
@bave
bave / sample_waitpid.c
Created January 29, 2019 14:29
waitpidのサンプル
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
int child()
{
int count = 10;
@bave
bave / sample_thread_sigwait.c
Last active February 15, 2019 20:40
sigwaitとスレッドのサンプル
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <pthread.h>
#include <sys/epoll.h>
#include <sys/signalfd.h>
@bave
bave / sample_tap.cpp
Created February 25, 2019 13:42
tapのサンプル
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <net/if.h>
/*
unsigned int if_nametoindex(const char *ifname);
char *if_indextoname(unsigned int ifindex, char *ifname);
*/