Lines Matching refs:p
92 pcap_stats_win32(pcap_t *p, struct pcap_stat *ps) in pcap_stats_win32() argument
95 if(PacketGetStats(p->adapter, (struct bpf_stat*)ps) != TRUE){ in pcap_stats_win32()
96 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "PacketGetStats error: %s", pcap_win32strerror()); in pcap_stats_win32()
104 pcap_read_win32_npf(pcap_t *p, int cnt, pcap_handler callback, u_char *user) in pcap_read_win32_npf() argument
110 cc = p->cc; in pcap_read_win32_npf()
111 if (p->cc == 0) { in pcap_read_win32_npf()
115 if (p->break_loop) { in pcap_read_win32_npf()
121 p->break_loop = 0; in pcap_read_win32_npf()
126 if(PacketReceivePacket(p->adapter,p->Packet,TRUE)==FALSE){ in pcap_read_win32_npf()
127 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "read error: PacketReceivePacket failed"); in pcap_read_win32_npf()
131 cc = p->Packet->ulBytesReceived; in pcap_read_win32_npf()
133 bp = p->Packet->Buffer; in pcap_read_win32_npf()
136 bp = p->bp; in pcap_read_win32_npf()
155 if (p->break_loop) { in pcap_read_win32_npf()
157 p->break_loop = 0; in pcap_read_win32_npf()
160 p->bp = bp; in pcap_read_win32_npf()
161 p->cc = ep - bp; in pcap_read_win32_npf()
177 p->bp = bp; in pcap_read_win32_npf()
178 p->cc = ep - bp; in pcap_read_win32_npf()
183 p->cc = 0; in pcap_read_win32_npf()
189 pcap_read_win32_dag(pcap_t *p, int cnt, pcap_handler callback, u_char *user) in pcap_read_win32_dag() argument
201 unsigned dfp = p->adapter->DagFastProcess; in pcap_read_win32_dag()
203 cc = p->cc; in pcap_read_win32_dag()
207 if(PacketReceivePacket(p->adapter, p->Packet, TRUE)==FALSE){ in pcap_read_win32_dag()
208 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "read error: PacketReceivePacket failed"); in pcap_read_win32_dag()
212 cc = p->Packet->ulBytesReceived; in pcap_read_win32_dag()
216 header = (dag_record_t*)p->adapter->DagBuffer; in pcap_read_win32_dag()
219 header = (dag_record_t*)p->bp; in pcap_read_win32_dag()
233 p->md.stat.ps_recv++; in pcap_read_win32_dag()
250 packet_len = swt - (p->md.dag_fcs_bits); in pcap_read_win32_dag()
262 packet_len = swt - (p->md.dag_fcs_bits); in pcap_read_win32_dag()
272 if(caplen > p->snapshot) in pcap_read_win32_dag()
273 caplen = p->snapshot; in pcap_read_win32_dag()
284 if (p->break_loop) in pcap_read_win32_dag()
288 p->break_loop = 0; in pcap_read_win32_dag()
293 p->bp = (char*)header; in pcap_read_win32_dag()
294 p->cc = endofbuf - (char*)header; in pcap_read_win32_dag()
314 if (p->fcode.bf_insns) in pcap_read_win32_dag()
316 if (bpf_filter(p->fcode.bf_insns, dp, packet_len, caplen) == 0) in pcap_read_win32_dag()
337 p->bp = (char*)header; in pcap_read_win32_dag()
338 p->cc = endofbuf - (char*)header; in pcap_read_win32_dag()
350 pcap_inject_win32(pcap_t *p, const void *buf, size_t size){ in pcap_inject_win32() argument
357 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send error: PacketAllocatePacket failed"); in pcap_inject_win32()
362 if(PacketSendPacket(p->adapter,PacketToSend,TRUE) == FALSE){ in pcap_inject_win32()
363 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send error: PacketSendPacket failed"); in pcap_inject_win32()
379 pcap_close_win32(pcap_t *p) in pcap_close_win32() argument
381 pcap_close_common(p); in pcap_close_win32()
382 if (p->adapter != NULL) { in pcap_close_win32()
383 PacketCloseAdapter(p->adapter); in pcap_close_win32()
384 p->adapter = NULL; in pcap_close_win32()
386 if (p->Packet) { in pcap_close_win32()
387 PacketFreePacket(p->Packet); in pcap_close_win32()
388 p->Packet = NULL; in pcap_close_win32()
396 register pcap_t *p; in pcap_open_live() local
402 p = (pcap_t *)malloc(sizeof(*p)); in pcap_open_live()
403 if (p == NULL) in pcap_open_live()
408 memset(p, 0, sizeof(*p)); in pcap_open_live()
409 p->adapter=NULL; in pcap_open_live()
411 p->adapter = PacketOpenAdapter((char*)device); in pcap_open_live()
413 if (p->adapter == NULL) in pcap_open_live()
415 free(p); in pcap_open_live()
422 if(PacketGetNetType (p->adapter,&type) == FALSE) in pcap_open_live()
432 p->linktype = DLT_EN10MB; in pcap_open_live()
436 p->linktype = DLT_EN10MB; in pcap_open_live()
447 p->dlt_list = (u_int *) malloc(sizeof(u_int) * 2); in pcap_open_live()
451 if (p->dlt_list != NULL) { in pcap_open_live()
452 p->dlt_list[0] = DLT_EN10MB; in pcap_open_live()
453 p->dlt_list[1] = DLT_DOCSIS; in pcap_open_live()
454 p->dlt_count = 2; in pcap_open_live()
459 p->linktype = DLT_FDDI; in pcap_open_live()
463 p->linktype = DLT_IEEE802; in pcap_open_live()
467 p->linktype = DLT_ARCNET; in pcap_open_live()
471 p->linktype = DLT_ARCNET; in pcap_open_live()
475 p->linktype = DLT_ATM_RFC1483; in pcap_open_live()
479 p->linktype = DLT_CHDLC; in pcap_open_live()
483 p->linktype = DLT_PPP_SERIAL; in pcap_open_live()
487 p->linktype = DLT_NULL; in pcap_open_live()
491 p->linktype = DLT_IEEE802_11; in pcap_open_live()
495 p->linktype = DLT_IEEE802_11_RADIO; in pcap_open_live()
499 p->linktype = DLT_PPI; in pcap_open_live()
503 p->linktype = DLT_EN10MB; /*an unknown adapter is assumed to be ethernet*/ in pcap_open_live()
511 if (PacketSetHwFilter(p->adapter,NDIS_PACKET_TYPE_PROMISCUOUS) == FALSE) in pcap_open_live()
519 if (PacketSetHwFilter(p->adapter,NDIS_PACKET_TYPE_ALL_LOCAL) == FALSE) in pcap_open_live()
527 p->bufsize = PcapBufSize; in pcap_open_live()
530 p->timeout= to_ms; in pcap_open_live()
533 if((p->Packet = PacketAllocatePacket())==NULL) in pcap_open_live()
539 if(!(p->adapter->Flags & INFO_FLAG_DAG_CARD)) in pcap_open_live()
545 p->buffer = (u_char *)malloc(PcapBufSize); in pcap_open_live()
546 if (p->buffer == NULL) in pcap_open_live()
552 PacketInitPacket(p->Packet,(BYTE*)p->buffer,p->bufsize); in pcap_open_live()
554 p->snapshot = snaplen; in pcap_open_live()
557 if(PacketSetBuff( p->adapter, SIZE_BUF)==FALSE) in pcap_open_live()
564 if(PacketSetMinToCopy(p->adapter,16000)==FALSE) in pcap_open_live()
609 p->snapshot = PacketSetSnapLen(p->adapter, snaplen); in pcap_open_live()
613 p->md.dag_fcs_bits = p->adapter->DagFcsLen; in pcap_open_live()
619 PacketSetReadTimeout(p->adapter, to_ms); in pcap_open_live()
622 if(p->adapter->Flags & INFO_FLAG_DAG_CARD) in pcap_open_live()
625 p->read_op = pcap_read_win32_dag; in pcap_open_live()
626 p->setfilter_op = pcap_setfilter_win32_dag; in pcap_open_live()
632 p->read_op = pcap_read_win32_npf; in pcap_open_live()
633 p->setfilter_op = pcap_setfilter_win32_npf; in pcap_open_live()
637 p->setdirection_op = NULL; /* Not implemented. */ in pcap_open_live()
639 p->inject_op = pcap_inject_win32; in pcap_open_live()
640 p->set_datalink_op = NULL; /* can't change data link type */ in pcap_open_live()
641 p->getnonblock_op = pcap_getnonblock_win32; in pcap_open_live()
642 p->setnonblock_op = pcap_setnonblock_win32; in pcap_open_live()
643 p->stats_op = pcap_stats_win32; in pcap_open_live()
644 p->close_op = pcap_close_win32; in pcap_open_live()
646 return (p); in pcap_open_live()
648 if (p->adapter) in pcap_open_live()
649 PacketCloseAdapter(p->adapter); in pcap_open_live()
650 if (p->buffer != NULL) in pcap_open_live()
651 free(p->buffer); in pcap_open_live()
652 if(p->Packet) in pcap_open_live()
653 PacketFreePacket(p->Packet); in pcap_open_live()
657 if (p->dlt_list != NULL) in pcap_open_live()
658 free(p->dlt_list); in pcap_open_live()
659 free(p); in pcap_open_live()
665 pcap_setfilter_win32_npf(pcap_t *p, struct bpf_program *fp) in pcap_setfilter_win32_npf() argument
667 if(PacketSetBpf(p->adapter,fp)==FALSE){ in pcap_setfilter_win32_npf()
673 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Driver error: cannot set bpf filter: %s", pcap_win32strerro… in pcap_setfilter_win32_npf()
683 p->cc = 0; in pcap_setfilter_win32_npf()
691 pcap_setfilter_win32_dag(pcap_t *p, struct bpf_program *fp) { in pcap_setfilter_win32_dag() argument
695 strncpy(p->errbuf, "setfilter: No filter specified", sizeof(p->errbuf)); in pcap_setfilter_win32_dag()
700 if (install_bpf_program(p, fp) < 0) in pcap_setfilter_win32_dag()
702 snprintf(p->errbuf, sizeof(p->errbuf), in pcap_setfilter_win32_dag()
707 p->md.use_bpf = 0; in pcap_setfilter_win32_dag()
713 pcap_getnonblock_win32(pcap_t *p, char *errbuf) in pcap_getnonblock_win32() argument
720 return (p->nonblock); in pcap_getnonblock_win32()
724 pcap_setnonblock_win32(pcap_t *p, int nonblock, char *errbuf) in pcap_setnonblock_win32() argument
739 newtimeout = p->timeout; in pcap_setnonblock_win32()
741 if (!PacketSetReadTimeout(p->adapter, newtimeout)) { in pcap_setnonblock_win32()
742 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, in pcap_setnonblock_win32()
746 p->nonblock = (newtimeout == -1); in pcap_setnonblock_win32()
752 pcap_setmode(pcap_t *p, int mode){ in pcap_setmode() argument
754 if (p->adapter==NULL) in pcap_setmode()
756 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "impossible to set mode while reading from a file"); in pcap_setmode()
760 if(PacketSetMode(p->adapter,mode)==FALSE) in pcap_setmode()
762 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "driver error: working mode not recognized"); in pcap_setmode()
771 pcap_setbuff(pcap_t *p, int dim) in pcap_setbuff() argument
773 if (p->adapter==NULL) in pcap_setbuff()
775 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "The kernel buffer size cannot be set while reading from a f… in pcap_setbuff()
779 if(PacketSetBuff(p->adapter,dim)==FALSE) in pcap_setbuff()
781 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "driver error: not enough memory to allocate the kernel buff… in pcap_setbuff()
789 pcap_setmintocopy(pcap_t *p, int size) in pcap_setmintocopy() argument
791 if (p->adapter==NULL) in pcap_setmintocopy()
793 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Impossible to set the mintocopy parameter on an offline cap… in pcap_setmintocopy()
797 if(PacketSetMinToCopy(p->adapter, size)==FALSE) in pcap_setmintocopy()
799 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "driver error: unable to set the requested mintocopy size"); in pcap_setmintocopy()