2011-02-06 11 views

उत्तर

15

मैनुअल इस अद्भुत तरीके से वर्णन करता है (मैं कह रहा हूं कि सीधे चेहरे, वादे के साथ)। man pcap_loop से:

pcap_loop() processes packets from a live capture or ``savefile'' 
    until cnt packets are processed, the end of the ``savefile'' is 
    reached when reading from a ``savefile'', pcap_breakloop() is called, 
    or an error occurs. It does not return when live read timeouts 
    occur. A value of -1 or 0 for cnt is equivalent to infinity, so that 
    packets are processed until another ending condition occurs. 

    pcap_dispatch() processes packets from a live capture or ``savefile'' 
    until cnt packets are processed, the end of the current bufferful of 
    packets is reached when doing a live capture, the end of the ``save‐ 
    file'' is reached when reading from a ``savefile'', pcap_breakloop() 
    is called, or an error occurs. Thus, when doing a live capture, cnt 
    is the maximum number of packets to process before returning, but is 
    not a minimum number; when reading a live capture, only one bufferful 
    of packets is read at a time, so fewer than cnt packets may be pro‐ 
    cessed. A value of -1 or 0 for cnt causes all the packets received in 
    one buffer to be processed when reading a live capture, and causes 
    all the packets in the file to be processed when reading a ``save‐ 
    file''. 

मैं जानता हूँ कि तुम सच में पढ़ सकते हैं और यह सब समझते हैं, तो चलो इसे तोड़ने के नीचे जाने के लिए नहीं करना चाहता था।

दोनों कार्यों: एक जीवित कब्जा या "savefile" इन शर्तों के किसी भी जब तक से

  • प्रक्रिया पैकेट होते हैं:
    • निर्दिष्ट गिनती
    • "savefile के अंत तक पहुँच जाता है "
    • pcap_breakloop() को
    • एक त्रुटि होती है
  • अनिवार्य रूप से "पैकेट की असीमित संख्या को संसाधित करने" के लिए -1 या 0 पर विचार करें - यानी, एक और अंत स्थिति होने तक।

pcap_dispatch() अकेले

  • इसके अलावा पैकेट की वर्तमान bufferful के अंत के बाद रिटर्न (-1 पुराने संस्करणों के साथ अंतर के लिए सिफारिश की है, बाद में मैनुअल में) तक पहुँच जाता है, जब कर एक लाइव कैप्चर (दूसरे शब्दों में, अधिक बार वापस आ सकता है, क्योंकि निर्दिष्ट गणना न्यूनतम नहीं है)
संबंधित मुद्दे