- 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:
Guus Sliepen 2002-06-08 12:57:10 +00:00
parent d333fca4d6
commit 116ba3b3da
14 changed files with 107 additions and 79 deletions

View file

@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script. 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) AC_INIT(src/tincd.c)
AM_INIT_AUTOMAKE(tinc, 1.0-cvs) AM_INIT_AUTOMAKE(tinc, 1.0-cvs)
@ -69,8 +69,9 @@ dnl Checks for libraries.
dnl Checks for header files. dnl Checks for header files.
AC_HEADER_STDC AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h limits.h sys/ioctl.h syslog.h unistd.h \ AC_CHECK_HEADERS([fcntl.h limits.h malloc.h stdint.h strings.h syslog.h unistd.h \
sys/time.h malloc.h strings.h sys/file.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. dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST AC_C_CONST
@ -95,8 +96,8 @@ dnl Checks for library functions.
AC_FUNC_MEMCMP AC_FUNC_MEMCMP
AC_FUNC_ALLOCA AC_FUNC_ALLOCA
AC_TYPE_SIGNAL AC_TYPE_SIGNAL
AC_CHECK_FUNCS([ftime socket select strtol strerror flock unsetenv \ AC_CHECK_FUNCS([asprintf daemon fcloseall flock ftime get_current_dir_name \
asprintf putenv strdup fcloseall daemon strsignal get_current_dir_name]) putenv select strdup strerror strsignal strtol unsetenv])
jm_FUNC_MALLOC jm_FUNC_MALLOC
jm_FUNC_REALLOC jm_FUNC_REALLOC

View file

@ -19,7 +19,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -255,8 +255,8 @@ cp
/* Teach newbies what subnets are... */ /* Teach newbies what subnets are... */
if(((subnet->type == SUBNET_IPV4) && maskcheck((char *)&subnet->net.ipv4.address, subnet->net.ipv4.prefixlength, sizeof(ipv4_t))) if(((subnet->type == SUBNET_IPV4) && maskcheck(&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)))) || ((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"), 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); cfg->variable, cfg->file, cfg->line);

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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: /* We need to generate two trees from the graph:
@ -50,7 +50,7 @@
#include <syslog.h> #include <syslog.h>
#include "config.h" #include "config.h"
#include <string.h> #include <string.h>
#if defined(HAVE_FREEBSD) || defined(HAVE_OPENBSD) #ifdef HAVE_SYS_PARAM_H
#include <sys/param.h> #include <sys/param.h>
#endif #endif
#include <netinet/in.h> #include <netinet/in.h>

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -26,8 +26,10 @@
#include <fcntl.h> #include <fcntl.h>
#include <netdb.h> #include <netdb.h>
#include <netinet/in.h> #include <netinet/in.h>
#ifdef HAVE_LINUX #ifdef HAVE_NETINET_IP_H
#include <netinet/ip.h> #include <netinet/ip.h>
#endif
#ifdef HAVE_NETINET_TCP_H
#include <netinet/tcp.h> #include <netinet/tcp.h>
#endif #endif
#include <stdio.h> #include <stdio.h>

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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__ #ifndef __TINC_NET_H__
@ -28,6 +28,10 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <sys/time.h> #include <sys/time.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include "config.h" #include "config.h"
#ifdef ENABLE_JUMBOGRAMS #ifdef ENABLE_JUMBOGRAMS
@ -46,12 +50,12 @@
typedef struct mac_t typedef struct mac_t
{ {
unsigned char x[6]; uint8_t x[6];
} mac_t; } mac_t;
typedef struct ipv4_t typedef struct ipv4_t
{ {
unsigned char x[4]; uint8_t x[4];
} ipv4_t; } ipv4_t;
typedef struct ip_mask_t { typedef struct ip_mask_t {
@ -61,7 +65,7 @@ typedef struct ip_mask_t {
typedef struct ipv6_t typedef struct ipv6_t
{ {
unsigned short x[8]; uint16_t x[8];
} ipv6_t; } ipv6_t;
typedef unsigned short port_t; typedef unsigned short port_t;
@ -83,8 +87,8 @@ typedef union {
typedef struct vpn_packet_t { typedef struct vpn_packet_t {
length_t len; /* the actual number of bytes in the `data' field */ length_t len; /* the actual number of bytes in the `data' field */
int priority; /* priority or TOS */ int priority; /* priority or TOS */
unsigned int seqno; /* 32 bits sequence number (network byte order of course) */ uint32_t seqno; /* 32 bits sequence number (network byte order of course) */
unsigned char data[MAXSIZE]; uint8_t data[MAXSIZE];
} vpn_packet_t; } vpn_packet_t;
typedef struct queue_element_t { typedef struct queue_element_t {

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -26,8 +26,10 @@
#include <fcntl.h> #include <fcntl.h>
#include <netdb.h> #include <netdb.h>
#include <netinet/in.h> #include <netinet/in.h>
#ifdef HAVE_LINUX #ifdef HAVE_NETINET_IP_H
#include <netinet/ip.h> #include <netinet/ip.h>
#endif
#ifdef HAVE_NETINET_TCP_H
#include <netinet/tcp.h> #include <netinet/tcp.h>
#endif #endif
#include <stdio.h> #include <stdio.h>

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -26,8 +26,10 @@
#include <fcntl.h> #include <fcntl.h>
#include <netdb.h> #include <netdb.h>
#include <netinet/in.h> #include <netinet/in.h>
#ifdef HAVE_LINUX #ifdef HAVE_NETINET_IP_H
#include <netinet/ip.h> #include <netinet/ip.h>
#endif
#ifdef HAVE_NETINET_TCP_H
#include <netinet/tcp.h> #include <netinet/tcp.h>
#endif #endif
#include <stdio.h> #include <stdio.h>

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -26,8 +26,10 @@
#include <fcntl.h> #include <fcntl.h>
#include <netdb.h> #include <netdb.h>
#include <netinet/in.h> #include <netinet/in.h>
#ifdef HAVE_LINUX #ifdef HAVE_NETINET_IP_H
#include <netinet/ip.h> #include <netinet/ip.h>
#endif
#ifdef HAVE_NETINET_TCP_H
#include <netinet/tcp.h> #include <netinet/tcp.h>
#endif #endif
#include <stdio.h> #include <stdio.h>
@ -241,10 +243,12 @@ cp
/* Optimize TCP settings */ /* Optimize TCP settings */
#ifdef HAVE_LINUX #if defined(SOL_TCP) && defined(TCP_NODELAY)
option = 1; option = 1;
setsockopt(c->socket, SOL_TCP, TCP_NODELAY, &option, sizeof(option)); setsockopt(c->socket, SOL_TCP, TCP_NODELAY, &option, sizeof(option));
#endif
#if defined(SOL_IP) && defined(IP_TOS)
option = IPTOS_LOWDELAY; option = IPTOS_LOWDELAY;
setsockopt(c->socket, SOL_IP, IP_TOS, &option, sizeof(option)); setsockopt(c->socket, SOL_IP, IP_TOS, &option, sizeof(option));
#endif #endif
@ -337,10 +341,12 @@ begin:
/* Optimize TCP settings */ /* Optimize TCP settings */
#ifdef HAVE_LINUX #if defined(SOL_TCP) && defined(TCP_NODELAY)
option = 1; option = 1;
setsockopt(c->socket, SOL_TCP, TCP_NODELAY, &option, sizeof(option)); setsockopt(c->socket, SOL_TCP, TCP_NODELAY, &option, sizeof(option));
#endif
#if defined(SOL_IP) && defined(IP_TOS)
option = IPTOS_LOWDELAY; option = IPTOS_LOWDELAY;
setsockopt(c->socket, SOL_IP, IP_TOS, &option, sizeof(option)); setsockopt(c->socket, SOL_IP, IP_TOS, &option, sizeof(option));
#endif #endif

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -27,7 +27,7 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#ifndef HAVE_NETBSD #ifndef HAVE_STDINT_H
#include <stdint.h> #include <stdint.h>
#endif #endif
#include <string.h> #include <string.h>
@ -115,10 +115,8 @@ cp
exit(0); exit(0);
} }
#ifdef HAVE_LINUX
if((scopeid = strchr(address, '%'))) if((scopeid = strchr(address, '%')))
*scopeid = '\0'; /* Descope. */ *scopeid = '\0'; /* Descope. */
#endif
*addrstr = xstrdup(address); *addrstr = xstrdup(address);
*portstr = xstrdup(port); *portstr = xstrdup(port);
@ -185,9 +183,11 @@ void sockaddrunmap(sockaddr_t *sa)
/* Subnet mask handling */ /* 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; int i, m, result;
char *a = va;
char *b = vb;
cp cp
for(m = masklen, i = 0; m >= 8; m -= 8, i++) for(m = masklen, i = 0; m >= 8; m -= 8, i++)
if((result = a[i] - b[i])) if((result = a[i] - b[i]))
@ -199,9 +199,10 @@ cp
return 0; return 0;
} }
void mask(char *a, int masklen, int len) void mask(void *va, int masklen, int len)
{ {
int i; int i;
char *a = va;
cp cp
i = masklen / 8; i = masklen / 8;
masklen %= 8; masklen %= 8;
@ -213,9 +214,11 @@ cp
a[i] = 0; 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; int i, m;
char *a = va;
char *b = vb;
cp cp
for(m = masklen, i = 0; m >= 8; m -= 8, i++) for(m = masklen, i = 0; m >= 8; m -= 8, i++)
a[i] = b[i]; a[i] = b[i];
@ -230,9 +233,10 @@ cp
a[i] = 0; a[i] = 0;
} }
int maskcheck(char *a, int masklen, int len) int maskcheck(void *va, int masklen, int len)
{ {
int i; int i;
char *a = va;
cp cp
i = masklen / 8; i = masklen / 8;
masklen %= 8; masklen %= 8;

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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__ #ifndef __TINC_NETUTL_H__
@ -31,16 +31,15 @@
extern int hostnames; extern int hostnames;
extern char *hostlookup(unsigned long);
extern struct addrinfo *str2addrinfo(char *, char *, int); extern struct addrinfo *str2addrinfo(char *, char *, int);
extern sockaddr_t str2sockaddr(char *, char *); extern sockaddr_t str2sockaddr(char *, char *);
extern void sockaddr2str(sockaddr_t *, char **, char **); extern void sockaddr2str(sockaddr_t *, char **, char **);
extern char *sockaddr2hostname(sockaddr_t *); extern char *sockaddr2hostname(sockaddr_t *);
extern int sockaddrcmp(sockaddr_t *, sockaddr_t *); extern int sockaddrcmp(sockaddr_t *, sockaddr_t *);
extern void sockaddrunmap(sockaddr_t *); extern void sockaddrunmap(sockaddr_t *);
extern int maskcmp(char *, char *, int, int); extern int maskcmp(void *, void *, int, int);
extern void maskcpy(char *, char *, int, int); extern void maskcpy(void *, void *, int, int);
extern void mask(char *, int, int); extern void mask(void *, int, int);
extern int maskcheck(char *, int, int); extern int maskcheck(void *, int, int);
#endif /* __TINC_NETUTL_H__ */ #endif /* __TINC_NETUTL_H__ */

View file

@ -17,12 +17,16 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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__ #ifndef __TINC_NODE_H__
#define __TINC_NODE_H__ #define __TINC_NODE_H__
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <avl_tree.h> #include <avl_tree.h>
#include "subnet.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) */ 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 */ uint32_t sent_seqno; /* Sequence number last sent to this node */
unsigned int received_seqno; /* Sequence number last received from this node */ uint32_t received_seqno; /* Sequence number last received from this node */
} node_t; } node_t;
extern struct node_t *myself; extern struct node_t *myself;

