Lines Matching +full:layer +full:- +full:buffer +full:- +full:offset
49 #include "pcap-int.h"
52 #include "os-proto.h"
65 struct pcap_snoop *psn = p->priv;
76 if (p->break_loop) {
78 * Yes - clear the flag that indicates that it
79 * has, and return -2 to indicate that we were
82 p->break_loop = 0;
83 return (-2);
85 cc = read(p->fd, (char *)p->buffer, p->bufsize);
96 pcapint_fmt_errmsg_for_errno(p->errbuf, sizeof(p->errbuf),
98 return (-1);
100 sh = (struct snoopheader *)p->buffer;
101 datalen = sh->snoop_packetlen;
104 * XXX - Sigh, snoop_packetlen is a 16 bit quantity. If we
108 if (cc == (p->snapshot + sizeof(struct snoopheader)) &&
109 (datalen < p->snapshot))
112 caplen = (datalen < p->snapshot) ? datalen : p->snapshot;
113 cp = (u_char *)(sh + 1) + p->offset; /* XXX */
121 if (p->linktype == DLT_NULL && *((short *)(cp + 2)) == 0) {
126 if (p->fcode.bf_insns == NULL ||
127 pcapint_filter(p->fcode.bf_insns, cp, datalen, caplen)) {
129 ++psn->stat.ps_recv;
130 h.ts.tv_sec = sh->snoop_timestamp.tv_sec;
131 h.ts.tv_usec = sh->snoop_timestamp.tv_usec;
146 * XXX - libnet overwrites the source address with what I
149 ret = write(p->fd, buf, size);
150 if (ret == -1) {
151 pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
153 return (-1);
161 struct pcap_snoop *psn = p->priv;
167 if (ioctl(p->fd, SIOCRAWSTATS, (char *)rs) < 0) {
168 pcapint_fmt_errmsg_for_errno(p->errbuf, sizeof(p->errbuf),
170 return (-1);
177 * "sbdrops" are those dropped due to socket buffer limits.
182 * XXX - does this count *all* Snoop or Drain sockets,
186 psn->stat.ps_drop =
187 rs->rs_snoop.ss_ifdrops + rs->rs_snoop.ss_sbdrops +
188 rs->rs_drain.ds_ifdrops + rs->rs_drain.ds_sbdrops;
193 * packets dropped because we ran out of buffer space.
195 *ps = psn->stat;
213 pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
217 p->fd = fd;
220 (void)strncpy(sr.sr_ifname, p->opt.device, sizeof(sr.sr_ifname));
223 * XXX - there's probably a particular bind error that
229 pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
235 pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
239 if (p->opt.buffer_size != 0)
240 v = p->opt.buffer_size;
242 v = 64 * 1024; /* default to 64K buffer size */
245 * XXX hack - map device name to link layer type
247 if (strncmp("et", p->opt.device, 2) == 0 || /* Challenge 10 Mbit */
248 strncmp("ec", p->opt.device, 2) == 0 || /* Indigo/Indy 10 Mbit,
250 strncmp("ef", p->opt.device, 2) == 0 || /* O200/2000 10/100 Mbit */
251 strncmp("eg", p->opt.device, 2) == 0 || /* Octane/O2xxx/O3xxx Gigabit */
252 strncmp("gfe", p->opt.device, 3) == 0 || /* GIO 100 Mbit */
253 strncmp("fxp", p->opt.device, 3) == 0 || /* Challenge VME Enet */
254 strncmp("ep", p->opt.device, 2) == 0 || /* Challenge 8x10 Mbit EPLEX */
255 strncmp("vfe", p->opt.device, 3) == 0 || /* Challenge VME 100Mbit */
256 strncmp("fa", p->opt.device, 2) == 0 ||
257 strncmp("qaa", p->opt.device, 3) == 0 ||
258 strncmp("cip", p->opt.device, 3) == 0 ||
259 strncmp("el", p->opt.device, 2) == 0) {
260 p->linktype = DLT_EN10MB;
261 p->offset = RAW_HDRPAD(sizeof(struct ether_header));
265 * link-layer-type list with DLT_EN10MB and DLT_DOCSIS, so
270 * DOCSIS frames out on the wire inside the low-level
273 * XXX - are there any sorts of "fake Ethernet" that have
274 * Ethernet link-layer headers but that *shouldn't offer
280 * as well; what are "cip" devices - some other ATM
283 p->dlt_list = (u_int *) malloc(sizeof(u_int) * 2);
284 if (p->dlt_list == NULL) {
285 pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
289 p->dlt_list[0] = DLT_EN10MB;
290 p->dlt_list[1] = DLT_DOCSIS;
291 p->dlt_count = 2;
292 } else if (strncmp("ipg", p->opt.device, 3) == 0 ||
293 strncmp("rns", p->opt.device, 3) == 0 || /* O2/200/2000 FDDI */
294 strncmp("xpi", p->opt.device, 3) == 0) {
295 p->linktype = DLT_FDDI;
296 p->offset = 3; /* XXX yeah? */
298 } else if (strncmp("ppp", p->opt.device, 3) == 0) {
299 p->linktype = DLT_RAW;
301 } else if (strncmp("qfa", p->opt.device, 3) == 0) {
302 p->linktype = DLT_IP_OVER_FC;
304 } else if (strncmp("pl", p->opt.device, 2) == 0) {
305 p->linktype = DLT_RAW;
307 } else if (strncmp("lo", p->opt.device, 2) == 0) {
308 p->linktype = DLT_NULL;
311 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
312 "snoop: unknown physical layer type");
316 if (p->opt.rfmon) {
318 * No monitor mode on Irix (no Wi-Fi devices on
332 if (p->snapshot <= 0 || p->snapshot > MAXIMUM_SNAPLEN)
333 p->snapshot = MAXIMUM_SNAPLEN;
337 * XXX - IRIX appears to give you an error if you try to set the
342 (void)strncpy(ifr.ifr_name, p->opt.device, sizeof(ifr.ifr_name));
344 pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
351 * XXX - some versions of IRIX 6.5 define "ifr_mtu" and have an
365 if (p->snapshot > ifr.ifr_mtu + ll_hdrlen)
366 p->snapshot = ifr.ifr_mtu + ll_hdrlen;
370 * The argument to SIOCSNOOPLEN is the number of link-layer
371 * payload bytes to capture - it doesn't count link-layer
374 snooplen = p->snapshot - ll_hdrlen;
378 pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
384 pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
389 p->bufsize = 4096; /* XXX */
390 p->buffer = malloc(p->bufsize);
391 if (p->buffer == NULL) {
392 pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
398 * "p->fd" is a socket, so "select()" should work on it.
400 p->selectable_fd = p->fd;
402 p->read_op = pcap_read_snoop;
403 p->inject_op = pcap_inject_snoop;
404 p->setfilter_op = pcapint_install_bpf_program; /* no kernel filtering */
405 p->setdirection_op = NULL; /* Not implemented. */
406 p->set_datalink_op = NULL; /* can't change data link type */
407 p->getnonblock_op = pcapint_getnonblock_fd;
408 p->setnonblock_op = pcapint_setnonblock_fd;
409 p->stats_op = pcap_stats_snoop;
426 p->activate_op = pcap_activate_snoop;
431 * XXX - there's probably a particular bind error that means "that device
445 * XXX - is there a way to find out whether an adapter has