Lines Matching +full:dim +full:- +full:mode
35 #include <pcap-int.h>
37 #include "pcap-tc.h"
129 static int TcSetBuff(pcap_t *p, int dim);
130 static int TcSetMode(pcap_t *p, int mode);
420 pcapint_add_dev(devlist, dev->name, dev->flags, dev->description, errbuf); in TcFindAllDevs()
453 newIf->name = (char*)malloc(strlen(name) + 1); in TcCreatePcapIfFromPort()
454 if (newIf->name == NULL) in TcCreatePcapIfFromPort()
460 newIf->description = (char*)malloc(strlen(description) + 1); in TcCreatePcapIfFromPort()
461 if (newIf->description == NULL) in TcCreatePcapIfFromPort()
463 free(newIf->name); in TcCreatePcapIfFromPort()
468 strcpy(newIf->name, name); in TcCreatePcapIfFromPort()
469 strcpy(newIf->description, description); in TcCreatePcapIfFromPort()
471 newIf->addresses = NULL; in TcCreatePcapIfFromPort()
472 newIf->next = NULL; in TcCreatePcapIfFromPort()
473 newIf->flags = 0; in TcCreatePcapIfFromPort()
482 struct pcap_tc *pt = p->priv; in TcActivate()
487 if (p->opt.rfmon) in TcActivate()
490 * No monitor mode on Tc cards; they're Ethernet in TcActivate()
496 pt->PpiPacket = malloc(sizeof(PPI_HEADER) + MAX_TC_PACKET_SIZE); in TcActivate()
498 if (pt->PpiPacket == NULL) in TcActivate()
500 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Error allocating memory"); in TcActivate()
512 if (p->snapshot <= 0 || p->snapshot > MAXIMUM_SNAPLEN) in TcActivate()
513 p->snapshot = MAXIMUM_SNAPLEN; in TcActivate()
518 pPpiHeader = (PPPI_HEADER)pt->PpiPacket; in TcActivate()
519 pPpiHeader->PacketHeader.PphDlt = DLT_EN10MB; in TcActivate()
520 pPpiHeader->PacketHeader.PphLength = sizeof(PPI_HEADER); in TcActivate()
521 pPpiHeader->PacketHeader.PphFlags = 0; in TcActivate()
522 pPpiHeader->PacketHeader.PphVersion = 0; in TcActivate()
524 pPpiHeader->AggregationFieldHeader.PfhLength = sizeof(PPI_FIELD_AGGREGATION_EXTENSION); in TcActivate()
525 pPpiHeader->AggregationFieldHeader.PfhType = PPI_FIELD_TYPE_AGGREGATION_EXTENSION; in TcActivate()
527 pPpiHeader->Dot3FieldHeader.PfhLength = sizeof(PPI_FIELD_802_3_EXTENSION); in TcActivate()
528 pPpiHeader->Dot3FieldHeader.PfhType = PPI_FIELD_TYPE_802_3_EXTENSION; in TcActivate()
530 status = g_TcFunctions.InstanceOpenByName(p->opt.device, &pt->TcInstance); in TcActivate()
535 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Error opening TurboCap adapter: %s", g_TcFunctions.StatusGe… in TcActivate()
539 p->linktype = DLT_EN10MB; in TcActivate()
540 p->dlt_list = (u_int *) malloc(sizeof(u_int) * 2); in TcActivate()
541 if (p->dlt_list == NULL) in TcActivate()
543 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Error allocating memory"); in TcActivate()
546 p->dlt_list[0] = DLT_EN10MB; in TcActivate()
547 p->dlt_list[1] = DLT_PPI; in TcActivate()
548 p->dlt_count = 2; in TcActivate()
551 * ignore promiscuous mode in TcActivate()
552 * p->opt.promisc in TcActivate()
563 status = g_TcFunctions.InstanceSetFeature(pt->TcInstance, TC_INST_FT_RX_STATUS, 1); in TcActivate()
567 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE,"Error enabling reception on a TurboCap instance: %s", g_TcFu… in TcActivate()
574 status = g_TcFunctions.InstanceSetFeature(pt->TcInstance, TC_INST_FT_TX_STATUS, 1); in TcActivate()
579 p->inject_op = TcInject; in TcActivate()
581 * if the timeout is -1, it means immediate return, no timeout in TcActivate()
585 if (p->opt.timeout == 0) in TcActivate()
590 if (p->opt.timeout < 0) in TcActivate()
599 timeout = p->opt.timeout; in TcActivate()
602 status = g_TcFunctions.InstanceSetFeature(pt->TcInstance, TC_INST_FT_READ_TIMEOUT, timeout); in TcActivate()
606 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE,"Error setting the read timeout a TurboCap instance: %s", g_T… in TcActivate()
610 p->read_op = TcRead; in TcActivate()
611 p->setfilter_op = pcapint_install_bpf_program; in TcActivate()
612 p->setdirection_op = NULL; /* Not implemented. */ in TcActivate()
613 p->set_datalink_op = TcSetDatalink; in TcActivate()
614 p->getnonblock_op = TcGetNonBlock; in TcActivate()
615 p->setnonblock_op = TcSetNonBlock; in TcActivate()
616 p->stats_op = TcStats; in TcActivate()
618 p->stats_ex_op = TcStatsEx; in TcActivate()
619 p->setbuff_op = TcSetBuff; in TcActivate()
620 p->setmode_op = TcSetMode; in TcActivate()
621 p->setmintocopy_op = TcSetMinToCopy; in TcActivate()
622 p->getevent_op = TcGetReceiveWaitHandle; in TcActivate()
623 p->oid_get_request_op = TcOidGetRequest; in TcActivate()
624 p->oid_set_request_op = TcOidSetRequest; in TcActivate()
625 p->sendqueue_transmit_op = TcSendqueueTransmit; in TcActivate()
626 p->setuserbuffer_op = TcSetUserBuffer; in TcActivate()
627 p->live_dump_op = TcLiveDump; in TcActivate()
628 p->live_dump_ended_op = TcLiveDumpEnded; in TcActivate()
629 p->get_airpcap_handle_op = TcGetAirPcapHandle; in TcActivate()
631 p->selectable_fd = -1; in TcActivate()
634 p->cleanup_op = TcCleanup; in TcActivate()
655 * XXX - report this as an error rather than as in TcCreate()
670 * XXX - report this as an error rather than as in TcCreate()
708 p->activate_op = TcActivate; in TcCreate()
711 * to set non-blocking mode before we're activated, or in TcCreate()
712 * query the state of non-blocking mode, they get an error, in TcCreate()
713 * rather than having the non-blocking mode option set in TcCreate()
716 p->getnonblock_op = TcGetNonBlock; in TcCreate()
717 p->setnonblock_op = TcSetNonBlock; in TcCreate()
727 * p->linktype to the new value; we don't have to do anything in TcSetDatalink()
728 * in hardware, we just use what's in p->linktype. in TcSetDatalink()
731 * doesn't think we don't support setting the link-layer header in TcSetDatalink()
739 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, in TcGetNonBlock()
740 "Non-blocking mode isn't supported for TurboCap ports"); in TcGetNonBlock()
741 return -1; in TcGetNonBlock()
746 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, in TcSetNonBlock()
747 "Non-blocking mode isn't supported for TurboCap ports"); in TcSetNonBlock()
748 return -1; in TcSetNonBlock()
753 struct pcap_tc *pt = p->priv; in TcCleanup()
755 if (pt->TcPacketsBuffer != NULL) in TcCleanup()
757 g_TcFunctions.PacketsBufferDestroy(pt->TcPacketsBuffer); in TcCleanup()
758 pt->TcPacketsBuffer = NULL; in TcCleanup()
760 if (pt->TcInstance != NULL) in TcCleanup()
765 g_TcFunctions.InstanceClose(pt->TcInstance); in TcCleanup()
766 pt->TcInstance = NULL; in TcCleanup()
769 if (pt->PpiPacket != NULL) in TcCleanup()
771 free(pt->PpiPacket); in TcCleanup()
772 pt->PpiPacket = NULL; in TcCleanup()
781 struct pcap_tc *pt = p->priv; in TcInject()
788 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send error: the TurboCap API does not support packets large… in TcInject()
789 return -1; in TcInject()
796 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send error: TcPacketsBufferCreate failure: %s (%08x)", g_Tc… in TcInject()
797 return -1; in TcInject()
812 status = g_TcFunctions.InstanceTransmitPackets(pt->TcInstance, buffer); in TcInject()
816 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send error: TcInstanceTransmitPackets failure: %s (%08x)", … in TcInject()
821 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send error: TcPacketsBufferCommitNextPacket failure: %s (%0… in TcInject()
828 return -1; in TcInject()
838 struct pcap_tc *pt = p->priv; in TcRead()
845 if (p->break_loop) in TcRead()
848 * Yes - clear the flag that indicates that it in TcRead()
849 * has, and return -2 to indicate that we were in TcRead()
852 p->break_loop = 0; in TcRead()
853 return -2; in TcRead()
856 if (pt->TcPacketsBuffer == NULL) in TcRead()
858 status = g_TcFunctions.InstanceReceivePackets(pt->TcInstance, &pt->TcPacketsBuffer); in TcRead()
861 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "read error, TcInstanceReceivePackets failure: %s (%08x)", g… in TcRead()
862 return -1; in TcRead()
875 * If so, return immediately - if we haven't read any in TcRead()
876 * packets, clear the flag and return -2 to indicate in TcRead()
882 if (p->break_loop) in TcRead()
886 p->break_loop = 0; in TcRead()
887 return -2; in TcRead()
895 if (pt->TcPacketsBuffer == NULL) in TcRead()
900 status = g_TcFunctions.PacketsBufferQueryNextPacket(pt->TcPacketsBuffer, &tcHeader, &data); in TcRead()
904 g_TcFunctions.PacketsBufferDestroy(pt->TcPacketsBuffer); in TcRead()
905 pt->TcPacketsBuffer = NULL; in TcRead()
911 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "read error, TcPacketsBufferQueryNextPacket failure: %s (%08… in TcRead()
912 return -1; in TcRead()
916 if (p->fcode.bf_insns) in TcRead()
918 filterResult = pcapint_filter(p->fcode.bf_insns, data, tcHeader.Length, tcHeader.CapturedLength); in TcRead()
935 pt->TcAcceptedCount ++; in TcRead()
940 if (p->linktype == DLT_EN10MB) in TcRead()
948 PPPI_HEADER pPpiHeader = (PPPI_HEADER)pt->PpiPacket; in TcRead()
951 pPpiHeader->AggregationField.InterfaceId = TC_PH_FLAGS_RX_PORT_ID(tcHeader.Flags); in TcRead()
952 pPpiHeader->Dot3Field.Errors = tcHeader.Errors; in TcRead()
955 pPpiHeader->Dot3Field.Flags = PPI_FLD_802_3_EXT_FLAG_FCS_PRESENT; in TcRead()
959 pPpiHeader->Dot3Field.Flags = 0; in TcRead()
975 (*callback)(user, &hdr, pt->PpiPacket); in TcRead()
991 struct pcap_tc *pt = p->priv; in TcStats()
997 status = g_TcFunctions.InstanceQueryStatistics(pt->TcInstance, &statistics); in TcStats()
1001 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "TurboCap error in TcInstanceQueryStatistics: %s (%08x)", g_… in TcStats()
1002 return -1; in TcStats()
1010 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "TurboCap error in TcStatisticsQueryValue: %s (%08x)", g_TcF… in TcStats()
1011 return -1; in TcStats()
1025 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "TurboCap error in TcStatisticsQueryValue: %s (%08x)", g_TcF… in TcStats()
1026 return -1; in TcStats()
1040 s.ps_capt = pt->TcAcceptedCount; in TcStats()
1052 struct pcap_tc *pt = p->priv; in TcStatsEx()
1057 *pcap_stat_size = sizeof (p->stat); in TcStatsEx()
1059 status = g_TcFunctions.InstanceQueryStatistics(pt->TcInstance, &statistics); in TcStatsEx()
1063 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "TurboCap error in TcInstanceQueryStatistics: %s (%08x)", g_… in TcStatsEx()
1067 memset(&p->stat, 0, sizeof(p->stat)); in TcStatsEx()
1072 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "TurboCap error in TcStatisticsQueryValue: %s (%08x)", g_TcF… in TcStatsEx()
1077 p->stat.ps_recv = (ULONG)counter; in TcStatsEx()
1081 p->stat.ps_recv = 0xFFFFFFFF; in TcStatsEx()
1087 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "TurboCap error in TcStatisticsQueryValue: %s (%08x)", g_TcF… in TcStatsEx()
1092 p->stat.ps_ifdrop = (ULONG)counter; in TcStatsEx()
1093 p->stat.ps_drop = (ULONG)counter; in TcStatsEx()
1097 p->stat.ps_ifdrop = 0xFFFFFFFF; in TcStatsEx()
1098 p->stat.ps_drop = 0xFFFFFFFF; in TcStatsEx()
1102 p->stat.ps_capt = pt->TcAcceptedCount; in TcStatsEx()
1105 return &p->stat; in TcStatsEx()
1108 /* Set the dimension of the kernel-level capture buffer */
1110 TcSetBuff(pcap_t *p, int dim) in TcSetBuff() argument
1121 TcSetMode(pcap_t *p, int mode) in TcSetMode() argument
1123 if (mode != MODE_CAPT) in TcSetMode()
1125 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Mode %d not supported by TurboCap devices. TurboCap only su… in TcSetMode()
1126 return -1; in TcSetMode()
1135 struct pcap_tc *pt = p->priv; in TcSetMinToCopy()
1140 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Mintocopy cannot be less than 0."); in TcSetMinToCopy()
1141 return -1; in TcSetMinToCopy()
1144 status = g_TcFunctions.InstanceSetFeature(pt->TcInstance, TC_INST_FT_MINTOCOPY, (ULONG)size); in TcSetMinToCopy()
1148 …snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "TurboCap error setting the mintocopy: %s (%08x)", g_TcFunct… in TcSetMinToCopy()
1157 struct pcap_tc *pt = p->priv; in TcGetReceiveWaitHandle()
1159 return g_TcFunctions.InstanceGetReceiveWaitHandle(pt->TcInstance); in TcGetReceiveWaitHandle()
1165 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, in TcOidGetRequest()
1174 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, in TcOidSetRequest()
1182 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, in TcSendqueueTransmit()
1190 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, in TcSetUserBuffer()
1192 return -1; in TcSetUserBuffer()
1198 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, in TcLiveDump()
1200 return -1; in TcLiveDump()
1206 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, in TcLiveDumpEnded()
1208 return -1; in TcLiveDumpEnded()