Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 262765 | Differences between
and this patch

Collapse All | Expand All

(-)nstx-1.1-beta6.tuntap/Makefile (-2 / +2 lines)
Lines 1-9 Link Here
1
CFLAGS += -ggdb -Wall -Werror -Wsign-compare 
1
CFLAGS += -ggdb -Wall -Werror -Wsign-compare 
2
2
3
NSTXD_SRCS = nstxd.c nstx_encode.c nstx_pstack.c nstx_dns.c nstx_tuntap.c nstx_queue.c
3
NSTXD_SRCS = nstxd.c nstx_encode.c nstx_pstack.c nstx_dns.c nstx_tuntap.c nstx_queue.c nstx_util.c
4
NSTXD_OBJS = ${NSTXD_SRCS:.c=.o}
4
NSTXD_OBJS = ${NSTXD_SRCS:.c=.o}
5
5
6
NSTXCD_SRCS = nstxcd.c nstx_encode.c nstx_pstack.c nstx_dns.c nstx_tuntap.o nstx_queue.c
6
NSTXCD_SRCS = nstxcd.c nstx_encode.c nstx_pstack.c nstx_dns.c nstx_tuntap.o nstx_queue.c nstx_util.c
7
NSTXCD_OBJS = ${NSTXCD_SRCS:.c=.o}
7
NSTXCD_OBJS = ${NSTXCD_SRCS:.c=.o}
8
8
9
PROGS = nstxd nstxcd
9
PROGS = nstxd nstxcd
(-)nstx-1.1-beta6.tuntap/nstx_util.c (+46 lines)
Lines 27-32 Link Here
27
#include <stdio.h>
27
#include <stdio.h>
28
#include <sys/types.h>
28
#include <sys/types.h>
29
#include <sys/socket.h>
29
#include <sys/socket.h>
30
#include <net/if.h>
31
#include <sys/ioctl.h>
32
#include <arpa/inet.h>
33
#include <errno.h>
30
34
31
#include "nstxfun.h"
35
#include "nstxfun.h"
32
36
Lines 48-53 Link Here
48
   close(fd);
52
   close(fd);
49
}
53
}
50
54
55
static int iface_addr(const char * name, in_addr_t * result) {
56
    int r, s;
57
    struct ifreq ifr;
58
    struct sockaddr_in * sin;
59
    
60
    s = socket(AF_INET, SOCK_DGRAM, 0);
61
62
    if (s < 0) {
63
        perror("socket");
64
        return s;
65
    }
66
67
    strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
68
    ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = 0;
69
70
    r = ioctl(s, SIOCGIFADDR, &ifr);
71
72
    if (r < 0) {
73
        perror("ioctl(SIOCGIFADDR)");
74
        return r;
75
    }
76
77
    sin = (struct sockaddr_in *)&ifr.ifr_addr;
78
    *result = sin->sin_addr.s_addr;
79
80
    if (*result == INADDR_ANY || *result == INADDR_NONE) {
81
        fprintf(stderr, "interface %s has no assigned address\n", name);
82
        return -EINVAL;
83
    }
84
85
    return 0;
86
}
87
88
int addr_convert(const char * s, in_addr_t * result) {
89
    *result = inet_addr(s);
90
91
    if (*result != INADDR_NONE)
92
        return 0;
93
94
    return iface_addr(s, result);
95
}
96
51
#ifdef WITH_PKTDUMP
97
#ifdef WITH_PKTDUMP
52
void
98
void
53
pktdump (const char *prefix, unsigned short id, const char *data,
99
pktdump (const char *prefix, unsigned short id, const char *data,
(-)nstx-1.1-beta6.tuntap/nstxd.8 (-2 / +2 lines)
Lines 22-29 Link Here
22
Tun mode (default)
22
Tun mode (default)
23
.IP \-T
23
.IP \-T
24
Tap mode
24
Tap mode
25
.IP \-i ipaddr
25
.IP \-i ipaddr|interface
26
Bind to this IP address rather than every available address
26
Bind to this IP address or interface rather than every available address
27
.IP \-C dir
27
.IP \-C dir
28
Chroot to this directory on startup
28
Chroot to this directory on startup
29
.IP \-D
29
.IP \-D
(-)nstx-1.1-beta6.tuntap/nstxd.c (-5 / +6 lines)
Lines 61-67 Link Here
61
	    "\t-t (tun mode, default)\n"
61
	    "\t-t (tun mode, default)\n"
62
	    "\t-T (tap mode)\n"
62
	    "\t-T (tap mode)\n"
63
#endif
63
#endif
64
	    "\t-i ip.to.bi.nd (bind to port 53 on this IP only)\n"
64
	    "\t-i ip|interface (bind to port 53 on this IP/interface only)\n"
65
	    "\t-C dir (chroot() to this directory after initialization)\n"
65
	    "\t-C dir (chroot() to this directory after initialization)\n"
66
	    "\t-D (call daemon(3) to detach from terminal)\n"
66
	    "\t-D (call daemon(3) to detach from terminal)\n"
67
	    "\t-g (enable debug messages)\n"
67
	    "\t-g (enable debug messages)\n"
Lines 80-93 Link Here
80
   int		 daemonize = 0;
80
   int		 daemonize = 0;
81
   int		 logmask = LOG_UPTO(LOG_INFO);
81
   int		 logmask = LOG_UPTO(LOG_INFO);
82
   int tun = 1;
82
   int tun = 1;
83
   int r;
83
   
84
   
84
   while ((ch = getopt(argc, argv, "gDC:u:hd:I:i:tT")) != -1) {
85
   while ((ch = getopt(argc, argv, "gDC:u:hd:I:i:tT")) != -1) {
85
	switch(ch) {
86
	switch(ch) {
86
	case 'i':
87
	case 'i':
87
		bindto = inet_addr(optarg);
88
        r = addr_convert(optarg, &bindto);
88
		if (bindto == INADDR_NONE) {
89
        if (r < 0) {
89
			fprintf(stderr, "`%s' is not an IP-address\n",
90
            fprintf(stderr, "couldn't use interface %s: %s\n", optarg,
90
			    optarg);
91
                    strerror(-r));
91
			exit(EX_USAGE);
92
			exit(EX_USAGE);
92
		}
93
		}
93
		break;
94
		break;
(-)nstx-1.1-beta6.tuntap/nstxfun.h (+2 lines)
Lines 102-105 Link Here
102
void pktdump (const char *, unsigned short, const char *, size_t, int);
102
void pktdump (const char *, unsigned short, const char *, size_t, int);
103
#endif
103
#endif
104
104
105
int addr_convert(const char *, in_addr_t *);
106
105
#endif /* _NSTXHDR_H */
107
#endif /* _NSTXHDR_H */

Return to bug 262765