{"id":13775332,"url":"https://github.com/dns-oarc/pcap-thread","last_synced_at":"2025-11-09T16:04:55.685Z","repository":{"id":50146664,"uuid":"65970922","full_name":"DNS-OARC/pcap-thread","owner":"DNS-OARC","description":"PCAP helper library with POSIX threads support and transport layer callbacks","archived":false,"fork":false,"pushed_at":"2023-02-06T09:19:11.000Z","size":328,"stargazers_count":6,"open_issues_count":3,"forks_count":3,"subscribers_count":5,"default_branch":"develop","last_synced_at":"2024-11-17T10:39:45.844Z","etag":null,"topics":["c","library","packet-capture","pcap","pthreads"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DNS-OARC.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-08-18T06:23:55.000Z","updated_at":"2023-02-03T15:13:16.000Z","dependencies_parsed_at":"2022-09-24T02:50:47.189Z","dependency_job_id":"5f736471-eb19-49e8-91ff-c4f1f44178bd","html_url":"https://github.com/DNS-OARC/pcap-thread","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DNS-OARC%2Fpcap-thread","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DNS-OARC%2Fpcap-thread/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DNS-OARC%2Fpcap-thread/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DNS-OARC%2Fpcap-thread/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DNS-OARC","download_url":"https://codeload.github.com/DNS-OARC/pcap-thread/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225872238,"owners_count":17537382,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","library","packet-capture","pcap","pthreads"],"created_at":"2024-08-03T17:01:37.017Z","updated_at":"2025-11-09T16:04:55.680Z","avatar_url":"https://github.com/DNS-OARC.png","language":"C","funding_links":[],"categories":["\u003ca id=\"f13469c9891173804423be4403b2c4ff\"\u003e\u003c/a\u003epcap"],"sub_categories":["\u003ca id=\"eb49514924c3f4bf2acf6f3a4436af13\"\u003e\u003c/a\u003e未分类"],"readme":"# pcap-thread\n\nPCAP helper library with POSIX threads support and transport layer callbacks\n\n## About\n\nThis is a helper library that will initialize the `pcap_t` for you and,\nif you have support, launch a thread per `pcap_t` for the collection which\nis then feeded back to the main thread using a queue before being passed on\nto the callback.\n\nAdditional callbacks exists for simplifying the handling of various transport\nlayers, based on [pcap_layers](https://github.com/wessels/pcap_layers) by\nDuane Wessels (The Measurement Factory, Inc.), such as ether, VLAN, IP, IPv4,\nIPv6, GRE tunnels, UDP and TCP.\n\n## Usage\n\nHere is a short example how to use this helper, see the hexdump directory\nfor a more complete example.\n\n```c\n#include \"config.h\"\n#include \"pcap-thread/pcap_thread.h\"\n\nvoid callback(u_char* user, const struct pcap_pkthdr* packet_header, const u_char* packet, int datalink_type) {\n    ...\n}\n\nint main(void) {\n    pcap_thread_t pt = PCAP_THREAD_T_INIT;\n\n    pcap_thread_set_snaplen(\u0026pt, 65535);\n    pcap_thread_set_filter(\u0026pt, \"port 80\", 7);\n    pcap_thread_set_callback(\u0026pt, callback);\n    pcap_thread_open(\u0026pt, \"eth0\", 0);\n    pcap_thread_open(\u0026pt, \"lo\", 0);\n    pcap_thread_run(\u0026pt);\n    pcap_thread_close(\u0026pt);\n\n    return 0;\n}\n```\n\n### git submodule\n\n```shell\ngit submodule init\ngit submodule add https://codeberg.org/DNS-OARC/pcap-thread.git src/pcap-thread\ngit submodule update --init --recursive\n```\n\n### auto(re)conf\n\n```shell\nautoreconf ... --include=src/pcap-thread/m4\n```\n\n### configure.ac\n\n```m4\nAX_PCAP_THREAD\n```\n\n### Top level Makefile.am\n\n```m4\nACLOCAL_AMFLAGS = ... -I src/pcap-thread/m4\n```\n\n### Makefile.am\n\n```m4\nAM_CFLAGS += $(PTHREAD_CFLAGS)\nAM_CPPFLAGS += $(PTHREAD_CFLAGS)\nAM_CXXFLAGS += $(PTHREAD_CFLAGS)\n\nprogram_SOURCES += pcap-thread/pcap-thread.c\ndist_program_SOURCES += pcap-thread/pcap-thread.h\nprogram_LDADD += $(PTHREAD_LIBS)\n```\n\n## Author(s)\n\nJerry Lundström \u003cjerry@dns-oarc.net\u003e\n\n## Copyright and license\n\nCopyright (c) 2016-2025 OARC, Inc.\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n\n1. Redistributions of source code must retain the above copyright\n   notice, this list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright\n   notice, this list of conditions and the following disclaimer in\n   the documentation and/or other materials provided with the\n   distribution.\n\n3. Neither the name of the copyright holder nor the names of its\n   contributors may be used to endorse or promote products derived\n   from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\nFOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\nCOPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\nBUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\nLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\nANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdns-oarc%2Fpcap-thread","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdns-oarc%2Fpcap-thread","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdns-oarc%2Fpcap-thread/lists"}