Cleanup:
- Remove checks for specific OS's, instead check for #defines/#includes. - Use uint??_t where appropriate. - Mask handling functions use void pointers to get rid of silly casts.
This commit is contained in:
parent
d333fca4d6
commit
116ba3b3da
14 changed files with 107 additions and 79 deletions
11
configure.in
11
configure.in
|
@ -1,6 +1,6 @@
|
|||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
dnl $Id: configure.in,v 1.13.2.44 2002/04/19 14:06:40 guus Exp $
|
||||
dnl $Id: configure.in,v 1.13.2.45 2002/06/08 12:57:09 guus Exp $
|
||||
|
||||
AC_INIT(src/tincd.c)
|
||||
AM_INIT_AUTOMAKE(tinc, 1.0-cvs)
|
||||
|
@ -69,8 +69,9 @@ dnl Checks for libraries.
|
|||
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS([fcntl.h limits.h sys/ioctl.h syslog.h unistd.h \
|
||||
sys/time.h malloc.h strings.h sys/file.h])
|
||||
AC_CHECK_HEADERS([fcntl.h limits.h malloc.h stdint.h strings.h syslog.h unistd.h \
|
||||
net/ethernet.h net/if.h netinet/ip.h netinet/tcp.h \
|
||||
sys/file.h sys/ioctl.h sys/param.h sys/time.h])
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
|
@ -95,8 +96,8 @@ dnl Checks for library functions.
|
|||
AC_FUNC_MEMCMP
|
||||
AC_FUNC_ALLOCA
|
||||
AC_TYPE_SIGNAL
|
||||
AC_CHECK_FUNCS([ftime socket select strtol strerror flock unsetenv \
|
||||
asprintf putenv strdup fcloseall daemon strsignal get_current_dir_name])
|
||||
AC_CHECK_FUNCS([asprintf daemon fcloseall flock ftime get_current_dir_name \
|
||||
putenv select strdup strerror strsignal strtol unsetenv])
|
||||
jm_FUNC_MALLOC
|
||||
jm_FUNC_REALLOC
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: conf.c,v 1.9.4.55 2002/04/09 11:42:48 guus Exp $
|
||||
$Id: conf.c,v 1.9.4.56 2002/06/08 12:57:09 guus Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -255,8 +255,8 @@ cp
|
|||
|
||||
/* Teach newbies what subnets are... */
|
||||
|
||||
if(((subnet->type == SUBNET_IPV4) && maskcheck((char *)&subnet->net.ipv4.address, subnet->net.ipv4.prefixlength, sizeof(ipv4_t)))
|
||||
|| ((subnet->type == SUBNET_IPV6) && maskcheck((char *)&subnet->net.ipv6.address, subnet->net.ipv6.prefixlength, sizeof(ipv6_t))))
|
||||
if(((subnet->type == SUBNET_IPV4) && maskcheck(&subnet->net.ipv4.address, subnet->net.ipv4.prefixlength, sizeof(ipv4_t)))
|
||||
|| ((subnet->type == SUBNET_IPV6) && maskcheck(&subnet->net.ipv6.address, subnet->net.ipv6.prefixlength, sizeof(ipv6_t))))
|
||||
{
|
||||
syslog(LOG_ERR, _("Network address and prefix length do not match for configuration variable %s in %s line %d"),
|
||||
cfg->variable, cfg->file, cfg->line);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: graph.c,v 1.1.2.11 2002/03/24 16:28:27 guus Exp $
|
||||
$Id: graph.c,v 1.1.2.12 2002/06/08 12:57:09 guus Exp $
|
||||
*/
|
||||
|
||||
/* We need to generate two trees from the graph:
|
||||
|
@ -50,7 +50,7 @@
|
|||
#include <syslog.h>
|
||||
#include "config.h"
|
||||
#include <string.h>
|
||||
#if defined(HAVE_FREEBSD) || defined(HAVE_OPENBSD)
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#include <netinet/in.h>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: net.c,v 1.35.4.171 2002/05/01 09:15:58 guus Exp $
|
||||
$Id: net.c,v 1.35.4.172 2002/06/08 12:57:09 guus Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -26,8 +26,10 @@
|
|||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#ifdef HAVE_LINUX
|
||||
#ifdef HAVE_NETINET_IP_H
|
||||
#include <netinet/ip.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_TCP_H
|
||||
#include <netinet/tcp.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
|
16
src/net.h
16
src/net.h
|
@ -17,7 +17,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: net.h,v 1.9.4.49 2002/03/27 15:01:36 guus Exp $
|
||||
$Id: net.h,v 1.9.4.50 2002/06/08 12:57:09 guus Exp $
|
||||
*/
|
||||
|
||||
#ifndef __TINC_NET_H__
|
||||
|
@ -28,6 +28,10 @@
|
|||
#include <netinet/in.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef ENABLE_JUMBOGRAMS
|
||||
|
@ -46,12 +50,12 @@
|
|||
|
||||
typedef struct mac_t
|
||||
{
|
||||
unsigned char x[6];
|
||||
uint8_t x[6];
|
||||
} mac_t;
|
||||
|
||||
typedef struct ipv4_t
|
||||
{
|
||||
unsigned char x[4];
|
||||
uint8_t x[4];
|
||||
} ipv4_t;
|
||||
|
||||
typedef struct ip_mask_t {
|
||||
|
@ -61,7 +65,7 @@ typedef struct ip_mask_t {
|
|||
|
||||
typedef struct ipv6_t
|
||||
{
|
||||
unsigned short x[8];
|
||||
uint16_t x[8];
|
||||
} ipv6_t;
|
||||
|
||||
typedef unsigned short port_t;
|
||||
|
@ -83,8 +87,8 @@ typedef union {
|
|||
typedef struct vpn_packet_t {
|
||||
length_t len; /* the actual number of bytes in the `data' field */
|
||||
int priority; /* priority or TOS */
|
||||
unsigned int seqno; /* 32 bits sequence number (network byte order of course) */
|
||||
unsigned char data[MAXSIZE];
|
||||
uint32_t seqno; /* 32 bits sequence number (network byte order of course) */
|
||||
uint8_t data[MAXSIZE];
|
||||
} vpn_packet_t;
|
||||
|
||||
typedef struct queue_element_t {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: net_packet.c,v 1.1.2.14 2002/04/18 20:09:05 zarq Exp $
|
||||
$Id: net_packet.c,v 1.1.2.15 2002/06/08 12:57:09 guus Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -26,8 +26,10 @@
|
|||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#ifdef HAVE_LINUX
|
||||
#ifdef HAVE_NETINET_IP_H
|
||||
#include <netinet/ip.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_TCP_H
|
||||
#include <netinet/tcp.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: net_setup.c,v 1.1.2.16 2002/06/02 16:06:33 guus Exp $
|
||||
$Id: net_setup.c,v 1.1.2.17 2002/06/08 12:57:10 guus Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -26,8 +26,10 @@
|
|||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#ifdef HAVE_LINUX
|
||||
#ifdef HAVE_NETINET_IP_H
|
||||
#include <netinet/ip.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_TCP_H
|
||||
#include <netinet/tcp.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: net_socket.c,v 1.1.2.12 2002/04/18 20:09:05 zarq Exp $
|
||||
$Id: net_socket.c,v 1.1.2.13 2002/06/08 12:57:10 guus Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -26,8 +26,10 @@
|
|||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#ifdef HAVE_LINUX
|
||||
#ifdef HAVE_NETINET_IP_H
|
||||
#include <netinet/ip.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_TCP_H
|
||||
#include <netinet/tcp.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
@ -241,10 +243,12 @@ cp
|
|||
|
||||
/* Optimize TCP settings */
|
||||
|
||||
#ifdef HAVE_LINUX
|
||||
#if defined(SOL_TCP) && defined(TCP_NODELAY)
|
||||
option = 1;
|
||||
setsockopt(c->socket, SOL_TCP, TCP_NODELAY, &option, sizeof(option));
|
||||
#endif
|
||||
|
||||
#if defined(SOL_IP) && defined(IP_TOS)
|
||||
option = IPTOS_LOWDELAY;
|
||||
setsockopt(c->socket, SOL_IP, IP_TOS, &option, sizeof(option));
|
||||
#endif
|
||||
|
@ -337,10 +341,12 @@ begin:
|
|||
|
||||
/* Optimize TCP settings */
|
||||
|
||||
#ifdef HAVE_LINUX
|
||||
#if defined(SOL_TCP) && defined(TCP_NODELAY)
|
||||
option = 1;
|
||||
setsockopt(c->socket, SOL_TCP, TCP_NODELAY, &option, sizeof(option));
|
||||
#endif
|
||||
|
||||
#if defined(SOL_IP) && defined(IP_TOS)
|
||||
option = IPTOS_LOWDELAY;
|
||||
setsockopt(c->socket, SOL_IP, IP_TOS, &option, sizeof(option));
|
||||
#endif
|
||||
|
|
20
src/netutl.c
20
src/netutl.c
|
@ -17,7 +17,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: netutl.c,v 1.12.4.37 2002/06/07 11:14:05 wsl Exp $
|
||||
$Id: netutl.c,v 1.12.4.38 2002/06/08 12:57:10 guus Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -27,7 +27,7 @@
|
|||
#include <netinet/in.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifndef HAVE_NETBSD
|
||||
#ifndef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
@ -115,10 +115,8 @@ cp
|
|||
exit(0);
|
||||
}
|
||||
|
||||
#ifdef HAVE_LINUX
|
||||
if((scopeid = strchr(address, '%')))
|
||||
*scopeid = '\0'; /* Descope. */
|
||||
#endif
|
||||
|
||||
*addrstr = xstrdup(address);
|
||||
*portstr = xstrdup(port);
|
||||
|
@ -185,9 +183,11 @@ void sockaddrunmap(sockaddr_t *sa)
|
|||
|
||||
/* Subnet mask handling */
|
||||
|
||||
int maskcmp(char *a, char *b, int masklen, int len)
|
||||
int maskcmp(void *va, void *vb, int masklen, int len)
|
||||
{
|
||||
int i, m, result;
|
||||
char *a = va;
|
||||
char *b = vb;
|
||||
cp
|
||||
for(m = masklen, i = 0; m >= 8; m -= 8, i++)
|
||||
if((result = a[i] - b[i]))
|
||||
|
@ -199,9 +199,10 @@ cp
|
|||
return 0;
|
||||
}
|
||||
|
||||
void mask(char *a, int masklen, int len)
|
||||
void mask(void *va, int masklen, int len)
|
||||
{
|
||||
int i;
|
||||
char *a = va;
|
||||
cp
|
||||
i = masklen / 8;
|
||||
masklen %= 8;
|
||||
|
@ -213,9 +214,11 @@ cp
|
|||
a[i] = 0;
|
||||
}
|
||||
|
||||
void maskcpy(char *a, char *b, int masklen, int len)
|
||||
void maskcpy(void *va, void *vb, int masklen, int len)
|
||||
{
|
||||
int i, m;
|
||||
char *a = va;
|
||||
char *b = vb;
|
||||
cp
|
||||
for(m = masklen, i = 0; m >= 8; m -= 8, i++)
|
||||
a[i] = b[i];
|
||||
|
@ -230,9 +233,10 @@ cp
|
|||
a[i] = 0;
|
||||
}
|
||||
|
||||
int maskcheck(char *a, int masklen, int len)
|
||||
int maskcheck(void *va, int masklen, int len)
|
||||
{
|
||||
int i;
|
||||
char *a = va;
|
||||
cp
|
||||
i = masklen / 8;
|
||||
masklen %= 8;
|
||||
|
|
11
src/netutl.h
11
src/netutl.h
|
@ -17,7 +17,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: netutl.h,v 1.2.4.11 2002/03/17 15:59:29 guus Exp $
|
||||
$Id: netutl.h,v 1.2.4.12 2002/06/08 12:57:10 guus Exp $
|
||||
*/
|
||||
|
||||
#ifndef __TINC_NETUTL_H__
|
||||
|
@ -31,16 +31,15 @@
|
|||
|
||||
extern int hostnames;
|
||||
|
||||
extern char *hostlookup(unsigned long);
|
||||
extern struct addrinfo *str2addrinfo(char *, char *, int);
|
||||
extern sockaddr_t str2sockaddr(char *, char *);
|
||||
extern void sockaddr2str(sockaddr_t *, char **, char **);
|
||||
extern char *sockaddr2hostname(sockaddr_t *);
|
||||
extern int sockaddrcmp(sockaddr_t *, sockaddr_t *);
|
||||
extern void sockaddrunmap(sockaddr_t *);
|
||||
extern int maskcmp(char *, char *, int, int);
|
||||
extern void maskcpy(char *, char *, int, int);
|
||||
extern void mask(char *, int, int);
|
||||
extern int maskcheck(char *, int, int);
|
||||
extern int maskcmp(void *, void *, int, int);
|
||||
extern void maskcpy(void *, void *, int, int);
|
||||
extern void mask(void *, int, int);
|
||||
extern int maskcheck(void *, int, int);
|
||||
|
||||
#endif /* __TINC_NETUTL_H__ */
|
||||
|
|
10
src/node.h
10
src/node.h
|
@ -17,12 +17,16 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: node.h,v 1.1.2.13 2002/03/19 22:48:25 guus Exp $
|
||||
$Id: node.h,v 1.1.2.14 2002/06/08 12:57:10 guus Exp $
|
||||
*/
|
||||
|
||||
#ifndef __TINC_NODE_H__
|
||||
#define __TINC_NODE_H__
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include <avl_tree.h>
|
||||
|
||||
#include "subnet.h"
|
||||
|
@ -67,8 +71,8 @@ typedef struct node_t {
|
|||
|
||||
struct connection_t *connection; /* Connection associated with this node (if a direct connection exists) */
|
||||
|
||||
unsigned int sent_seqno; /* Sequence number last sent to this node */
|
||||
unsigned int received_seqno; /* Sequence number last received from this node */
|
||||
uint32_t sent_seqno; /* Sequence number last sent to this node */
|
||||
uint32_t received_seqno; /* Sequence number last received from this node */
|
||||
} node_t;
|
||||
|
||||
extern struct node_t *myself;
|
||||
|
|
60
src/route.c
60
src/route.c
|
@ -17,20 +17,20 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: route.c,v 1.1.2.39 2002/06/05 00:25:55 guus Exp $
|
||||
$Id: route.c,v 1.1.2.40 2002/06/08 12:57:10 guus Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if defined(HAVE_FREEBSD) || defined(HAVE_OPENBSD) || defined(HAVE_NETBSD)
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#if defined(HAVE_SOLARIS) || defined(HAVE_OPENBSD) || defined(HAVE_NETBSD)
|
||||
#ifdef HAVE_NET_IF_H
|
||||
#include <net/if.h>
|
||||
#define ETHER_ADDR_LEN 6
|
||||
#else
|
||||
#endif
|
||||
#ifdef HAVE_NET_ETHERNET_H
|
||||
#include <net/ethernet.h>
|
||||
#endif
|
||||
#include <netinet/ip6.h>
|
||||
|
@ -40,7 +40,7 @@
|
|||
#include <xalloc.h>
|
||||
#include <syslog.h>
|
||||
#include <string.h>
|
||||
#ifndef HAVE_NETBSD
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
|
@ -55,6 +55,10 @@
|
|||
|
||||
#include "system.h"
|
||||
|
||||
#ifndef ETHER_ADDR_LEN
|
||||
#define ETHER_ADDR_LEN 6
|
||||
#endif
|
||||
|
||||
int routing_mode = RMODE_ROUTER;
|
||||
int priorityinheritance = 0;
|
||||
int macexpire = 600;
|
||||
|
@ -173,14 +177,14 @@ cp
|
|||
if(debug_lvl >= DEBUG_TRAFFIC)
|
||||
{
|
||||
syslog(LOG_WARNING, _("Cannot route packet: unknown IPv6 destination address %hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx"),
|
||||
ntohs(*(short unsigned int *)&packet->data[38]),
|
||||
ntohs(*(short unsigned int *)&packet->data[40]),
|
||||
ntohs(*(short unsigned int *)&packet->data[42]),
|
||||
ntohs(*(short unsigned int *)&packet->data[44]),
|
||||
ntohs(*(short unsigned int *)&packet->data[46]),
|
||||
ntohs(*(short unsigned int *)&packet->data[48]),
|
||||
ntohs(*(short unsigned int *)&packet->data[50]),
|
||||
ntohs(*(short unsigned int *)&packet->data[52]));
|
||||
ntohs(*(uint16_t *)&packet->data[38]),
|
||||
ntohs(*(uint16_t *)&packet->data[40]),
|
||||
ntohs(*(uint16_t *)&packet->data[42]),
|
||||
ntohs(*(uint16_t *)&packet->data[44]),
|
||||
ntohs(*(uint16_t *)&packet->data[46]),
|
||||
ntohs(*(uint16_t *)&packet->data[48]),
|
||||
ntohs(*(uint16_t *)&packet->data[50]),
|
||||
ntohs(*(uint16_t *)&packet->data[52]));
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -189,9 +193,9 @@ cp
|
|||
return subnet->owner;
|
||||
}
|
||||
|
||||
unsigned short int inet_checksum(unsigned short int *data, int len, unsigned short int prevsum)
|
||||
uint16_t inet_checksum(uint16_t *data, int len, uint16_t prevsum)
|
||||
{
|
||||
unsigned long int checksum = prevsum ^ 0xFFFF;
|
||||
uint32_t checksum = prevsum ^ 0xFFFF;
|
||||
|
||||
while(len--)
|
||||
checksum += ntohs(*data++);
|
||||
|
@ -208,7 +212,7 @@ void route_neighborsol(vpn_packet_t *packet)
|
|||
struct nd_neighbor_solicit *ns;
|
||||
struct nd_opt_hdr *opt;
|
||||
subnet_t *subnet;
|
||||
short unsigned int checksum;
|
||||
uint16_t checksum;
|
||||
|
||||
struct {
|
||||
struct in6_addr ip6_src; /* source address */
|
||||
|
@ -248,8 +252,8 @@ cp
|
|||
|
||||
/* Generate checksum */
|
||||
|
||||
checksum = inet_checksum((unsigned short int *)&pseudo, sizeof(pseudo)/2, ~0);
|
||||
checksum = inet_checksum((unsigned short int *)ns, sizeof(*ns)/2 + 4, checksum);
|
||||
checksum = inet_checksum((uint16_t *)&pseudo, sizeof(pseudo)/2, ~0);
|
||||
checksum = inet_checksum((uint16_t *)ns, sizeof(*ns)/2 + 4, checksum);
|
||||
|
||||
if(checksum)
|
||||
{
|
||||
|
@ -305,8 +309,8 @@ cp
|
|||
|
||||
/* Generate checksum */
|
||||
|
||||
checksum = inet_checksum((unsigned short int *)&pseudo, sizeof(pseudo)/2, ~0);
|
||||
checksum = inet_checksum((unsigned short int *)ns, sizeof(*ns)/2 + 4, checksum);
|
||||
checksum = inet_checksum((uint16_t *)&pseudo, sizeof(pseudo)/2, ~0);
|
||||
checksum = inet_checksum((uint16_t *)ns, sizeof(*ns)/2 + 4, checksum);
|
||||
|
||||
ns->nd_ns_hdr.icmp6_cksum = htons(checksum);
|
||||
|
||||
|
@ -318,7 +322,7 @@ void route_arp(vpn_packet_t *packet)
|
|||
{
|
||||
struct ether_arp *arp;
|
||||
subnet_t *subnet;
|
||||
unsigned char ipbuf[4];
|
||||
uint8_t ipbuf[4];
|
||||
cp
|
||||
/* First, snatch the source address from the ARP packet */
|
||||
|
||||
|
@ -335,8 +339,8 @@ cp
|
|||
|
||||
if(ntohs(arp->arp_hrd) != ARPHRD_ETHER ||
|
||||
ntohs(arp->arp_pro) != ETHERTYPE_IP ||
|
||||
(int) (arp->arp_hln) != ETHER_ADDR_LEN ||
|
||||
(int) (arp->arp_pln) != 4 ||
|
||||
arp->arp_hln != ETHER_ADDR_LEN ||
|
||||
arp->arp_pln != 4 ||
|
||||
ntohs(arp->arp_op) != ARPOP_REQUEST )
|
||||
{
|
||||
if(debug_lvl > DEBUG_TRAFFIC)
|
||||
|
@ -383,7 +387,7 @@ cp
|
|||
|
||||
void route_outgoing(vpn_packet_t *packet)
|
||||
{
|
||||
unsigned short int type;
|
||||
uint16_t type;
|
||||
node_t *n = NULL;
|
||||
cp
|
||||
/* FIXME: multicast? */
|
||||
|
@ -391,7 +395,7 @@ cp
|
|||
switch(routing_mode)
|
||||
{
|
||||
case RMODE_ROUTER:
|
||||
type = ntohs(*((unsigned short*)(&packet->data[12])));
|
||||
type = ntohs(*((uint16_t *)(&packet->data[12])));
|
||||
switch(type)
|
||||
{
|
||||
case 0x0800:
|
||||
|
@ -440,9 +444,9 @@ void route_incoming(node_t *source, vpn_packet_t *packet)
|
|||
case RMODE_ROUTER:
|
||||
{
|
||||
node_t *n = NULL;
|
||||
unsigned short int type;
|
||||
uint16_t type;
|
||||
|
||||
type = ntohs(*((unsigned short*)(&packet->data[12])));
|
||||
type = ntohs(*((uint16_t *)(&packet->data[12])));
|
||||
switch(type)
|
||||
{
|
||||
case 0x0800:
|
||||
|
|
12
src/subnet.c
12
src/subnet.c
|
@ -17,7 +17,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: subnet.c,v 1.1.2.35 2002/04/26 18:13:00 zarq Exp $
|
||||
$Id: subnet.c,v 1.1.2.36 2002/06/08 12:57:10 guus Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -176,7 +176,7 @@ subnet_t *str2net(char *subnetstr)
|
|||
{
|
||||
int i, l;
|
||||
subnet_t *subnet;
|
||||
unsigned short int x[8];
|
||||
uint16_t x[8];
|
||||
cp
|
||||
subnet = new_subnet();
|
||||
cp
|
||||
|
@ -323,14 +323,14 @@ cp
|
|||
break;
|
||||
}
|
||||
|
||||
if (!maskcmp((char *)address, (char *)&p->net.ipv4.address, p->net.ipv4.prefixlength, sizeof(ipv4_t)))
|
||||
if (!maskcmp(address, &p->net.ipv4.address, p->net.ipv4.prefixlength, sizeof(ipv4_t)))
|
||||
break;
|
||||
else
|
||||
{
|
||||
/* Otherwise, see if there is a bigger enclosing subnet */
|
||||
|
||||
subnet.net.ipv4.prefixlength = p->net.ipv4.prefixlength - 1;
|
||||
maskcpy((char *)&subnet.net.ipv4.address, (char *)&p->net.ipv4.address, subnet.net.ipv4.prefixlength, sizeof(ipv4_t));
|
||||
maskcpy(&subnet.net.ipv4.address, &p->net.ipv4.address, subnet.net.ipv4.prefixlength, sizeof(ipv4_t));
|
||||
}
|
||||
}
|
||||
} while (p);
|
||||
|
@ -360,14 +360,14 @@ cp
|
|||
if(p->type != SUBNET_IPV6)
|
||||
return NULL;
|
||||
|
||||
if (!maskcmp((char *)address, (char *)&p->net.ipv6.address, p->net.ipv6.prefixlength, sizeof(ipv6_t)))
|
||||
if (!maskcmp(address, &p->net.ipv6.address, p->net.ipv6.prefixlength, sizeof(ipv6_t)))
|
||||
break;
|
||||
else
|
||||
{
|
||||
/* Otherwise, see if there is a bigger enclosing subnet */
|
||||
|
||||
subnet.net.ipv6.prefixlength = p->net.ipv6.prefixlength - 1;
|
||||
maskcpy((char *)&subnet.net.ipv6.address, (char *)&p->net.ipv6.address, subnet.net.ipv6.prefixlength, sizeof(ipv6_t));
|
||||
maskcpy(&subnet.net.ipv6.address, &p->net.ipv6.address, subnet.net.ipv6.prefixlength, sizeof(ipv6_t));
|
||||
}
|
||||
}
|
||||
} while (p);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: tincd.c,v 1.10.4.58 2002/03/11 11:23:04 guus Exp $
|
||||
$Id: tincd.c,v 1.10.4.59 2002/06/08 12:57:10 guus Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -338,7 +338,7 @@ main(int argc, char **argv, char **envp)
|
|||
if(show_help)
|
||||
usage(0);
|
||||
|
||||
#ifdef HAVE_SOLARIS
|
||||
#ifndef LOG_PERROR
|
||||
openlog("tinc", LOG_CONS, LOG_DAEMON); /* Catch all syslog() calls issued before detaching */
|
||||
#else
|
||||
openlog("tinc", LOG_PERROR, LOG_DAEMON); /* Catch all syslog() calls issued before detaching */
|
||||
|
|
Loading…
Reference in a new issue