From 89e1462302c0068d6a79197620f2bac24f1a80fb Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 15 Mar 2024 16:31:27 -0700 Subject: [PATCH 01/19] Fix encoding (iso-8859 -> utf-8) --- src/fw-pktfilter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fw-pktfilter.c b/src/fw-pktfilter.c index d378d7a4..1ba7c5b2 100644 --- a/src/fw-pktfilter.c +++ b/src/fw-pktfilter.c @@ -2,7 +2,7 @@ * fw-pktfilter.c * * Copyright (c) 2002 Dug Song - * Copyright (c) 2001 Jean-Baptiste Marchand, Hervé Schauer Consultants. + * Copyright (c) 2001 Jean-Baptiste Marchand, Hervé Schauer Consultants. * * $Id$ */ From c9fab1b25802f53c4bf41ba574fbcb85098e03b9 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 15 Mar 2024 22:03:49 +0000 Subject: [PATCH 02/19] Initial CI config --- .gitlab-ci.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..ff35b287 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,14 @@ +stages: + - build + +.install-packages: + script: + - sudo apt-get install -y gcc g++ cmake wget git + +build-job-ubuntu-22: + extends: .install-packages + image: ubuntu-22.04 + stage: build + script: + - echo "Compiling the code..." + - echo "Compile complete." \ No newline at end of file From 44b660dcecdc97336595510052de224534a6d6f7 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 15 Mar 2024 22:04:37 +0000 Subject: [PATCH 03/19] Correct tag --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ff35b287..134cdf69 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,7 @@ stages: build-job-ubuntu-22: extends: .install-packages - image: ubuntu-22.04 + image: ubuntu:22.04 stage: build script: - echo "Compiling the code..." From 00376c3e64a8437f4ec95a882338a42e6a694246 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 15 Mar 2024 22:07:59 +0000 Subject: [PATCH 04/19] Update build steps --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 134cdf69..426a8fb3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,10 +5,10 @@ stages: script: - sudo apt-get install -y gcc g++ cmake wget git -build-job-ubuntu-22: +build-job-ubuntu-22-shared-on: extends: .install-packages image: ubuntu:22.04 stage: build script: - - echo "Compiling the code..." - - echo "Compile complete." \ No newline at end of file + cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -B "build/" + cmake --build build/ --config Release \ No newline at end of file From ff6e4882aa4143c929063ab691099aa680efd640 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 15 Mar 2024 22:14:22 +0000 Subject: [PATCH 05/19] Build on Ubuntu w/ w/o shared libs --- .gitlab-ci.yml | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 426a8fb3..314b4788 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,3 +1,6 @@ +variables: + SHARED_LIBS: "ON" + stages: - build @@ -5,10 +8,21 @@ stages: script: - sudo apt-get install -y gcc g++ cmake wget git -build-job-ubuntu-22-shared-on: +.build-job-ubuntu-22: extends: .install-packages image: ubuntu:22.04 - stage: build script: - cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -B "build/" - cmake --build build/ --config Release \ No newline at end of file + cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=$SHARED_LIBS -B "build/" + cmake --build build/ --config Release + +build-job-ubuntu-22-shared-libs-on: + extends: .build-job-ubuntu-22 + stage: build + variables: + SHARED_LIBS: "ON" + +build-job-ubuntu-22-shared-libs-off: + extends: .build-job-ubuntu-22 + stage: build + variables: + SHARED_LIBS: "OFF" \ No newline at end of file From 90e2d3dca9a1cd162ca7f044be8697fab2c4e034 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 15 Mar 2024 22:19:24 +0000 Subject: [PATCH 06/19] Rearrange the build --- .gitlab-ci.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 314b4788..a0c05e0b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,16 +4,13 @@ variables: stages: - build -.install-packages: - script: - - sudo apt-get install -y gcc g++ cmake wget git - .build-job-ubuntu-22: - extends: .install-packages image: ubuntu:22.04 + before_script: + - sudo apt-get install -y gcc g++ cmake wget git script: - cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=$SHARED_LIBS -B "build/" - cmake --build build/ --config Release + - cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=$SHARED_LIBS -B "build/" + - cmake --build build/ --config Release build-job-ubuntu-22-shared-libs-on: extends: .build-job-ubuntu-22 From 7d540a26a0eec53c74d4d9462247477c751cd96e Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 15 Mar 2024 22:22:53 +0000 Subject: [PATCH 07/19] No sudo needed + update cache and upgrade system --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a0c05e0b..ab2a66b0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,8 @@ stages: .build-job-ubuntu-22: image: ubuntu:22.04 before_script: - - sudo apt-get install -y gcc g++ cmake wget git + - apt-get update && apt-get upgrade -y + - apt-get install -y gcc g++ cmake wget git script: - cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=$SHARED_LIBS -B "build/" - cmake --build build/ --config Release From f67e10e1ff1a6cdf57c561f0614ca3c6b13c51bf Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 15 Mar 2024 22:26:59 +0000 Subject: [PATCH 08/19] Variables? --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ab2a66b0..b63c1cf1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,7 @@ stages: - apt-get update && apt-get upgrade -y - apt-get install -y gcc g++ cmake wget git script: - - cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=$SHARED_LIBS -B "build/" + - cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS='$SHARED_LIBS' -B "build/" - cmake --build build/ --config Release build-job-ubuntu-22-shared-libs-on: From b3ae2d1fe90c43c030ab4d37b911c76384dc0e3b Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 15 Mar 2024 22:30:26 +0000 Subject: [PATCH 09/19] Add templates --- .gitlab-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b63c1cf1..cb5063b9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,13 @@ variables: SHARED_LIBS: "ON" +include: + - template: Jobs/Code-Quality.gitlab-ci.yml + - template: Jobs/Test.gitlab-ci.yml + stages: - build + - test .build-job-ubuntu-22: image: ubuntu:22.04 From a3b8c5937a30ce5f0a65bb5525c5c868d22c762a Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 15 Mar 2024 22:34:47 +0000 Subject: [PATCH 10/19] Update templates to be included --- .gitlab-ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cb5063b9..b5e2ef0b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,12 @@ variables: include: - template: Jobs/Code-Quality.gitlab-ci.yml - - template: Jobs/Test.gitlab-ci.yml + - template: Jobs/Secret-Detection.gitlab-ci.yml + - template: Jobs/SAST.gitlab-ci.yml + - template: Jobs/License-Scanning.gitlab-ci.yml + - template: Jobs/Dependency-Scanning.gitlab-ci.yml + - template: Jobs/Code-Quality.gitlab-ci.yml + stages: - build From 88a2c933bf39c78f952309d8aa50334a86fe5141 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 15 Mar 2024 22:38:08 +0000 Subject: [PATCH 11/19] Flawfinder has utf8 issues and needs debugging --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b5e2ef0b..5b2cf730 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,6 @@ variables: SHARED_LIBS: "ON" + SECURE_LOG_LEVEL: "debug". include: - template: Jobs/Code-Quality.gitlab-ci.yml From fee272ffdd877dab9d42617562c13692da3bb88e Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 15 Mar 2024 22:39:09 +0000 Subject: [PATCH 12/19] License scanning now in dep scanning --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5b2cf730..939f6e19 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,7 +6,6 @@ include: - template: Jobs/Code-Quality.gitlab-ci.yml - template: Jobs/Secret-Detection.gitlab-ci.yml - template: Jobs/SAST.gitlab-ci.yml - - template: Jobs/License-Scanning.gitlab-ci.yml - template: Jobs/Dependency-Scanning.gitlab-ci.yml - template: Jobs/Code-Quality.gitlab-ci.yml From ac3c2ab91f90e984cb0055f43668d341f14bdaab Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 15 Mar 2024 22:41:42 +0000 Subject: [PATCH 13/19] Fix typo --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 939f6e19..bced7eb1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,6 @@ variables: SHARED_LIBS: "ON" - SECURE_LOG_LEVEL: "debug". + SECURE_LOG_LEVEL: "debug" include: - template: Jobs/Code-Quality.gitlab-ci.yml From 9a1894e869cb22c2a18fcef37288181f540fded1 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Fri, 15 Mar 2024 23:49:08 +0000 Subject: [PATCH 14/19] Add Windows --- .gitlab-ci.yml | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bced7eb1..aec7f267 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,6 +22,9 @@ stages: script: - cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS='$SHARED_LIBS' -B "build/" - cmake --build build/ --config Release + - pushd python + - python setup.py build + - popd build-job-ubuntu-22-shared-libs-on: extends: .build-job-ubuntu-22 @@ -33,4 +36,30 @@ build-job-ubuntu-22-shared-libs-off: extends: .build-job-ubuntu-22 stage: build variables: - SHARED_LIBS: "OFF" \ No newline at end of file + SHARED_LIBS: "OFF" + + +.windows_job: + tags: + - saas-windows-medium-amd64 + before_script: + - Set-Variable -Name "time" -Value (date -Format "%H:%m") + - echo ${time} + - echo "started by ${GITLAB_USER_NAME}" + script: + - cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS="$SHARED_LIBS" -B "./build" + - cmake --build ./build --config Release + +windows-shared-on: + extends: + - .windows_job + stage: build + variables: + SHARED_LIBS: "OFF" + +windows-shared-off: + extends: + - .windows_job + stage: build + variables: + SHARED_LIBS: "ON" \ No newline at end of file From 403e7306b25e3bd43b8ceae45ced7114fccc6150 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Sat, 16 Mar 2024 00:17:06 +0000 Subject: [PATCH 15/19] Add missing python packages --- .gitlab-ci.yml | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aec7f267..ca2b4fd0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,13 +18,10 @@ stages: image: ubuntu:22.04 before_script: - apt-get update && apt-get upgrade -y - - apt-get install -y gcc g++ cmake wget git + - apt-get install -y gcc g++ cmake wget git python3 python3-pip python3-setuptools script: - cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS='$SHARED_LIBS' -B "build/" - cmake --build build/ --config Release - - pushd python - - python setup.py build - - popd build-job-ubuntu-22-shared-libs-on: extends: .build-job-ubuntu-22 @@ -36,30 +33,4 @@ build-job-ubuntu-22-shared-libs-off: extends: .build-job-ubuntu-22 stage: build variables: - SHARED_LIBS: "OFF" - - -.windows_job: - tags: - - saas-windows-medium-amd64 - before_script: - - Set-Variable -Name "time" -Value (date -Format "%H:%m") - - echo ${time} - - echo "started by ${GITLAB_USER_NAME}" - script: - - cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS="$SHARED_LIBS" -B "./build" - - cmake --build ./build --config Release - -windows-shared-on: - extends: - - .windows_job - stage: build - variables: - SHARED_LIBS: "OFF" - -windows-shared-off: - extends: - - .windows_job - stage: build - variables: - SHARED_LIBS: "ON" \ No newline at end of file + SHARED_LIBS: "OFF" \ No newline at end of file From ef502e0006b6b0127b63010fdce8fc63151ff35f Mon Sep 17 00:00:00 2001 From: lomaster <119946584+Lomasterrrr@users.noreply.github.com> Date: Thu, 13 Feb 2025 19:06:09 +0300 Subject: [PATCH 16/19] Update icmp.h (#100) wrong size of fields for icmp4 timestamp message --- include/dnet/icmp.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/dnet/icmp.h b/include/dnet/icmp.h index f1433a3a..9895789e 100644 --- a/include/dnet/icmp.h +++ b/include/dnet/icmp.h @@ -153,8 +153,8 @@ struct icmp_msg_rtradvert { * Timestamp message data */ struct icmp_msg_tstamp { - uint32_t icmp_id; /* identifier */ - uint32_t icmp_seq; /* sequence number */ + uint16_t icmp_id; /* identifier */ + uint16_t icmp_seq; /* sequence number */ uint32_t icmp_ts_orig; /* originate timestamp */ uint32_t icmp_ts_rx; /* receive timestamp */ uint32_t icmp_ts_tx; /* transmit timestamp */ From 91b6711b3e335092fa4739b0d333035ebfc5d75c Mon Sep 17 00:00:00 2001 From: lomaster <119946584+Lomasterrrr@users.noreply.github.com> Date: Thu, 13 Feb 2025 19:07:39 +0300 Subject: [PATCH 17/19] Update icmp.h (#101) 16bits are enough for Id/Seq. --- include/dnet/icmp.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/dnet/icmp.h b/include/dnet/icmp.h index 9895789e..7f120f6b 100644 --- a/include/dnet/icmp.h +++ b/include/dnet/icmp.h @@ -164,8 +164,8 @@ struct icmp_msg_tstamp { * Address mask message data, RFC 950 */ struct icmp_msg_mask { - uint32_t icmp_id; /* identifier */ - uint32_t icmp_seq; /* sequence number */ + uint16_t icmp_id; /* identifier */ + uint16_t icmp_seq; /* sequence number */ uint32_t icmp_mask; /* address mask */ }; From 411fc5fbfa4be426bd0f39656865d4d21380313f Mon Sep 17 00:00:00 2001 From: Jiri Luznicky Date: Thu, 13 Feb 2025 17:12:37 +0100 Subject: [PATCH 18/19] fix payload size of Netlink message (#99) The `len` parameter of `NLMSG_LENGTH` was size of Netlink header instead of RtNetlink header. Also make it more clear that the parameter of the macro is the payload size, which is RtNetlink message in this case. --- src/route-linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/route-linux.c b/src/route-linux.c index 45b5c2e4..4275a304 100644 --- a/src/route-linux.c +++ b/src/route-linux.c @@ -232,7 +232,7 @@ route_get(route_t *r, struct route_entry *entry) memset(buf, 0, sizeof(buf)); nmsg = (struct nlmsghdr *)buf; - nmsg->nlmsg_len = NLMSG_LENGTH(sizeof(*nmsg)) + RTA_LENGTH(alen); + nmsg->nlmsg_len = NLMSG_LENGTH(sizeof(*rmsg) + RTA_LENGTH(alen)); nmsg->nlmsg_flags = NLM_F_REQUEST; nmsg->nlmsg_type = RTM_GETROUTE; nmsg->nlmsg_seq = ++seq; From 3463e6e2f58a0da9d241a22aaa65eaa543caa1c6 Mon Sep 17 00:00:00 2001 From: "Z. Liu" Date: Thu, 3 Apr 2025 19:57:57 +0800 Subject: [PATCH 19/19] python/dnet.pyx: fix incompatible-function-pointer-types for modern compiler (#104) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * python/dnet.pyx: fix incompatible-function-pointer-types for modern compiler which is error now, see https://bugs.gentoo.org/933360, clang 19 (maybe earlier) has the same problem too * python/dnet.pyx: fix -Wincompatible-pointer-types reported by gcc14 ./dnet.c:8451:52: error: passing argument 2 of ‘PyObject_AsReadBuffer’ from incompatible pointer type [-Wincompatible-pointer-types] 8451 | __pyx_t_1 = (PyObject_AsReadBuffer(__pyx_v_pkt, (&__pyx_v_p), (&__pyx_v_n)) == 0); | ~^~~~~~~~~~~ | | | char ** /usr/include/python3.12/abstract.h:370:52: note: expected ‘const void **’ but argument is of type ‘char **’ 370 | const void **buffer, | ~~~~~~~~~~~~~^~~~~~ ./dnet.c:8451:66: error: passing argument 3 of ‘PyObject_AsReadBuffer’ from incompatible pointer type [-Wincompatible-pointer-types] 8451 | __pyx_t_1 = (PyObject_AsReadBuffer(__pyx_v_pkt, (&__pyx_v_p), (&__pyx_v_n)) == 0); | ~^~~~~~~~~~~ | | | int * /usr/include/python3.12/abstract.h:371:51: note: expected ‘Py_ssize_t *’ {aka ‘long int *’} but argument is of type ‘int *’ 371 | Py_ssize_t *buffer_len); | ~~~~~~~~~~~~^~~~~~~~~~ Signed-off-by: Z. Liu --- python/dnet.pyx | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/python/dnet.pyx b/python/dnet.pyx index 4e3604fd..6aefaa2a 100644 --- a/python/dnet.pyx +++ b/python/dnet.pyx @@ -25,7 +25,7 @@ cdef extern from "dnet.h": cdef extern from "Python.h": object PyBytes_FromStringAndSize(char *s, int len) int PyBytes_Size(object o) - int PyObject_AsReadBuffer(object o, char **pp, int *lenp) + int PyObject_AsReadBuffer(object o, const void **pp, ssize_t *lenp) int PyLong_Check(object o) int PyLong_Check(object o) long PyLong_AsLong(object o) @@ -294,8 +294,8 @@ def ip_checksum(pkt): """ cdef char buf[2048] cdef char *p - cdef int n - if PyObject_AsReadBuffer(pkt, &p, &n) == 0: + cdef ssize_t n + if PyObject_AsReadBuffer(pkt, &p, &n) == 0: if n < 2048: memcpy(buf, p, n) __ip_checksum(buf, n) @@ -310,8 +310,8 @@ def ip_checksum(pkt): def ip_cksum_add(buf, int sum): cdef char *p - cdef int n - if PyObject_AsReadBuffer(buf, &p, &n) == 0: + cdef ssize_t n + if PyObject_AsReadBuffer(buf, &p, &n) == 0: return __ip_cksum_add(p, n, sum) else: raise TypeError @@ -661,7 +661,7 @@ cdef extern from *: addr_t arp_ha ctypedef struct arp_t: int __xxx - ctypedef int (*arp_handler)(arp_entry *entry, void *arg) except -1 + ctypedef int (*arp_handler)(const arp_entry *entry, void *arg) except -1 arp_t *arp_open() int arp_add(arp_t *arp, arp_entry *entry) @@ -687,7 +687,7 @@ ARP_OP_REPLY = 2 # /* response giving hardware address */ ARP_OP_REVREQUEST = 3 # /* request to resolve pa given ha */ ARP_OP_REVREPLY = 4 # /* response giving protocol address */ -cdef int __arp_callback(arp_entry *entry, void *arg) except -1: +cdef int __arp_callback(const arp_entry *entry, void *arg) except -1: f, a = arg pa, ha = addr(), addr() (pa)._addr = entry.arp_pa @@ -911,7 +911,7 @@ cdef extern from *: addr_t intf_alias_addrs[8] # XXX ctypedef struct intf_t: int __xxx - ctypedef int (*intf_handler)(intf_entry *entry, void *arg) except -1 + ctypedef int (*intf_handler)(const intf_entry *entry, void *arg) except -1 intf_t *intf_open() int intf_get(intf_t *intf, intf_entry *entry) @@ -933,7 +933,7 @@ INTF_FLAG_NOARP = 0x08 # /* disable ARP */ INTF_FLAG_BROADCAST = 0x10 # /* supports broadcast (r/o) */ INTF_FLAG_MULTICAST = 0x20 # /* supports multicast (r/o) */ -cdef object ifent_to_dict(intf_entry *entry): +cdef object ifent_to_dict(const intf_entry *entry): d = {} d['name'] = entry.intf_name d['type'] = entry.intf_type @@ -970,7 +970,7 @@ cdef dict_to_ifent(object d, intf_entry *entry): for i from 0 <= i < entry.intf_alias_num: entry.intf_alias_addrs[i] = (d['alias_addrs'][i])._addr -cdef int __intf_callback(intf_entry *entry, void *arg) except -1: +cdef int __intf_callback(const intf_entry *entry, void *arg) except -1: f, a = arg ret = f(ifent_to_dict(entry), a) if not ret: @@ -1077,7 +1077,7 @@ cdef extern from *: addr_t route_gw ctypedef struct route_t: int __xxx - ctypedef int (*route_handler)(route_entry *entry, void *arg) except -1 + ctypedef int (*route_handler)(const route_entry *entry, void *arg) except -1 route_t *route_open() int route_add(route_t *route, route_entry *entry) @@ -1086,7 +1086,7 @@ cdef extern from *: int route_loop(route_t *route, route_handler callback, void *arg) route_t *route_close(route_t *route) -cdef int __route_callback(route_entry *entry, void *arg) except -1: +cdef int __route_callback(const route_entry *entry, void *arg) except -1: f, a = arg dst, gw = addr(), addr() (dst)._addr = entry.route_dst @@ -1183,7 +1183,7 @@ cdef extern from *: ctypedef struct fw_t: int __xxx - ctypedef int (*fw_handler)(fw_rule *rule, void *arg) except -1 + ctypedef int (*fw_handler)(const fw_rule *rule, void *arg) except -1 fw_t *fw_open() int fw_add(fw_t *f, fw_rule *rule) @@ -1197,7 +1197,7 @@ FW_OP_BLOCK = 2 FW_DIR_IN = 1 FW_DIR_OUT = 2 -cdef object rule_to_dict(fw_rule *rule): +cdef object rule_to_dict(const fw_rule *rule): d = {} d['device'] = rule.fw_device d['op'] = rule.fw_op @@ -1235,7 +1235,7 @@ cdef dict_to_rule(object d, fw_rule *rule): rule.fw_dport[0] = d['dport'][0] rule.fw_dport[1] = d['dport'][1] -cdef int __fw_callback(fw_rule *rule, void *arg) except -1: +cdef int __fw_callback(const fw_rule *rule, void *arg) except -1: f, a = arg ret = f(rule_to_dict(rule), a) if not ret: