mirror of
https://github.com/the-tcpdump-group/tcpdump.git
synced 2024-11-23 18:14:29 +08:00
From Gisle Vanem: make print-esp.c work with more (maybe all?) OpenSSL
versions, and changes to make it work on DOS/Windows with various compilers and C support libraries.
This commit is contained in:
parent
dbc1ec5ef1
commit
24f5540899
1
FILES
1
FILES
@ -71,6 +71,7 @@ missing/sockstorage.h
|
||||
missing/strdup.c
|
||||
missing/strlcat.c
|
||||
missing/strlcpy.c
|
||||
missing/strsep.c
|
||||
mkdep
|
||||
nameser.h
|
||||
netbios.h
|
||||
|
@ -184,6 +184,9 @@
|
||||
/* Define if you have the strlcpy function. */
|
||||
#undef HAVE_STRLCPY
|
||||
|
||||
/* Define if you have the strsep function. */
|
||||
#undef HAVE_STRSEP
|
||||
|
||||
/* Define if you have the vfprintf function. */
|
||||
#undef HAVE_VFPRINTF
|
||||
|
||||
|
2
configure
vendored
2
configure
vendored
@ -2889,7 +2889,7 @@ if test "$missing_includes" = "yes"; then
|
||||
fi
|
||||
|
||||
|
||||
for ac_func in vfprintf strcasecmp strlcat strlcpy strdup
|
||||
for ac_func in vfprintf strcasecmp strlcat strlcpy strdup strsep
|
||||
do
|
||||
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
|
||||
echo "configure:2896: checking for $ac_func" >&5
|
||||
|
@ -1,4 +1,4 @@
|
||||
dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.160 2003-02-11 07:41:52 guy Exp $ (LBL)
|
||||
dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.161 2003-03-02 23:19:37 guy Exp $ (LBL)
|
||||
dnl
|
||||
dnl Copyright (c) 1994, 1995, 1996, 1997
|
||||
dnl The Regents of the University of California. All rights reserved.
|
||||
@ -6,7 +6,7 @@ dnl
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
dnl
|
||||
|
||||
AC_REVISION($Revision: 1.160 $)
|
||||
AC_REVISION($Revision: 1.161 $)
|
||||
AC_PREREQ(2.13)
|
||||
AC_INIT(tcpdump.c)
|
||||
|
||||
@ -511,7 +511,7 @@ if test "$missing_includes" = "yes"; then
|
||||
fi
|
||||
|
||||
|
||||
AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup)
|
||||
AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep)
|
||||
AC_CHECK_FUNCS(ether_ntohost, [
|
||||
AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
|
||||
AC_TRY_RUN([
|
||||
|
80
missing/strsep.c
Normal file
80
missing/strsep.c
Normal file
@ -0,0 +1,80 @@
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)strsep.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/*
|
||||
* Get next token from string *stringp, where tokens are possibly-empty
|
||||
* strings separated by characters from delim.
|
||||
*
|
||||
* Writes NULs into the string at *stringp to end tokens.
|
||||
* delim need not remain constant from call to call.
|
||||
* On return, *stringp points past the last NUL written (if there might
|
||||
* be further tokens), or is NULL (if there are definitely no more tokens).
|
||||
*
|
||||
* If *stringp is NULL, strsep returns NULL.
|
||||
*/
|
||||
char *
|
||||
strsep(stringp, delim)
|
||||
register char **stringp;
|
||||
register const char *delim;
|
||||
{
|
||||
register char *s;
|
||||
register const char *spanp;
|
||||
register int c, sc;
|
||||
char *tok;
|
||||
|
||||
if ((s = *stringp) == NULL)
|
||||
return (NULL);
|
||||
for (tok = s;;) {
|
||||
c = *s++;
|
||||
spanp = delim;
|
||||
do {
|
||||
if ((sc = *spanp++) == c) {
|
||||
if (c == 0)
|
||||
s = NULL;
|
||||
else
|
||||
s[-1] = 0;
|
||||
*stringp = s;
|
||||
return (tok);
|
||||
}
|
||||
} while (sc != 0);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
33
print-esp.c
33
print-esp.c
@ -23,7 +23,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.33 2003-02-26 18:58:05 mcr Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.34 2003-03-02 23:19:38 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -55,6 +55,11 @@ static const char rcsid[] =
|
||||
#include "ip6.h"
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__) || defined(__WATCOMC__)
|
||||
#include "addrinfo.h"
|
||||
extern char *strsep (char **stringp, const char *delim); /* Missing/strsep.c */
|
||||
#endif
|
||||
|
||||
#define AVOID_CHURN 1
|
||||
#include "interface.h"
|
||||
#include "addrtoname.h"
|
||||
@ -192,13 +197,13 @@ static void esp_print_decode_onesecret(char *line)
|
||||
char fileline[1024];
|
||||
char *nl;
|
||||
|
||||
secretfile=fopen(line, "r");
|
||||
secretfile = fopen(line, FOPEN_READ_TXT);
|
||||
if(secretfile == NULL) {
|
||||
perror(line);
|
||||
exit(3);
|
||||
}
|
||||
|
||||
while(fgets(fileline, 1024, secretfile) != NULL) {
|
||||
while(fgets(fileline, sizeof(fileline)-1, secretfile) != NULL) {
|
||||
|
||||
/* remove newline from the line */
|
||||
nl = strchr(fileline, '\n');
|
||||
@ -467,7 +472,15 @@ esp_print(register const u_char *bp, register const u_char *bp2,
|
||||
|
||||
if (espsecret_keylen != 8)
|
||||
goto fail;
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x00907000L
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x00908000L
|
||||
DES_set_key_unchecked((const_DES_cblock *)secret, &schedule);
|
||||
|
||||
DES_cbc_encrypt((const unsigned char *)p, p,
|
||||
(long)(ep - p), &schedule, (DES_cblock *)iv,
|
||||
DES_DECRYPT);
|
||||
|
||||
#elif OPENSSL_VERSION_NUMBER >= 0x00907000L
|
||||
DES_set_key_unchecked((DES_cblock *)secret, schedule);
|
||||
|
||||
DES_cbc_encrypt((const unsigned char *)p, p,
|
||||
@ -557,6 +570,17 @@ esp_print(register const u_char *bp, register const u_char *bp2,
|
||||
DES_set_odd_parity((DES_cblock *)secret);
|
||||
DES_set_odd_parity((DES_cblock *)(secret + 8));
|
||||
DES_set_odd_parity((DES_cblock *)(secret + 16));
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x00908000L
|
||||
if(DES_set_key_checked((const_DES_cblock *)secret, &s1) != 0) {
|
||||
printf("failed to schedule key 1\n");
|
||||
}
|
||||
if(DES_set_key_checked((const_DES_cblock *)(secret + 8), &s2)!=0) {
|
||||
printf("failed to schedule key 2\n");
|
||||
}
|
||||
if(DES_set_key_checked((const_DES_cblock *)(secret + 16), &s3)!=0) {
|
||||
printf("failed to schedule key 3\n");
|
||||
}
|
||||
#else
|
||||
if(DES_set_key_checked((DES_cblock *)secret, s1) != 0) {
|
||||
printf("failed to schedule key 1\n");
|
||||
}
|
||||
@ -566,6 +590,7 @@ esp_print(register const u_char *bp, register const u_char *bp2,
|
||||
if(DES_set_key_checked((DES_cblock *)(secret + 16), s3)!=0) {
|
||||
printf("failed to schedule key 3\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
p = ivoff + ivlen;
|
||||
DES_ede3_cbc_encrypt((const unsigned char *)p, p,
|
||||
|
@ -18,7 +18,7 @@
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.3 2002-08-05 07:47:24 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.4 2003-03-02 23:19:38 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -28,16 +28,22 @@
|
||||
* differences to this one file.
|
||||
*/
|
||||
|
||||
#ifndef tcpdump_stdinc_h
|
||||
#define tcpdump_stdinc_h
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#include <stdio.h>
|
||||
#include <winsock2.h>
|
||||
#include "bittypes.h"
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <io.h>
|
||||
#include "IP6_misc.h"
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#include <stdint.h>
|
||||
int* _errno();
|
||||
#define errno (*_errno())
|
||||
|
||||
@ -46,6 +52,10 @@ int* _errno();
|
||||
|
||||
#endif /* __MINGW32__ */
|
||||
|
||||
#ifndef toascii
|
||||
#define toascii(c) ((c) & 0x7f)
|
||||
#endif
|
||||
|
||||
#ifndef caddr_t
|
||||
typedef char* caddr_t;
|
||||
#endif /* caddr_t */
|
||||
@ -57,7 +67,8 @@ typedef char* caddr_t;
|
||||
#define vsnprintf _vsnprintf
|
||||
#define RETSIGTYPE void
|
||||
|
||||
#ifndef __MINGW32__
|
||||
#if !defined(__MINGW32__) && !defined(__WATCOMC__)
|
||||
#undef toascii
|
||||
#define isascii __isascii
|
||||
#define toascii __toascii
|
||||
#define stat _stat
|
||||
@ -91,3 +102,17 @@ typedef short ino_t;
|
||||
#ifdef INET6
|
||||
#include "ip6.h"
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) || defined(MSDOS)
|
||||
#define FOPEN_READ_TXT "rt"
|
||||
#define FOPEN_READ_BIN "rb"
|
||||
#define FOPEN_WRITE_TXT "wt"
|
||||
#define FOPEN_WRITE_BIN "wb"
|
||||
#else
|
||||
#define FOPEN_READ_TXT "r"
|
||||
#define FOPEN_READ_BIN FOPEN_READ_BIN
|
||||
#define FOPEN_WRITE_TXT "w"
|
||||
#define FOPEN_WRITE_BIN FOPEN_WRITE_TXT
|
||||
#endif
|
||||
|
||||
#endif /* tcpdump_stdinc_h */
|
||||
|
Loading…
Reference in New Issue
Block a user