-
Notifications
You must be signed in to change notification settings - Fork 19
/
netns.h
35 lines (29 loc) · 837 Bytes
/
netns.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef ISOLATE_NETNS_H
#define ISOLATE_NETNS_H
#include <stdio.h>
#include <string.h>
#include <linux/rtnetlink.h>
#include <linux/veth.h>
#include <net/if.h>
#include <stdarg.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#define MAX_PAYLOAD 1024
struct nl_req {
struct nlmsghdr n;
struct ifinfomsg i;
char buf[MAX_PAYLOAD];
};
#define NLMSG_TAIL(nmsg) \
((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
int create_socket(int domain, int type, int protocol);
void if_up(char *ifname, char *ip, char *netmask);
void create_veth(int sock_fd, char *ifname, char *peername);
void move_if_to_pid_netns(int sock_fd, char *ifname, int netns);
int get_netns_fd(int pid);
#endif //ISOLATE_NETNS_H