#include <stdlib.h>
#include <stdio.h>
#include <linux/unistd.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <linux/if_ether.h>
#include <net/if.h>
#include <linux/if_packet.h>
#include <arpa/inet.h>
#include "libbpf.h"

static inline int open_raw_sock(const char *name)
{
	struct sockaddr_ll sll;
	int sock;

	sock = socket(PF_PACKET, SOCK_RAW | SOCK_NONBLOCK | SOCK_CLOEXEC, htons(ETH_P_ALL));
	if (sock < 0) {
		printf("cannot create raw socket\n");
		return -1;
	}

	memset(&sll, 0, sizeof(sll));
	sll.sll_family = AF_PACKET;
	sll.sll_ifindex = if_nametoindex(name);
	sll.sll_protocol = htons(ETH_P_ALL);
	if (bind(sock, (struct sockaddr *)&sll, sizeof(sll)) < 0) {
		printf("bind to %s: %s\n", name, strerror(errno));
		close(sock);
		return -1;
	}

	return sock;
}
/a></td><td class='form'><form method='get'>
<input type='hidden' name='id' value='a8496eb81342393e4c8280a5ec27e1872a3fb9fd'/><select name='h' onchange='this.form.submit();'>
<option value='emaclite-cleanup'>emaclite-cleanup</option>
<option value='master' selected='selected'>master</option>
<option value='nds-private-remove'>nds-private-remove</option>
<option value='packet-loop-back'>packet-loop-back</option>
<option value='packet-rx-pump-back'>packet-rx-pump-back</option>
</select> <input type='submit' value='switch'/></form></td></tr>
<tr><td class='sub'>net-next plumbings</td><td class='sub right'>Tobias Klauser</td></tr></table>
<table class='tabs'><tr><td>
<a href='/cgit.cgi/linux/net-next.git/'>summary</a><a href='/cgit.cgi/linux/net-next.git/refs/?id=a8496eb81342393e4c8280a5ec27e1872a3fb9fd'>refs</a><a class='active' href='/cgit.cgi/linux/net-next.git/log/sound/soc/codecs/jz4740.c'>log</a><a href='/cgit.cgi/linux/net-next.git/tree/sound/soc/codecs/jz4740.c?id=a8496eb81342393e4c8280a5ec27e1872a3fb9fd'>tree</a><a href='/cgit.cgi/linux/net-next.git/commit/sound/soc/codecs/jz4740.c?id=a8496eb81342393e4c8280a5ec27e1872a3fb9fd'>commit</a><a href='/cgit.cgi/linux/net-next.git/diff/sound/soc/codecs/jz4740.c?id=a8496eb81342393e4c8280a5ec27e1872a3fb9fd'>diff</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/sound/soc/codecs/jz4740.c'>
<input type='hidden' name='id' value='a8496eb81342393e4c8280a5ec27e1872a3fb9fd'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit.cgi/linux/net-next.git/log/?id=a8496eb81342393e4c8280a5ec27e1872a3fb9fd'>root</a>/<a href='/cgit.cgi/linux/net-next.git/log/sound?id=a8496eb81342393e4c8280a5ec27e1872a3fb9fd'>sound</a>/<a href='/cgit.cgi/linux/net-next.git/log/sound/soc?id=a8496eb81342393e4c8280a5ec27e1872a3fb9fd'>soc</a>/<a href='/cgit.cgi/linux/net-next.git/log/sound/soc/codecs?id=a8496eb81342393e4c8280a5ec27e1872a3fb9fd'>codecs</a>/<a href='/cgit.cgi/linux/net-next.git/log/sound/soc/codecs/jz4740.c?id=a8496eb81342393e4c8280a5ec27e1872a3fb9fd'>jz4740.c</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th class='left'>Age</th><th class='left'>Commit message (<a href='/cgit.cgi/linux/net-next.git/log/sound/soc/codecs/jz4740.c?id=a8496eb81342393e4c8280a5ec27e1872a3fb9fd&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Files</th><th class='left'>Lines</th></tr>