dect
/
libpcap
Archived
13
0
Fork 0

From Yoann Vandoorselaere <yoann@prelude-ids.org>: make the "device"

argument to "pcap_open_live()" a "const" pointer.

Constify some additional device name arguments, and update the man page
to reflect some arguments that were already consts.
This commit is contained in:
guy 2002-12-22 02:36:48 +00:00
parent eca5a61ef1
commit 8cd68a0fa4
13 changed files with 46 additions and 37 deletions

View File

@ -64,6 +64,7 @@ Additional people who have contributed patches:
Uwe Girlich <Uwe.Girlich@philosys.de>
Xianjie Zhang <xzhang@cup.hp.com>
Yen Yen Lim
Yoann Vandoorselaere <yoann@prelude-ids.org>
The original LBL crew:
Steve McCanne

10
inet.c
View File

@ -34,7 +34,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.53 2002-11-13 06:46:16 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.54 2002-12-22 02:36:48 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -103,9 +103,9 @@ dup_sockaddr(struct sockaddr *sa, size_t sa_length)
}
static int
get_instance(char *name)
get_instance(const char *name)
{
char *cp, *endcp;
const char *cp, *endcp;
int n;
if (strcmp(name, "any") == 0) {
@ -129,7 +129,7 @@ get_instance(char *name)
}
int
add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, char *name,
add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name,
u_int flags, const char *description, char *errbuf)
{
pcap_t *p;
@ -516,7 +516,7 @@ pcap_lookupdev(errbuf)
int
pcap_lookupnet(device, netp, maskp, errbuf)
register char *device;
register const char *device;
register bpf_u_int32 *netp, *maskp;
register char *errbuf;
{

View File

@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.54 2002-12-19 09:05:45 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.55 2002-12-22 02:36:48 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -224,7 +224,8 @@ bpf_open(pcap_t *p, char *errbuf)
* documented).
*/
pcap_t *
pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
char *ebuf)
{
int fd;
struct ifreq ifr;

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.41 2002-12-19 09:05:46 guy Exp $ (LBL)
* @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.42 2002-12-22 02:36:49 guy Exp $ (LBL)
*/
#ifndef pcap_int_h
@ -73,7 +73,7 @@ struct pcap_md {
int clear_promisc; /* must clear promiscuous mode when we close */
int cooked; /* using SOCK_DGRAM rather than SOCK_RAW */
int lo_ifindex; /* interface index of the loopback device */
char *device; /* device name */
const char *device; /* device name */
struct pcap *next; /* list of open promiscuous sock_packet pcaps */
#endif
};
@ -235,7 +235,7 @@ int add_addr_to_iflist(pcap_if_t **, char *, u_int, struct sockaddr *,
struct sockaddr *, size_t, char *);
int pcap_add_if(pcap_if_t **, char *, u_int, const char *, char *);
struct sockaddr *dup_sockaddr(struct sockaddr *, size_t);
int add_or_find_if(pcap_if_t **, pcap_if_t **, char *, u_int,
int add_or_find_if(pcap_if_t **, pcap_if_t **, const char *, u_int,
const char *, char *);
#ifdef linux

View File

@ -26,7 +26,7 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.86 2002-12-19 09:05:46 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.87 2002-12-22 02:36:49 guy Exp $ (LBL)";
#endif
/*
@ -179,8 +179,8 @@ typedef int socklen_t;
* Prototypes for internal functions
*/
static void map_arphrd_to_dlt(pcap_t *, int, int);
static int live_open_old(pcap_t *, char *, int, int, char *);
static int live_open_new(pcap_t *, char *, int, int, char *);
static int live_open_old(pcap_t *, const char *, int, int, char *);
static int live_open_new(pcap_t *, const char *, int, int, char *);
static int pcap_read_packet(pcap_t *, pcap_handler, u_char *);
/*
@ -219,7 +219,8 @@ static struct sock_fprog total_fcode
* See also pcap(3).
*/
pcap_t *
pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
char *ebuf)
{
pcap_t *handle;
int mtu;
@ -1134,7 +1135,7 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, int cooked_ok)
* FIXME: 0 uses to mean success (Sebastian)
*/
static int
live_open_new(pcap_t *handle, char *device, int promisc,
live_open_new(pcap_t *handle, const char *device, int promisc,
int to_ms, char *ebuf)
{
#ifdef HAVE_PF_PACKET_SOCKETS
@ -1488,7 +1489,7 @@ void pcap_close_linux( pcap_t *handle )
* FIXME: 0 uses to mean success (Sebastian)
*/
static int
live_open_old(pcap_t *handle, char *device, int promisc,
live_open_old(pcap_t *handle, const char *device, int promisc,
int to_ms, char *ebuf)
{
int sock_fd = -1, arptype;

View File

@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.43 2002-12-19 09:05:47 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.44 2002-12-22 02:36:49 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -202,7 +202,8 @@ nit_setflags(int fd, int promisc, int to_ms, char *ebuf)
}
pcap_t *
pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
char *ebuf)
{
int fd;
struct sockaddr_nit snit;

View File

@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/libpcap/pcap-null.c,v 1.15 2002-12-19 09:05:47 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/pcap-null.c,v 1.16 2002-12-22 02:36:49 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -54,7 +54,8 @@ pcap_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
}
pcap_t *
pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
char *ebuf)
{
(void)strlcpy(ebuf, nosup, PCAP_ERRBUF_SIZE);
return (NULL);

View File

@ -24,7 +24,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.70 2002-12-19 09:05:47 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.71 2002-12-22 02:36:50 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -238,7 +238,8 @@ pcap_stats(pcap_t *p, struct pcap_stat *ps)
}
pcap_t *
pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
char *ebuf)
{
pcap_t *p;
short enmode;

View File

@ -25,7 +25,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/libpcap/pcap-snit.c,v 1.59 2002-12-19 09:05:47 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/pcap-snit.c,v 1.60 2002-12-22 02:36:50 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -219,7 +219,8 @@ nit_setflags(int fd, int promisc, int to_ms, char *ebuf)
}
pcap_t *
pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
char *ebuf)
{
struct strioctl si; /* struct for ioctl() */
struct ifreq ifr; /* interface request struct */

View File

@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.38 2002-12-19 09:05:48 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.39 2002-12-22 02:36:50 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -144,7 +144,8 @@ pcap_stats(pcap_t *p, struct pcap_stat *ps)
/* XXX can't disable promiscuous */
pcap_t *
pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
char *ebuf)
{
int fd;
struct sockaddr_raw sr;

View File

@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.4 2002-12-19 09:05:48 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.5 2002-12-22 02:36:50 guy Exp $ (LBL)";
#endif
#include <pcap-int.h>
@ -115,7 +115,8 @@ pcap_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
pcap_t *
pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
char *ebuf)
{
register pcap_t *p;
NetType type;

12
pcap.3
View File

@ -1,4 +1,4 @@
.\" @(#) $Header: /tcpdump/master/libpcap/Attic/pcap.3,v 1.42 2002-12-21 23:38:51 guy Exp $
.\" @(#) $Header: /tcpdump/master/libpcap/Attic/pcap.3,v 1.43 2002-12-22 02:36:51 guy Exp $
.\"
.\" Copyright (c) 1994, 1996, 1997
.\" The Regents of the University of California. All rights reserved.
@ -34,12 +34,12 @@ char errbuf[PCAP_ERRBUF_SIZE];
.ft
.LP
.ft B
pcap_t *pcap_open_live(char *device, int snaplen,
pcap_t *pcap_open_live(const char *device, int snaplen,
.ti +8
int promisc, int to_ms, char *errbuf)
pcap_t *pcap_open_dead(int linktype, int snaplen)
pcap_t *pcap_open_offline(char *fname, char *errbuf)
pcap_dumper_t *pcap_dump_open(pcap_t *p, char *fname)
pcap_t *pcap_open_offline(const char *fname, char *errbuf)
pcap_dumper_t *pcap_dump_open(pcap_t *p, const char *fname)
.ft
.LP
.ft B
@ -49,9 +49,9 @@ int pcap_getnonblock(pcap_t *p, char *errbuf);
.LP
.ft B
int pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
void pcap_freealldevs(pcap_if_t *)
void pcap_freealldevs(pcap_if_t *alldevs)
char *pcap_lookupdev(char *errbuf)
int pcap_lookupnet(char *device, bpf_u_int32 *netp,
int pcap_lookupnet(const char *device, bpf_u_int32 *netp,
.ti +8
bpf_u_int32 *maskp, char *errbuf)
.ft

6
pcap.h
View File

@ -31,7 +31,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.39 2002-12-21 23:38:52 guy Exp $ (LBL)
* @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.40 2002-12-22 02:36:51 guy Exp $ (LBL)
*/
#ifndef lib_pcap_h
@ -166,8 +166,8 @@ typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *,
const u_char *);
char *pcap_lookupdev(char *);
int pcap_lookupnet(char *, bpf_u_int32 *, bpf_u_int32 *, char *);
pcap_t *pcap_open_live(char *, int, int, int, char *);
int pcap_lookupnet(const char *, bpf_u_int32 *, bpf_u_int32 *, char *);
pcap_t *pcap_open_live(const char *, int, int, int, char *);
pcap_t *pcap_open_dead(int, int);
pcap_t *pcap_open_offline(const char *, char *);
void pcap_close(pcap_t *);