Compare commits
19 Commits
v0.0.79-mu
...
v0.0.35
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a797b4f5f | ||
|
|
8cb849fbc3 | ||
|
|
13f9f4c896 | ||
|
|
cfd7af9241 | ||
|
|
c81592fcc5 | ||
|
|
b4a311cdc8 | ||
|
|
08617d0017 | ||
|
|
38cd3b0371 | ||
|
|
5944e61dfe | ||
|
|
585b2b08bc | ||
|
|
a3aa6fc4fb | ||
|
|
6f36424d12 | ||
|
|
fa9301da16 | ||
|
|
c154a00358 | ||
|
|
4246b510d2 | ||
|
|
c71db48ae1 | ||
|
|
e3cce8aeb9 | ||
|
|
ad0d205ff3 | ||
|
|
030087cb27 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
||||
[submodule "mud"]
|
||||
path = mud
|
||||
url = https://github.com/angt/mud.git
|
||||
@@ -20,11 +20,6 @@ glorytun_SOURCES = \
|
||||
src/state.c \
|
||||
src/state.h
|
||||
|
||||
glorytun_CFLAGS += -I$(srcdir)/mud
|
||||
glorytun_SOURCES += \
|
||||
mud/mud.h \
|
||||
mud/mud.c
|
||||
|
||||
EXTRA_DIST = \
|
||||
LICENSE \
|
||||
README.md \
|
||||
|
||||
10
README.md
10
README.md
@@ -1,6 +1,10 @@
|
||||
# π₁(Glorytun)=0
|
||||
# π₁(Glorytun)=ℤ²
|
||||
|
||||
Small, Simple and Stupid VPN over [mud](https://github.com/angt/mud).
|
||||
Small, Simple and Stupid TCP VPN.
|
||||
|
||||
#### Work In Progress
|
||||
|
||||
This code will probably format your harddisk!
|
||||
|
||||
#### Build and Install
|
||||
|
||||
@@ -8,7 +12,7 @@ Glorytun depends on [libsodium](https://github.com/jedisct1/libsodium) version >
|
||||
|
||||
To build and install the latest version:
|
||||
|
||||
$ git clone https://github.com/angt/glorytun --recursive --branch mud
|
||||
$ git clone https://github.com/angt/glorytun
|
||||
$ cd glorytun
|
||||
$ ./autogen.sh
|
||||
$ ./configure
|
||||
|
||||
@@ -14,6 +14,7 @@ AM_SILENT_RULES([yes])
|
||||
AM_PROG_CC_C_O
|
||||
AC_PROG_CC_C99
|
||||
AC_USE_SYSTEM_EXTENSIONS
|
||||
AC_SEARCH_LIBS([getaddrinfo], [resolv nsl])
|
||||
AC_SEARCH_LIBS([socket], [socket])
|
||||
AC_CHECK_LIB([rt], [clock_gettime])
|
||||
AC_CHECK_FUNCS([clock_gettime])
|
||||
|
||||
10
m4/pkg.m4
10
m4/pkg.m4
@@ -1,6 +1,6 @@
|
||||
dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
|
||||
dnl serial 11 (pkg-config-0.29)
|
||||
dnl
|
||||
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
|
||||
# serial 12 (pkg-config-0.29.2)
|
||||
|
||||
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
|
||||
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
|
||||
dnl
|
||||
@@ -41,7 +41,7 @@ dnl
|
||||
dnl See the "Since" comment for each macro you use to see what version
|
||||
dnl of the macros you require.
|
||||
m4_defun([PKG_PREREQ],
|
||||
[m4_define([PKG_MACROS_VERSION], [0.29])
|
||||
[m4_define([PKG_MACROS_VERSION], [0.29.2])
|
||||
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
|
||||
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
|
||||
])dnl PKG_PREREQ
|
||||
@@ -142,7 +142,7 @@ AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
|
||||
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
|
||||
|
||||
pkg_failed=no
|
||||
AC_MSG_CHECKING([for $1])
|
||||
AC_MSG_CHECKING([for $2])
|
||||
|
||||
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
|
||||
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
|
||||
|
||||
1
mud
1
mud
Submodule mud deleted from b5a5cb2f1f
34
src/common.c
34
src/common.c
@@ -1,10 +1,9 @@
|
||||
#include "common.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int
|
||||
gt_print(const char *fmt, ...)
|
||||
int gt_print (const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
@@ -17,8 +16,7 @@ gt_print(const char *fmt, ...)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
gt_log(const char *fmt, ...)
|
||||
void gt_log (const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
@@ -26,8 +24,7 @@ gt_log(const char *fmt, ...)
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
gt_fatal(const char *fmt, ...)
|
||||
void gt_fatal (const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
@@ -37,19 +34,17 @@ gt_fatal(const char *fmt, ...)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
void
|
||||
gt_na(const char *name)
|
||||
void gt_na (const char *name)
|
||||
{
|
||||
gt_log("%s is not available on your platform\n", name);
|
||||
}
|
||||
|
||||
int
|
||||
gt_tohex(char *dst, size_t dst_size, const uint8_t *src, size_t src_size)
|
||||
int gt_tohex (char *dst, size_t dst_size, const uint8_t *src, size_t src_size)
|
||||
{
|
||||
if (_0_(!dst_size))
|
||||
if _0_(!dst_size)
|
||||
return -1;
|
||||
|
||||
if (_0_(((dst_size - 1) / 2) < src_size))
|
||||
if _0_(((dst_size-1)/2)<src_size)
|
||||
return -1;
|
||||
|
||||
static const char tbl[] = "0123456789ABCDEF";
|
||||
@@ -64,8 +59,8 @@ gt_tohex(char *dst, size_t dst_size, const uint8_t *src, size_t src_size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
_const_ static inline int
|
||||
fromhex(const char c)
|
||||
_const_
|
||||
static inline int fromhex (const char c)
|
||||
{
|
||||
if (c>='0' && c<='9')
|
||||
return c-'0';
|
||||
@@ -79,20 +74,19 @@ fromhex(const char c)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
gt_fromhex(uint8_t *dst, size_t dst_size, const char *src, size_t src_size)
|
||||
int gt_fromhex (uint8_t *dst, size_t dst_size, const char *src, size_t src_size)
|
||||
{
|
||||
if (_0_(src_size & 1))
|
||||
if _0_(src_size&1)
|
||||
return -1;
|
||||
|
||||
if (_0_(dst_size < (src_size / 2)))
|
||||
if _0_(dst_size<(src_size/2))
|
||||
return -1;
|
||||
|
||||
for (size_t i=0; i<src_size; i+=2) {
|
||||
const int a = fromhex(src[i]);
|
||||
const int b = fromhex(src[i+1]);
|
||||
|
||||
if (_0_(a == -1 || b == -1))
|
||||
if _0_(a==-1 || b==-1)
|
||||
return -1;
|
||||
|
||||
*dst++ = (a<<4)|b;
|
||||
|
||||
35
src/db.c
35
src/db.c
@@ -12,14 +12,14 @@ struct node {
|
||||
uint32_t point;
|
||||
};
|
||||
|
||||
_pure_ static inline size_t
|
||||
db_size(const uint8_t *a)
|
||||
_pure_
|
||||
static inline size_t db_size (const uint8_t *a)
|
||||
{
|
||||
return (a[0]?:str_len((char *)a+1))+1;
|
||||
}
|
||||
|
||||
_pure_ static inline size_t
|
||||
db_cmp(const uint8_t *a, const uint8_t *b)
|
||||
_pure_
|
||||
static inline size_t db_cmp (const uint8_t *a, const uint8_t *b)
|
||||
{
|
||||
const size_t size = a[0];
|
||||
|
||||
@@ -39,8 +39,8 @@ db_cmp(const uint8_t *a, const uint8_t *b)
|
||||
return 0;
|
||||
}
|
||||
|
||||
_pure_ static inline int
|
||||
db_dir(const uint32_t point, uint8_t *data, const size_t size)
|
||||
_pure_
|
||||
static inline int db_dir (const uint32_t point, uint8_t *data, const size_t size)
|
||||
{
|
||||
const size_t pos = point>>8;
|
||||
|
||||
@@ -50,10 +50,9 @@ db_dir(const uint32_t point, uint8_t *data, const size_t size)
|
||||
return ((point|data[pos])&255)==255;
|
||||
}
|
||||
|
||||
uint8_t *
|
||||
db_search(uint8_t **p, uint8_t *data)
|
||||
uint8_t *db_search (uint8_t **p, uint8_t *data)
|
||||
{
|
||||
if (_0_(!*p))
|
||||
if _0_(!*p)
|
||||
return NULL;
|
||||
|
||||
uint8_t *r = *p;
|
||||
@@ -70,13 +69,12 @@ db_search(uint8_t **p, uint8_t *data)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint8_t *
|
||||
db_insert(uint8_t **p, uint8_t *data)
|
||||
uint8_t *db_insert (uint8_t **p, uint8_t *data)
|
||||
{
|
||||
if (_0_(CBIT(data)))
|
||||
if _0_(CBIT(data))
|
||||
return NULL;
|
||||
|
||||
if (_0_(!*p)) {
|
||||
if _0_(!*p) {
|
||||
*p = data;
|
||||
return data;
|
||||
}
|
||||
@@ -91,7 +89,7 @@ db_insert(uint8_t **p, uint8_t *data)
|
||||
|
||||
const size_t diff = db_cmp(r, data);
|
||||
|
||||
if (_0_(!diff))
|
||||
if _0_(!diff)
|
||||
return r;
|
||||
|
||||
const size_t pos = diff-1;
|
||||
@@ -109,7 +107,7 @@ db_insert(uint8_t **p, uint8_t *data)
|
||||
|
||||
struct node *node = malloc(sizeof(struct node));
|
||||
|
||||
if (_0_(!node))
|
||||
if _0_(!node)
|
||||
return NULL;
|
||||
|
||||
const int dir = (mask|r[pos])==255;
|
||||
@@ -123,10 +121,9 @@ db_insert(uint8_t **p, uint8_t *data)
|
||||
return data;
|
||||
}
|
||||
|
||||
uint8_t *
|
||||
db_remove(uint8_t **p, uint8_t *data)
|
||||
uint8_t *db_remove (uint8_t **p, uint8_t *data)
|
||||
{
|
||||
if (_0_(!*p))
|
||||
if _0_(!*p)
|
||||
return NULL;
|
||||
|
||||
const size_t size = db_size(data);
|
||||
@@ -142,7 +139,7 @@ db_remove(uint8_t **p, uint8_t *data)
|
||||
p = node->child+dir;
|
||||
}
|
||||
|
||||
if (_0_(db_cmp(data, *p)))
|
||||
if _0_(db_cmp(data, *p))
|
||||
return NULL;
|
||||
|
||||
uint8_t *r = *p;
|
||||
|
||||
3
src/ip.h
3
src/ip.h
@@ -4,7 +4,6 @@
|
||||
|
||||
struct ip_common {
|
||||
uint8_t version;
|
||||
uint8_t tc;
|
||||
uint8_t proto;
|
||||
uint8_t hdr_size;
|
||||
uint16_t size;
|
||||
@@ -25,13 +24,11 @@ static inline int ip_get_common (struct ip_common *ic, const uint8_t *data, size
|
||||
|
||||
switch (ic->version) {
|
||||
case 4:
|
||||
ic->tc = data[1];
|
||||
ic->proto = data[9];
|
||||
ic->hdr_size = (data[0]&0xF)<<2;
|
||||
ic->size = ((data[2]<<8)|data[3]);
|
||||
return 0;
|
||||
case 6:
|
||||
ic->tc = ((data[0]&0xF)<<4)|(data[1]>>4);
|
||||
ic->proto = data[6];
|
||||
ic->hdr_size = 40;
|
||||
ic->size = ((data[4]<<8)|data[5])+40;
|
||||
|
||||
1586
src/main.c
1586
src/main.c
File diff suppressed because it is too large
Load Diff
18
src/option.c
18
src/option.c
@@ -3,8 +3,7 @@
|
||||
#include "option.h"
|
||||
#include "str.h"
|
||||
|
||||
int
|
||||
option_str(void *data, int argc, char **argv)
|
||||
int option_str (void *data, int argc, char **argv)
|
||||
{
|
||||
if (argc<2 || str_empty(argv[1])) {
|
||||
gt_print("option `%s' need a string argument\n", argv[0]);
|
||||
@@ -16,8 +15,7 @@ option_str(void *data, int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
option_long(void *data, int argc, char **argv)
|
||||
int option_long (void *data, int argc, char **argv)
|
||||
{
|
||||
if (argc<2 || str_empty(argv[1])) {
|
||||
gt_print("option `%s' need an integer argument\n", argv[0]);
|
||||
@@ -38,8 +36,7 @@ option_long(void *data, int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
option_is_set(struct option *opts, const char *name)
|
||||
int option_is_set (struct option *opts, const char *name)
|
||||
{
|
||||
for (int k=0; opts[k].name; k++) {
|
||||
if (!str_cmp(opts[k].name, name))
|
||||
@@ -49,8 +46,7 @@ option_is_set(struct option *opts, const char *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
option_option(void *data, int argc, char **argv)
|
||||
int option_option (void *data, int argc, char **argv)
|
||||
{
|
||||
if (!data)
|
||||
return 0;
|
||||
@@ -91,8 +87,7 @@ option_option(void *data, int argc, char **argv)
|
||||
return argc;
|
||||
}
|
||||
|
||||
static int
|
||||
option_usage(struct option *opts, int slen)
|
||||
static int option_usage (struct option *opts, int slen)
|
||||
{
|
||||
if (!opts)
|
||||
return 0;
|
||||
@@ -119,8 +114,7 @@ option_usage(struct option *opts, int slen)
|
||||
return len;
|
||||
}
|
||||
|
||||
int
|
||||
option(struct option *opts, int argc, char **argv)
|
||||
int option (struct option *opts, int argc, char **argv)
|
||||
{
|
||||
int ret = option_option(opts, argc, argv);
|
||||
|
||||
|
||||
@@ -3,12 +3,11 @@
|
||||
#include "state.h"
|
||||
#include "str.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
int
|
||||
state_create(const char *filename)
|
||||
int state_create (const char *filename)
|
||||
{
|
||||
if (str_empty(filename))
|
||||
return -1;
|
||||
@@ -38,8 +37,7 @@ state_create(const char *filename)
|
||||
return fd;
|
||||
}
|
||||
|
||||
void
|
||||
state_send(int fd, const char *state, const char *info)
|
||||
void state_send (int fd, const char *state, const char *info)
|
||||
{
|
||||
if (str_empty(state))
|
||||
return;
|
||||
|
||||
99
src/tun.c
99
src/tun.c
@@ -1,26 +1,25 @@
|
||||
#include "common.h"
|
||||
|
||||
#include "ip.h"
|
||||
#include "str.h"
|
||||
#include "tun.h"
|
||||
#include "str.h"
|
||||
#include "ip.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
#ifdef __linux__
|
||||
#include <linux/if.h>
|
||||
#include <linux/if_tun.h>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <net/if_utun.h>
|
||||
#include <sys/kern_control.h>
|
||||
#include <sys/sys_domain.h>
|
||||
#include <sys/kern_control.h>
|
||||
#include <net/if_utun.h>
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(__OpenBSD__)
|
||||
@@ -29,8 +28,7 @@
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
static int
|
||||
tun_create_by_id(char *name, size_t size, unsigned id)
|
||||
static int tun_create_by_id (char *name, size_t size, unsigned id, _unused_ int mq)
|
||||
{
|
||||
int fd = socket(PF_SYSTEM, SOCK_DGRAM, SYSPROTO_CONTROL);
|
||||
|
||||
@@ -65,23 +63,21 @@ tun_create_by_id(char *name, size_t size, unsigned id)
|
||||
return fd;
|
||||
}
|
||||
|
||||
static int
|
||||
tun_create_by_name(char *name, size_t size, char *dev_name)
|
||||
static int tun_create_by_name (char *name, size_t size, char *dev_name, int mq)
|
||||
{
|
||||
unsigned id = 0;
|
||||
|
||||
if (sscanf(dev_name, "utun%u", &id)!=1)
|
||||
return -1;
|
||||
|
||||
return tun_create_by_id(name, size, id);
|
||||
return tun_create_by_id(name, size, id, mq);
|
||||
}
|
||||
|
||||
#else /* not __APPLE__ */
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
static int
|
||||
tun_create_by_name(char *name, size_t size, char *dev_name)
|
||||
static int tun_create_by_name (char *name, size_t size, char *dev_name, int mq)
|
||||
{
|
||||
int fd = open("/dev/net/tun", O_RDWR);
|
||||
|
||||
@@ -92,6 +88,12 @@ tun_create_by_name(char *name, size_t size, char *dev_name)
|
||||
.ifr_flags = IFF_TUN|IFF_NO_PI,
|
||||
};
|
||||
|
||||
if (mq) {
|
||||
#ifdef IFF_MULTI_QUEUE
|
||||
ifr.ifr_flags |= IFF_MULTI_QUEUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
str_cpy(ifr.ifr_name, dev_name, IFNAMSIZ-1);
|
||||
|
||||
if (ioctl(fd, TUNSETIFF, &ifr)) {
|
||||
@@ -106,8 +108,7 @@ tun_create_by_name(char *name, size_t size, char *dev_name)
|
||||
|
||||
#else /* not __linux__ not __APPLE__ */
|
||||
|
||||
static int
|
||||
tun_create_by_name(char *name, size_t size, char *dev_name)
|
||||
static int tun_create_by_name (char *name, size_t size, char *dev_name, _unused_ int mq)
|
||||
{
|
||||
char path[64];
|
||||
|
||||
@@ -119,29 +120,32 @@ tun_create_by_name(char *name, size_t size, char *dev_name)
|
||||
|
||||
#endif /* not __APPLE__ */
|
||||
|
||||
static int
|
||||
tun_create_by_id(char *name, size_t size, unsigned id)
|
||||
static int tun_create_by_id (char *name, size_t size, unsigned id, int mq)
|
||||
{
|
||||
char dev_name[64];
|
||||
|
||||
snprintf(dev_name, sizeof(dev_name), "tun%u", id);
|
||||
|
||||
return tun_create_by_name(name, size, dev_name);
|
||||
return tun_create_by_name(name, size, dev_name, mq);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int
|
||||
tun_create(char *dev_name, char **ret_name)
|
||||
int tun_create (char *dev_name, char **ret_name, int mq)
|
||||
{
|
||||
char name[64] = {0};
|
||||
int fd = -1;
|
||||
|
||||
#ifndef IFF_MULTI_QUEUE
|
||||
if (mq)
|
||||
gt_na("IFF_MULTI_QUEUE");
|
||||
#endif
|
||||
|
||||
if (str_empty(dev_name)) {
|
||||
for (unsigned id=0; id<32 && fd==-1; id++)
|
||||
fd = tun_create_by_id(name, sizeof(name), id);
|
||||
fd = tun_create_by_id(name, sizeof(name), id, mq);
|
||||
} else {
|
||||
fd = tun_create_by_name(name, sizeof(name), dev_name);
|
||||
fd = tun_create_by_name(name, sizeof(name), dev_name, mq);
|
||||
}
|
||||
|
||||
if (fd!=-1 && ret_name)
|
||||
@@ -150,8 +154,7 @@ tun_create(char *dev_name, char **ret_name)
|
||||
return fd;
|
||||
}
|
||||
|
||||
ssize_t
|
||||
tun_read(int fd, void *data, size_t size)
|
||||
ssize_t tun_read (int fd, void *data, size_t size)
|
||||
{
|
||||
if (!size)
|
||||
return -1;
|
||||
@@ -160,14 +163,8 @@ tun_read(int fd, void *data, size_t size)
|
||||
uint32_t family;
|
||||
|
||||
struct iovec iov[2] = {
|
||||
{
|
||||
.iov_base = &family,
|
||||
.iov_len = sizeof(family),
|
||||
},
|
||||
{
|
||||
.iov_base = data,
|
||||
.iov_len = size,
|
||||
},
|
||||
{ .iov_base = &family, .iov_len = sizeof(family) },
|
||||
{ .iov_base = data, .iov_len = size }
|
||||
};
|
||||
|
||||
ssize_t ret = readv(fd, iov, 2);
|
||||
@@ -195,8 +192,7 @@ tun_read(int fd, void *data, size_t size)
|
||||
#endif
|
||||
}
|
||||
|
||||
ssize_t
|
||||
tun_write(int fd, const void *data, size_t size)
|
||||
ssize_t tun_write (int fd, const void *data, size_t size)
|
||||
{
|
||||
if (!size)
|
||||
return -1;
|
||||
@@ -216,14 +212,8 @@ tun_write(int fd, const void *data, size_t size)
|
||||
}
|
||||
|
||||
struct iovec iov[2] = {
|
||||
{
|
||||
.iov_base = &family,
|
||||
.iov_len = sizeof(family),
|
||||
},
|
||||
{
|
||||
.iov_base = (void *)data,
|
||||
.iov_len = size,
|
||||
},
|
||||
{ .iov_base = &family, .iov_len = sizeof(family) },
|
||||
{ .iov_base = (void *) data, .iov_len = size },
|
||||
};
|
||||
|
||||
ssize_t ret = writev(fd, iov, 2);
|
||||
@@ -250,26 +240,3 @@ tun_write(int fd, const void *data, size_t size)
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
tun_set_mtu(char *dev_name, int mtu)
|
||||
{
|
||||
struct ifreq ifr = {
|
||||
.ifr_mtu = mtu,
|
||||
};
|
||||
|
||||
str_cpy(ifr.ifr_name, dev_name, IFNAMSIZ - 1);
|
||||
|
||||
int fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
|
||||
if (fd == -1)
|
||||
return -1;
|
||||
|
||||
int ret = ioctl(fd, SIOCSIFMTU, &ifr);
|
||||
|
||||
int err = errno;
|
||||
close(fd);
|
||||
errno = err;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user