View file

@ -17,20 +17,20 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
#if defined(HAVE_FREEBSD) || defined(HAVE_OPENBSD) || defined(HAVE_NETBSD) #ifdef HAVE_SYS_PARAM_H
#include <sys/param.h> #include <sys/param.h>
#endif #endif
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#if defined(HAVE_SOLARIS) || defined(HAVE_OPENBSD) || defined(HAVE_NETBSD) #ifdef HAVE_NET_IF_H
#include <net/if.h> #include <net/if.h>
#define ETHER_ADDR_LEN 6 #endif
#else #ifdef HAVE_NET_ETHERNET_H
#include <net/ethernet.h> #include <net/ethernet.h>
#endif #endif
#include <netinet/ip6.h> #include <netinet/ip6.h>
@ -40,7 +40,7 @@
#include <xalloc.h> #include <xalloc.h>
#include <syslog.h> #include <syslog.h>
#include <string.h> #include <string.h>
#ifndef HAVE_NETBSD #ifdef HAVE_STDINT_H
#include <stdint.h> #include <stdint.h>
#endif #endif
@ -55,6 +55,10 @@
#include "system.h" #include "system.h"
#ifndef ETHER_ADDR_LEN
#define ETHER_ADDR_LEN 6
#endif
int routing_mode = RMODE_ROUTER; int routing_mode = RMODE_ROUTER;
int priorityinheritance = 0; int priorityinheritance = 0;
int macexpire = 600; int macexpire = 600;
@ -173,14 +177,14 @@ cp
if(debug_lvl >= DEBUG_TRAFFIC) if(debug_lvl >= DEBUG_TRAFFIC)
{ {
syslog(LOG_WARNING, _("Cannot route packet: unknown IPv6 destination address %hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx"), 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(*(uint16_t *)&packet->data[38]),
ntohs(*(short unsigned int *)&packet->data[40]), ntohs(*(uint16_t *)&packet->data[40]),
ntohs(*(short unsigned int *)&packet->data[42]), ntohs(*(uint16_t *)&packet->data[42]),
ntohs(*(short unsigned int *)&packet->data[44]), ntohs(*(uint16_t *)&packet->data[44]),
ntohs(*(short unsigned int *)&packet->data[46]), ntohs(*(uint16_t *)&packet->data[46]),
ntohs(*(short unsigned int *)&packet->data[48]), ntohs(*(uint16_t *)&packet->data[48]),
ntohs(*(short unsigned int *)&packet->data[50]), ntohs(*(uint16_t *)&packet->data[50]),
ntohs(*(short unsigned int *)&packet->data[52])); ntohs(*(uint16_t *)&packet->data[52]));
} }
return NULL; return NULL;
@ -189,9 +193,9 @@ cp
return subnet->owner; 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--) while(len--)
checksum += ntohs(*data++); checksum += ntohs(*data++);
@ -208,7 +212,7 @@ void route_neighborsol(vpn_packet_t *packet)
struct nd_neighbor_solicit *ns; struct nd_neighbor_solicit *ns;
struct nd_opt_hdr *opt; struct nd_opt_hdr *opt;
subnet_t *subnet; subnet_t *subnet;
short unsigned int checksum; uint16_t checksum;
struct { struct {
struct in6_addr ip6_src; /* source address */ struct in6_addr ip6_src; /* source address */
@ -248,8 +252,8 @@ cp
/* Generate checksum */ /* Generate checksum */
checksum = inet_checksum((unsigned short int *)&pseudo, sizeof(pseudo)/2, ~0); checksum = inet_checksum((uint16_t *)&pseudo, sizeof(pseudo)/2, ~0);
checksum = inet_checksum((unsigned short int *)ns, sizeof(*ns)/2 + 4, checksum); checksum = inet_checksum((uint16_t *)ns, sizeof(*ns)/2 + 4, checksum);
if(checksum) if(checksum)
{ {
@ -305,8 +309,8 @@ cp
/* Generate checksum */ /* Generate checksum */
checksum = inet_checksum((unsigned short int *)&pseudo, sizeof(pseudo)/2, ~0); checksum = inet_checksum((uint16_t *)&pseudo, sizeof(pseudo)/2, ~0);
checksum = inet_checksum((unsigned short int *)ns, sizeof(*ns)/2 + 4, checksum); checksum = inet_checksum((uint16_t *)ns, sizeof(*ns)/2 + 4, checksum);
ns->nd_ns_hdr.icmp6_cksum = htons(checksum); ns->nd_ns_hdr.icmp6_cksum = htons(checksum);
@ -318,7 +322,7 @@ void route_arp(vpn_packet_t *packet)
{ {
struct ether_arp *arp; struct ether_arp *arp;
subnet_t *subnet; subnet_t *subnet;
unsigned char ipbuf[4]; uint8_t ipbuf[4];
cp cp
/* First, snatch the source address from the ARP packet */ /* First, snatch the source address from the ARP packet */
@ -335,8 +339,8 @@ cp
if(ntohs(arp->arp_hrd) != ARPHRD_ETHER || if(ntohs(arp->arp_hrd) != ARPHRD_ETHER ||
ntohs(arp->arp_pro) != ETHERTYPE_IP || ntohs(arp->arp_pro) != ETHERTYPE_IP ||
(int) (arp->arp_hln) != ETHER_ADDR_LEN || arp->arp_hln != ETHER_ADDR_LEN ||
(int) (arp->arp_pln) != 4 || arp->arp_pln != 4 ||
ntohs(arp->arp_op) != ARPOP_REQUEST ) ntohs(arp->arp_op) != ARPOP_REQUEST )
{ {
if(debug_lvl > DEBUG_TRAFFIC) if(debug_lvl > DEBUG_TRAFFIC)
@ -383,7 +387,7 @@ cp
void route_outgoing(vpn_packet_t *packet) void route_outgoing(vpn_packet_t *packet)
{ {
unsigned short int type; uint16_t type;
node_t *n = NULL; node_t *n = NULL;
cp cp
/* FIXME: multicast? */ /* FIXME: multicast? */
@ -391,7 +395,7 @@ cp
switch(routing_mode) switch(routing_mode)
{ {
case RMODE_ROUTER: case RMODE_ROUTER:
type = ntohs(*((unsigned short*)(&packet->data[12]))); type = ntohs(*((uint16_t *)(&packet->data[12])));
switch(type) switch(type)
{ {
case 0x0800: case 0x0800:
@ -440,9 +444,9 @@ void route_incoming(node_t *source, vpn_packet_t *packet)
case RMODE_ROUTER: case RMODE_ROUTER:
{ {
node_t *n = NULL; 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) switch(type)
{ {
case 0x0800: case 0x0800:

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -176,7 +176,7 @@ subnet_t *str2net(char *subnetstr)
{ {
int i, l; int i, l;
subnet_t *subnet; subnet_t *subnet;
unsigned short int x[8]; uint16_t x[8];
cp cp
subnet = new_subnet(); subnet = new_subnet();
cp cp
@ -323,14 +323,14 @@ cp
break; 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; break;
else else
{ {
/* Otherwise, see if there is a bigger enclosing subnet */ /* Otherwise, see if there is a bigger enclosing subnet */
subnet.net.ipv4.prefixlength = p->net.ipv4.prefixlength - 1; 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); } while (p);
@ -360,14 +360,14 @@ cp
if(p->type != SUBNET_IPV6) if(p->type != SUBNET_IPV6)
return NULL; 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; break;
else else
{ {
/* Otherwise, see if there is a bigger enclosing subnet */ /* Otherwise, see if there is a bigger enclosing subnet */
subnet.net.ipv6.prefixlength = p->net.ipv6.prefixlength - 1; 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); } while (p);

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -338,7 +338,7 @@ main(int argc, char **argv, char **envp)
if(show_help) if(show_help)
usage(0); usage(0);
#ifdef HAVE_SOLARIS #ifndef LOG_PERROR
openlog("tinc", LOG_CONS, LOG_DAEMON); /* Catch all syslog() calls issued before detaching */ openlog("tinc", LOG_CONS, LOG_DAEMON); /* Catch all syslog() calls issued before detaching */
#else #else
openlog("tinc", LOG_PERROR, LOG_DAEMON); /* Catch all syslog() calls issued before detaching */ openlog("tinc", LOG_PERROR, LOG_DAEMON); /* Catch all syslog() calls issued before detaching */