xref: /freebsd/contrib/libpcap/pcap-null.c (revision 3052b236)
18cf6c252SPaul Traina /*
23052b236SBill Fenner  * Copyright (c) 1994, 1995, 1996
38cf6c252SPaul Traina  *	The Regents of the University of California.  All rights reserved.
48cf6c252SPaul Traina  *
58cf6c252SPaul Traina  * Redistribution and use in source and binary forms, with or without
68cf6c252SPaul Traina  * modification, are permitted provided that: (1) source code distributions
78cf6c252SPaul Traina  * retain the above copyright notice and this paragraph in its entirety, (2)
88cf6c252SPaul Traina  * distributions including binary code include the above copyright notice and
98cf6c252SPaul Traina  * this paragraph in its entirety in the documentation or other materials
108cf6c252SPaul Traina  * provided with the distribution, and (3) all advertising materials mentioning
118cf6c252SPaul Traina  * features or use of this software display the following acknowledgement:
128cf6c252SPaul Traina  * ``This product includes software developed by the University of California,
138cf6c252SPaul Traina  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
148cf6c252SPaul Traina  * the University nor the names of its contributors may be used to endorse
158cf6c252SPaul Traina  * or promote products derived from this software without specific prior
168cf6c252SPaul Traina  * written permission.
178cf6c252SPaul Traina  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
188cf6c252SPaul Traina  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
198cf6c252SPaul Traina  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
208cf6c252SPaul Traina  */
218cf6c252SPaul Traina #ifndef lint
223052b236SBill Fenner static const char rcsid[] =
233052b236SBill Fenner     "@(#) $Header: pcap-null.c,v 1.7 96/12/10 23:15:01 leres Exp $ (LBL)";
248cf6c252SPaul Traina #endif
258cf6c252SPaul Traina 
268cf6c252SPaul Traina #include <sys/param.h>			/* optionally get BSD define */
278cf6c252SPaul Traina 
288cf6c252SPaul Traina #include <string.h>
298cf6c252SPaul Traina 
308cf6c252SPaul Traina #include "gnuc.h"
318cf6c252SPaul Traina #ifdef HAVE_OS_PROTO_H
328cf6c252SPaul Traina #include "os-proto.h"
338cf6c252SPaul Traina #endif
348cf6c252SPaul Traina 
358cf6c252SPaul Traina #include "pcap-int.h"
368cf6c252SPaul Traina 
378cf6c252SPaul Traina static char nosup[] = "live packet capture not supported on this system";
388cf6c252SPaul Traina 
398cf6c252SPaul Traina int
408cf6c252SPaul Traina pcap_stats(pcap_t *p, struct pcap_stat *ps)
418cf6c252SPaul Traina {
428cf6c252SPaul Traina 
438cf6c252SPaul Traina 	(void)sprintf(p->errbuf, "pcap_stats: %s", nosup);
448cf6c252SPaul Traina 	return (-1);
458cf6c252SPaul Traina }
468cf6c252SPaul Traina 
478cf6c252SPaul Traina int
488cf6c252SPaul Traina pcap_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
498cf6c252SPaul Traina {
508cf6c252SPaul Traina 
518cf6c252SPaul Traina 	(void)sprintf(p->errbuf, "pcap_read: %s", nosup);
528cf6c252SPaul Traina 	return (-1);
538cf6c252SPaul Traina }
548cf6c252SPaul Traina 
558cf6c252SPaul Traina pcap_t *
568cf6c252SPaul Traina pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
578cf6c252SPaul Traina {
588cf6c252SPaul Traina 
598cf6c252SPaul Traina 	(void)strcpy(ebuf, nosup);
608cf6c252SPaul Traina 	return (NULL);
618cf6c252SPaul Traina }
628cf6c252SPaul Traina 
638cf6c252SPaul Traina int
648cf6c252SPaul Traina pcap_setfilter(pcap_t *p, struct bpf_program *fp)
658cf6c252SPaul Traina {
668cf6c252SPaul Traina 
678cf6c252SPaul Traina 	if (p->sf.rfile == NULL) {
688cf6c252SPaul Traina 		(void)sprintf(p->errbuf, "pcap_setfilter: %s", nosup);
698cf6c252SPaul Traina 		return (-1);
708cf6c252SPaul Traina 	}
718cf6c252SPaul Traina 	p->fcode = *fp;
728cf6c252SPaul Traina 	return (0);
738cf6c252SPaul Traina }
74