Compare commits

...

748 Commits

Author SHA1 Message Date
Sebastian Huber
4599f551de dhcp: Clear flags
Do not assume that mem_malloc() returns cleared memory.
2025-08-03 11:35:52 +02:00
Sergey Fionov
41a36098b3 tcp: Fix TCP timestamps for big-endian systems
Current parsing code is building reverse-order integer, and then calls htonl()
to assign right value to "ts_recent" field of pcb.

This works correctly on little-endian machines, where htonl() reverses bytes.
However, on big-endian machines, htonl() is no-op, so bytes stay reversed.

This patch fixes it by building non-reversed integer.
2025-08-03 11:33:53 +02:00
David Cermak
e7ab7e0773 autoip: Choose next address after rate limit
AutoIP now selects a new address after rate limit timeout,
AutoIP tries a new address by incrementing the tried_llipaddr counter
in the ACD_DECLINE case of the callback.

In lwIP pre-2.2.0, address conflict detection was handled within autoip.c, and
the incrementing happened in autoip_restart() (line 150). When ACD was
extracted into a separate module in 2.2.0, this increment was missing for the
rate-limiting path.

Without this change, devices continuously retry the same IP address after rate
limiting, causing them to fail Bonjour Conformance Tests.
2025-08-03 11:24:55 +02:00
Jerome Forissier
b1edb7780f tftp: bind to TFTP port only when in server mode
The TFTP app should not bind to the TFTP server port when configured as
a client. Instead, the local port should be chosen from the dynamic
range (49152 ~ 65535) so that if the application is stopped and started
again, the remote server will not consider the new packets as part of
the same context (which would cause an error since a new RRQ would be
unexpected).

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-07-15 22:09:27 +02:00
Simon Goldschmidt
56b29f8bcf ip4_frag/ip6_frag: fix potential NULL-pointer access on memory errors 2025-06-03 21:04:39 +02:00
Erik Ekman
92522e4538 codeql: Use ubuntu-latest instead of 20.04 2025-05-26 19:15:39 +02:00
Alexey Lapshin
571c46253f src/core: fix gcc analyzer warning
Make ip4_addr_isany check first to avoid warning:
"check of 'ipaddr' for NULL after already dereferencing it [-Werror=analyzer-deref-before-check]"
2025-05-26 19:10:03 +02:00
Mike Kleshov
ca0395c5ae Revert "Apply patch #10511: remove code with no effect in httpd.c"
This reverts commit f877b457a1bb759d48567326ec020be7e3a3d989.
2025-04-02 10:22:43 +03:00
MinghaoWang
31d8988f89 Apply patch #10358: preserve dhcp memory type flag 2025-03-21 22:34:52 +03:00
Mike Kleshov
f877b457a1 Apply patch #10511: remove code with no effect in httpd.c 2025-03-21 19:35:05 +03:00
Mike Kleshov
6c8874bf5d Apply patch #10047: HTTP11_CONNECTIONKEEPALIVE2 not needed any more 2025-03-21 19:25:31 +03:00
Oswin Bult
8459488006 Apply patch #10406: simplify sign extension 2025-03-21 18:48:50 +03:00
Simon Goldschmidt
ffce5ab1c7 try to fix unit test compiling with clang 2025-03-03 21:45:32 +01:00
Jarno Malmari
e55896319b Fix compilation with LWIP_DEBUG
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2025-02-24 21:52:41 +01:00
Matthias Dietrich
ba306bcdaa Fix missing END_TEST in test_ip6_reass unit test
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2025-02-24 21:32:58 +01:00
Simon Goldschmidt
554e104095 next release will probably be 2.2.2 2025-02-06 08:34:57 +01:00
Simon Goldschmidt
77dcd25a72 Prepare 2.2.1 release 2025-02-05 20:38:17 +01:00
Simon Goldschmidt
b6c6098964 Update CHANGELOG in preparation for 2.2.1 release 2025-02-05 20:34:17 +01:00
Jan Breuer
fbd597e450 snmp: Mention struct field removal in UPGRADING 2024-11-29 18:26:58 +01:00
Jan Breuer
5ee5801c2c snmp: remove unused prev field from snmp_varbind 2024-11-29 18:26:07 +01:00
Jan Breuer
f05e20101e snmp: remove handling of varbind->prev because it is never used
No code in snmp traverses varbinds backwards so prev is never used.
This also fixes false positive dangling pointer detection by GCC.
2024-11-29 18:26:07 +01:00
Jan Breuer
52bb3eedd7 snmp: fix dangling pointer in snmp_traps 2024-11-29 18:26:07 +01:00
Arne Schwabe
c06cc7655d Support FreeBSD in the default configuration
FreeBSD support is basically just very small changes related to
some different includes and one define to not hide non-standard defines
like B115200.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
2024-11-26 23:52:59 +01:00
Erik Ekman
3cae475d63 apps/snmp: Remove @retval tags on void methods
Fixing clang 19.1.0 error:
src/apps/snmp/snmp_traps.c:140:15: error: empty paragraph passed to '@retval' command [-Werror,-Wdocumentation]
2024-11-26 23:45:57 +01:00
scribam
41b8f785c3 cmake: create dist target if not exists 2024-11-26 23:18:43 +01:00
Erik Ekman
5d1b34f581 Bump versions in codeql action 2024-11-26 23:10:47 +01:00
Sebastian Huber
c24678acd2 test/unit: Fix DHCP tests
On big-endian targets, the htonl() function is a no operation.  We need
another way to get a bad XID.  Add get_bad_xid() to avoid code
duplication.
2024-11-26 23:01:11 +01:00
Sebastian Huber
80cfb002f9 test/unit: Fix test_ip4_frag
Reset linkoutput_byte_ctr for this test case.
2024-11-23 10:42:14 +01:00
Erik Ekman
73fcf72792 Stop running codeql every 24h
Only run on push/pull requests
2024-06-30 22:05:50 +02:00
Erik Ekman
4f9484f5ab Run ci job on github pull requests 2024-06-30 22:01:59 +02:00
jeans
86c9f79991 refactor: added apple macro for fs handling 2024-05-14 13:53:42 +02:00
jeans
8e1a247c1f refactor: added macOS include file
MacOS supports util.h as well
2024-05-14 13:53:42 +02:00
Erik Ekman
1cc1536e6a test/unit: fix inconsistent nullness check error
Inside a testcase, but still. Trying to address #160
2024-04-09 20:11:39 +02:00
Simon Goldschmidt
d0efd9ef7b tcpip: fix that TCPIP_CORE_LOCK is not released for LWIP_TIMERS==0
See bug #65328

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2024-02-19 21:44:18 +01:00
Krzysztof Mazur
e799c266fa makefsdata: extend file type matching with .shtml and .shtm
[Problem]
When using makefsdata perl script to convert shtml files with SSI tags
the shtml files get generated with text/plain content type, making
browsers not render them correctly

[Solution]
Extend the regex to generate text/html content type for any of:
.htm, .html, .shtm, .shtml extensions
2024-02-19 20:58:58 +01:00
Brian
cb511019b0 Update codeql-buildscript.sh
Adding install dependencies step
2024-02-19 20:03:32 +01:00
Brian
9004e7bd77 Add CodeQL Workflow for Code Security Analysis
Add CodeQL Workflow for Code Security Analysis

This pull request introduces a CodeQL workflow to enhance the security analysis of our repository. CodeQL is a powerful static analysis tool that helps identify and mitigate security vulnerabilities in our codebase. By integrating this workflow into our GitHub Actions, we can proactively identify and address potential issues before they become security threats.

We added a new CodeQL workflow file (.github/workflows/codeql.yml) that
- Runs on every pull request (functionality to run on every push to main branches is included as a comment for convenience).
- Runs daily.
- Excludes queries with a high false positive rate or low-severity findings.
- Does not display results for git submodules, focusing only on our own codebase.

Testing:
To validate the functionality of this workflow, we have run several test scans on the codebase and reviewed the results. The workflow successfully compiles the project, identifies issues, and provides actionable insights while reducing noise by excluding certain queries and third-party code.

Deployment:
Once this pull request is merged, the CodeQL workflow will be active and automatically run on every push and pull request to the main branch. To view the results of these code scans, please follow these steps:
1. Under the repository name, click on the Security tab.
2. In the left sidebar, click Code scanning alerts.

Additional Information:
- You can further customize the workflow to adapt to your specific needs by modifying the workflow file.
- For more information on CodeQL and how to interpret its results, refer to the GitHub documentation and the CodeQL documentation (https://codeql.github.com/ and https://codeql.github.com/docs/).

Signed-off-by: Brian <bayuan@purdue.edu>
2024-02-19 20:03:32 +01:00
Brian
17b1f5d382 Add CodeQL Workflow for Code Security Analysis
Add CodeQL Workflow for Code Security Analysis

This pull request introduces a CodeQL workflow to enhance the security analysis of our repository. CodeQL is a powerful static analysis tool that helps identify and mitigate security vulnerabilities in our codebase. By integrating this workflow into our GitHub Actions, we can proactively identify and address potential issues before they become security threats.

We added a new CodeQL workflow file (.github/workflows/codeql.yml) that
- Runs on every pull request (functionality to run on every push to main branches is included as a comment for convenience).
- Runs daily.
- Excludes queries with a high false positive rate or low-severity findings.
- Does not display results for git submodules, focusing only on our own codebase.

Testing:
To validate the functionality of this workflow, we have run several test scans on the codebase and reviewed the results. The workflow successfully compiles the project, identifies issues, and provides actionable insights while reducing noise by excluding certain queries and third-party code.

Deployment:
Once this pull request is merged, the CodeQL workflow will be active and automatically run on every push and pull request to the main branch. To view the results of these code scans, please follow these steps:
1. Under the repository name, click on the Security tab.
2. In the left sidebar, click Code scanning alerts.

Additional Information:
- You can further customize the workflow to adapt to your specific needs by modifying the workflow file.
- For more information on CodeQL and how to interpret its results, refer to the GitHub documentation and the CodeQL documentation (https://codeql.github.com/ and https://codeql.github.com/docs/).

Signed-off-by: Brian <bayuan@purdue.edu>
2024-02-19 20:03:32 +01:00
Brian
10dc9b7eb3 Add CodeQL Workflow for Code Security Analysis
Add CodeQL Workflow for Code Security Analysis

This pull request introduces a CodeQL workflow to enhance the security analysis of our repository. CodeQL is a powerful static analysis tool that helps identify and mitigate security vulnerabilities in our codebase. By integrating this workflow into our GitHub Actions, we can proactively identify and address potential issues before they become security threats.

We added a new CodeQL workflow file (.github/workflows/codeql.yml) that
- Runs on every pull request (functionality to run on every push to main branches is included as a comment for convenience).
- Runs daily.
- Excludes queries with a high false positive rate or low-severity findings.
- Does not display results for git submodules, focusing only on our own codebase.

Testing:
To validate the functionality of this workflow, we have run several test scans on the codebase and reviewed the results. The workflow successfully compiles the project, identifies issues, and provides actionable insights while reducing noise by excluding certain queries and third-party code.

Deployment:
Once this pull request is merged, the CodeQL workflow will be active and automatically run on every push and pull request to the main branch. To view the results of these code scans, please follow these steps:
1. Under the repository name, click on the Security tab.
2. In the left sidebar, click Code scanning alerts.

Additional Information:
- You can further customize the workflow to adapt to your specific needs by modifying the workflow file.
- For more information on CodeQL and how to interpret its results, refer to the GitHub documentation and the CodeQL documentation (https://codeql.github.com/ and https://codeql.github.com/docs/).

Signed-off-by: Brian <bayuan@purdue.edu>
2024-02-19 20:03:32 +01:00
Brian
c3d6fe9d72 Add CodeQL Workflow for Code Security Analysis
Add CodeQL Workflow for Code Security Analysis

This pull request introduces a CodeQL workflow to enhance the security analysis of our repository. CodeQL is a powerful static analysis tool that helps identify and mitigate security vulnerabilities in our codebase. By integrating this workflow into our GitHub Actions, we can proactively identify and address potential issues before they become security threats.

We added a new CodeQL workflow file (.github/workflows/codeql.yml) that
- Runs on every push and pull request to the main branch.
- Excludes queries with a high false positive rate or low-severity findings.
- Does not display results for third-party code, focusing only on our own codebase.

Testing:
To validate the functionality of this workflow, we have run several test scans on the codebase and reviewed the results. The workflow successfully compiles the project, identifies issues, and provides actionable insights while reducing noise by excluding certain queries and third-party code.

Deployment:
Once this pull request is merged, the CodeQL workflow will be active and automatically run on every push and pull request to the main branch. To view the results of these code scans, please follow these steps:
1. Under the repository name, click on the Security tab.
2. In the left sidebar, click Code scanning alerts.

Additional Information:
- You can further customize the workflow to adapt to your specific needs by modifying the workflow file.
- For more information on CodeQL and how to interpret its results, refer to the GitHub documentation and the CodeQL documentation.

Signed-off-by: Brian <bayuan@purdue.edu>
2024-02-19 20:03:32 +01:00
Kirill Lokotkov
93821fc437 Fixed netdb.c when LWIP_SOCKET_HAVE_SA_LEN == 0
Fields sin6_len and sin_len are always used in the file but not all implementations of sockaddr_in or sockaddr_in6 have this fields (including Linux implementation).
Added #if-check to avoid compilation errors in such cases.
2024-02-19 18:13:28 +01:00
Kirill Lokotkov
7c494b3829 Added "lwip/errno.h" to netdb.c includes
Defines EINVAL and ERANGE are used in the file but not included directly. When I try to use <sys/socket.h> and <arpa/inet.h> as LWIP_SOCKET_EXTERNAL_HEADERS it causes errors with this defines.
2024-02-19 18:13:28 +01:00
Sebastian Michel
e1b8080346 contrib: fixed c++ compatibility of unix port 2024-02-19 18:04:02 +01:00
Simon Goldschmidt
347054b329 Fix C++ compatibility of newly added function lwip_memcmp_consttime() 2024-01-09 21:26:40 +01:00
Simon Goldschmidt
c167a54540 ppp: use constant-time memcmp for checking credentials
See #65119
2024-01-09 21:23:11 +01:00
Simon Goldschmidt
25de99d1c1 Introduce constant-time memcmp and use it for snmpv3_get_engine_boots
See #65118
2024-01-09 21:14:49 +01:00
Simon Goldschmidt
09d929f7ff Fix uninitialized variable warning introduced with last commit
(at least reported by MS-VS C compiler)
2024-01-09 20:51:10 +01:00
Renzo Davoli
83abc8714c avoid callbacks for unsuccessful lwip_accept
See bug #64780
2024-01-09 20:45:05 +01:00
Simon Goldschmidt
09188668c7 update tinydir.h to newest version (1.2.6)
Update to cxong/tinydir version 1.2.6 commit 8124807 ("Fix buffer overflow in tinydir_file_open with long path names")

Although we're not affected of this bug, prevent others copying from our repo being affected...
2024-01-04 22:00:56 +01:00
Simon Goldschmidt
b413b04093 makefsdata: fix buffer corruption with very long paths
See bug #64941
2023-11-29 22:03:46 +01:00
Simon Goldschmidt
ee1523630a httpc with LWIP_HTTPC_HAVE_FILE_IO: fix heap buffer overflow for long local filenames
See bug #64940
2023-11-29 21:35:38 +01:00
Erik Ekman
5e3268cf3e src/core: Fix speling issues
Found by codespell
2023-10-14 18:16:49 +02:00
Erik Ekman
8c1190143c Ignore vim swap files 2023-10-14 18:10:30 +02:00
Erik Ekman
5e45328bb5 src/apps: Fix speling issues
Found by codespell
2023-10-14 18:08:00 +02:00
Erik Ekman
b6b20613ce src/api: Fix speling issues
Found by codespell
2023-10-14 18:04:35 +02:00
Erik Ekman
e7abb85d63 contrib: Fix speling issues
Found by codespell
2023-10-14 18:01:37 +02:00
Erik Ekman
3c06267d8e apps/http_client: Fix speling issues
Found by codespell
2023-10-14 17:51:01 +02:00
Erik Ekman
0ab52ff447 PPP: Fix speling issues
Found by codespell
2023-10-14 17:51:01 +02:00
Erik Ekman
20c9b117e1 test: Fix speling issues
Found by codespell
2023-10-14 17:51:01 +02:00
Erik Ekman
34516d5c2e Update codespell false positives 2023-10-14 17:51:01 +02:00
Florian La Roche
670a2f0827 Fix typos
From patch #10399
2023-10-14 17:34:13 +02:00
Simon Goldschmidt
1eeb70fbfa dhcp: fix memory corruption when LWIP_DHCP_MAX_DNS_SERVERS > DNS_MAX_SERVERS
see patch #10124
2023-10-12 22:08:14 +02:00
Simon Goldschmidt
b9ca1deba8 Fix building with ISO C90
This fixes the changes of commit 574bd6e5aa
2023-10-12 21:41:49 +02:00
Simon Goldschmidt
efe78e7e5b pbuf_cat: add a simple check to ensure we don't cat the same pbuf to itself 2023-10-12 21:34:11 +02:00
Simon Goldschmidt
6864eb1749 unixlib: LWIP_LISTEN_BACKLOG -> TCP_LISTEN_BACKLOG
see patch #10116
2023-10-12 21:10:53 +02:00
David Fries
35cbad52cc Document that sntp_setservername doesn't copy the string
I was expecting the string to be duplicated, doing a Google search
shows others did as well.
2023-10-12 21:04:11 +02:00
duckpowerMB
574bd6e5aa tcp_in : fix ooseq update error
if a pbuf received with the same seqno in ooseq ,
we then check  the size and replace the existing one
with the larger one,but if the existing one is the
last segment in ooseq ,it might has been trimed before.
the replacing action will overrun our receive windows

see patch #10106 and bug #56397
2023-10-12 21:00:21 +02:00
Thomas Kindler
de0b97861a Fix bug #60681: Initialize custom data in pbuf struct
Add a #define that users can use to initialize LWIP_PBUF_CUSTOM_DATA fields.

see patch #10072
idea by Thomas Kindler <mail_lwip@t-kindler.de>
2023-10-12 20:29:16 +02:00
Simon Goldschmidt
f5e7e8e576 pbuf: pbuf_get_contiguous: allow passing NULL for buffer to prevent copying
see bug #62832
2023-10-12 08:26:00 +02:00
Faidon Liambotis
4f88651247 Add MEM_CUSTOM_ALLOCATOR and make LIBC a subset of it
Allow one to provide a custom implementation of free/malloc/calloc
instead of the lwip internal allocator. The code to use the libc's
implementation already existed, so generalize the existing code and make
the libc variant a specialized case of this new capability, retaining
full backwards compatibility.
2023-10-11 21:45:55 +02:00
Simon Goldschmidt
e01c9a9504 dhcp: set LWIP_DHCP_DISCOVER_ADD_HOSTNAME==1 by DEFAULT_ACCEPTMBOX_SIZE
see bug #63457
2023-10-11 21:39:48 +02:00
Simon Goldschmidt
90a440eafd sockets: fix socket leak when using setsockopt/getsockopt hook with LWIP_NETCONN_FULLDUPLEX==1
see bug #63458
2023-10-11 21:23:32 +02:00
Simon Goldschmidt
583f352f60 altcp_mbedtls: don't ignore return value of mbedtls_ssl_flush_output
see bug #64045/task #16283
2023-10-11 21:18:56 +02:00
Simon Goldschmidt
7fd1350802 sockets: fix bug #63898: allow socket option IPV6_CHECKSUM for both IPPROTO_IPV6 and IPPROTO_RAW
See bug #63898
2023-10-10 22:27:03 +02:00
Simon Goldschmidt
c8d9adde0f win32 port: fix linking x64 with pcap 2023-10-10 22:24:29 +02:00
Simon Goldschmidt
e655b41a49 win32 port: allow "edit-and-continue" by disabling /SAFESEH 2023-10-10 21:58:56 +02:00
Simon Goldschmidt
2e650364fa win32 port: fix wrong intermediate directories 2023-10-10 20:43:55 +02:00
Simon Goldschmidt
ab1f582043 httpd: fix bug #64458: When tcp_err() is invoked, tcp_pcb is freed but httpd_post_finished() is not called by httpd.c 2023-10-10 20:40:42 +02:00
Simon Goldschmidt
b5f6720f88 apps/tftp: fix compiling for 64-bit 2023-10-10 20:39:45 +02:00
Simon Goldschmidt
5ec4c1d1f2 ping: fix compiling in dual-stack mode 2023-10-10 20:15:49 +02:00
Simon Goldschmidt
9e2fb2806f unittests: fix compiling in release mode 2023-10-10 20:14:52 +02:00
Simon Goldschmidt
4323e95dce win32 port: add x64 configurations 2023-10-10 20:14:16 +02:00
Simon Goldschmidt
66ef250b8c Fix running IPv6 reassembly unit tests on 64-bit 2023-10-10 19:59:06 +02:00
Simon Goldschmidt
c8f42025ce ipv6 reassembly: fix detecting holes in reassembled packets
Added unit test for reassembly.

See bug #64767
2023-10-10 16:31:16 +02:00
Simon Goldschmidt
16e8ef3145 ipv6: fix ip6_current_header() after reassembly
ip6_current_header() should point to the header before the reassembled data,
not to the first received pbuf (not necessarily the same).

See bug #64031
2023-10-10 16:31:09 +02:00
Simon Goldschmidt
76c7ac5cf9 posixlib: fix posixlib/CMakeLists.txt 2023-10-05 20:30:54 +02:00
Simon Goldschmidt
98e63b6acf apps: http client: improve the HTTP client; ensure connection settings are passed
Without connection settings, the caller is not informed of success vs failure of a transfer.
See bug #63554
2023-10-04 22:26:22 +02:00
Simon Goldschmidt
20f6ac7426 msvc: clean up duplicate use of intermediate directories 2023-10-04 21:42:42 +02:00
Simon Goldschmidt
0627c55c51 ping: fix assert in ping_init() 2023-10-04 21:36:00 +02:00
Simon Goldschmidt
732d3411bf fuzz: count packets for debugging 2023-10-03 21:37:14 +02:00
Simon Goldschmidt
9509acd876 fuzz: fix warning casting u64_t to s32_t/u32_t 2023-10-03 21:11:57 +02:00
Simon Goldschmidt
5fea01a0a8 msvc: add project + sln for fuzz tests 2023-10-03 21:11:26 +02:00
Simon Goldschmidt
f85ed72bac ipv6: frag: fix bogus icmp6 response on reassembly timeout
See bug #63929
2023-10-03 17:50:28 +02:00
Simon Goldschmidt
1ef6189287 pbuf: fix "returns" documentation on pbuf_get_contiguous()
See bug #64049
2023-10-03 17:34:53 +02:00
Simon Goldschmidt
ae5a5b99eb tcp: fix compiling with LWIP_NOASSERT
See bug #64734
2023-10-03 17:31:19 +02:00
Maxim Uvarov
de6b0a35f8 ping: do not clear IP address with ping_stop at the init
commit 4e6dd9 "ping: add stop function", was corrected
and wrongly added stop function after IP address set up.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
2023-10-03 17:15:56 +02:00
Yonggang Luo
dad8c4c72a guard when data is NULL
[build] ../../3rd/lwip/src/include/lwip/opt.h:137:41: error: argument 2 null where non-null expected [-Werror=nonnull]
[build]  #define MEMCPY(dst,src,len)             memcpy(dst,src,len)
[build]                                          ^~~~~~~~~~~~~~~~~~~
[build] ../../3rd/lwip/src/netif/ppp/fsm.c:791:7: note: in expansion of macro 'MEMCPY'
[build]        MEMCPY(outp + PPP_HDRLEN + HEADERLEN, data, datalen);
[build]        ^~~~~~
[build] In file included from c:\mentorgraphics\fly380s_8910\prebuilts\win32\gcc-arm-none-eabi\arm-none-eabi\include\sys\time.h:40:0,
[build]                  from ../../3rd/../src/cat1/arch/cc.h:40,
[build]                  from ../../3rd/lwip/src/include/lwip/arch.h:50,
[build]                  from ../../3rd/lwip/src/include/lwip/debug.h:40,
[build]                  from ../../3rd/lwip/src/include/lwip/opt.h:52,
[build]                  from ../../3rd/lwip/src/include/netif/ppp/ppp_opts.h:31,
[build]                  from ../../3rd/lwip/src/netif/ppp/fsm.c:43:
[build] c:\mentorgraphics\fly380s_8910\prebuilts\win32\gcc-arm-none-eabi\arm-none-eabi\include\string.h:31:8: note: in a call to function 'memcpy' declared here
[build]  _PTR   _EXFUN(memcpy,(_PTR __restrict, const _PTR __restrict, size_t));
[build]         ^
2023-09-29 22:21:02 +02:00
Simon Goldschmidt
14444c1c7f mqtt: support binary Will Message
see patch #10049
2023-09-29 22:08:03 +02:00
Simon Goldschmidt
2d6883c432 minor: fix spaces in unix/lib/lwipopts.h 2023-09-29 21:42:02 +02:00
Florian La Roche
0d5db9469e opt.h: Fix typo 2023-09-28 23:15:53 +02:00
Erik Ekman
339372919a mem: Include stdio.h
Memory overflow checks uses snprintf. Reported in bug #63904.
2023-09-28 23:04:37 +02:00
Erik Ekman
6f700a157d nd6: Fix RA link-local address option length check
Length field is in units of 8 bytes.
2023-09-28 22:39:14 +02:00
Simon Goldschmidt
2159f84682 httpd: compare client requests case-insensitive
Fixes bug #10047 (Fix case-sensitive comparison of Content-Length header for POST requests)

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2023-09-28 22:30:47 +02:00
Erik Ekman
7807f706f3 nd6: Update RA link-local addr option length check
lwIP might support different hardware address lengths (when using
Ethernet and 6LoWPAN for instance). Match provided lladdr length
from Router Advertisement to the current network interface instead
of comparing against longest that can be stored.
2023-09-28 22:23:25 +02:00
Erik Ekman
4f78da983f ci: Bump github action version
Fix warning:
"The following actions uses node12 which is deprecated and will be forced
to run on node16: actions/checkout@v2."
2023-09-28 21:06:09 +02:00
Simon Goldschmidt
d8b97bfc5d icmp: fix bug #64211 (ICMP reply error when using bridge)
when reusing an rx pbuf for tx, its if_idx has to be reset or else bridgeif_send_to_port() might drop it
2023-09-27 21:49:24 +02:00
Simon Goldschmidt
f7fe057821 win32 pcapif: fix "heap-use-after-free" on shutdown 2023-09-27 21:28:29 +02:00
Simon Goldschmidt
3792075baf Fix bug #64637 ("iperf -n 1000 -r" does not work) 2023-09-27 21:01:52 +02:00
Maxim Uvarov
4e6dd9c576 ping: add stop function
ping in raw mode does some set up and sets timeout, but clean
up procedure is missing. That is needed for case if PING_RESULT() macro
is used for application exit.

Also implement stop functionality when using sockets.
Running ping is stopped when calling ping_init() again.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2023-09-27 20:56:46 +02:00
Simon Goldschmidt
36cb95c4d2 next release will probably be 2.2.1... 2023-09-27 20:38:41 +02:00
Simon Goldschmidt
0a0452b2c3 Prepare 2.2.0 release 2023-09-25 21:25:35 +02:00
Simon Goldschmidt
c0cf130bb7 Prepare changelog for 2.2.0 release 2023-09-22 10:02:18 +02:00
Simon Goldschmidt
3eeda139bc minor coding style/spelling fixes 2023-09-22 09:54:36 +02:00
Simon Goldschmidt
b92faffaaa LWIP_VLAN_PCP==1: initialize tci correctly (disabled); add pcb_tci_*() functions to access the tci 2023-09-22 09:53:13 +02:00
Simon Goldschmidt
84fde1ebbf release: mark 2.2.0 RC1
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2023-06-29 22:22:19 +02:00
Simon Goldschmidt
2a3711a566 win32: check: adjust check config.h to run with newest check library on VS2022
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2023-06-29 22:14:36 +02:00
Simon Goldschmidt
1a5dffb931 win32: pcapif: ensure we can run with npcap as well
By default, npcap keeps its DLLs not in system32 but in system32/npcap.
To load DLLs from there, mark them as "delay load DLLs" and adjust the
DLL search path before using/loading them.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2023-06-29 22:11:55 +02:00
Simon Goldschmidt
bfcbf80221 win32: msvc: fix msvc project files to compile with VS2022; add test_tcp_state
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2023-06-29 22:08:45 +02:00
Simon Goldschmidt
657c9735a7 doxygen: dhcp: fix doxygen stumbling over nonexisting define 2023-06-29 21:59:05 +02:00
Simon Goldschmidt
9672405eb9 test: unit: tcp: fix tcp state tests to not break other tests
On platform where check cannot fork (win32), the tcp_state tests crashed other tests.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2023-06-29 21:32:20 +02:00
Shawn Silverman
e29870c15e Fix a printf conversion specifier in mdns.c
Use U32_F to print a u32_t.
2023-05-11 22:16:49 +02:00
Shawn Silverman
f84076b112 Add missing terminating newlines to LWIP_DEBUGF statements 2023-05-11 22:13:51 +02:00
Jonathan Neuschäfer
c2f9244137 test/fuzz: Fix use of htons vs. ntohs
Although ntohs and htons perform equivalent operations (a byte swap on
little-endian platforms), their semantic roles (as implied by the names)
are different.

In fuzz_common.c, we get integers from simulated network packages, and
convert them for host CPU use, so ntohs is the right variant to use.
2023-05-11 22:10:32 +02:00
Jonathan Neuschäfer
5514d8eb63 test/fuzz: Build with -O2 by default
Fuzzers should run fast by default, since the goal is to try many
variations of input data.
2023-05-11 22:08:46 +02:00
Jonathan Neuschäfer
911da26f96 test/fuzz: Fix CC default value in makefile
Unfortunately, CC ?= afl-gcc doesn't work. This is because CC has a
default value (of "cc"), and the ?= operator only assigns a value if the
variable previously had none. "make" currently compiles with cc.

In this patch, I implemented the more elaborate way to achieve what was
probably intended: "make" will use afl-gcc now, and "make CC=foo" will
compile with "foo".
2023-05-11 22:08:40 +02:00
Mingjie Shen
2e3dcf06d1 api,sockets: Fix signed overflow check
Signed overflow is undefined behaviour in C/C++.
2023-05-11 21:28:22 +02:00
Mingjie Shen
e3a20b3bc2 mdns: Add null check for pbuf_skip 2023-05-11 21:26:22 +02:00
Jan Breuer
1c5cc7bc02 snmp_v3: fix reported usmUserAuthProtocol for SHA 2023-05-11 21:05:16 +02:00
David Cermak
3aa82745c1 dhcp: Add macro for appending extra client's request options
Co-Authored-By: Liu Han <liuhan@espressif.com>
Co-Authored-By: Simon Goldschmidt <goldsimon@gmx.de>
2023-05-11 21:03:11 +02:00
Logan Gunthorpe
90b2a6b4c4 dhcp: Set hostname for DISCOVER packets
If the hostname is not set in the DISCOVER packet, then some servers might
issue an OFFER with hostname configured and consequently reject the REQUEST
with any other hostname.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Co-Authored-By: Simon Goldschmidt <goldsimon@gmx.de>
2023-05-11 20:59:15 +02:00
xueyunfei
5231c8da23 dhcp: Enable custom config for timeouts, thresholds, backoff time
Enables to configure:
* DHCP_COARSE_TIMER_SECS
* if DHCP_DEFINE_CUSTOM_TIMEOUTS defined these addtional options are
available:
  - DHCP_CALC_TIMEOUT_FROM_OFFERED_T0_LEASE to adjust the t0 lease timeout from the offered value
  - DHCP_CALC_TIMEOUT_FROM_OFFERED_T1_RENEW same for t1 renew
  - DHCP_CALC_TIMEOUT_FROM_OFFERED_T2_REBIND same for t2 rebind
  - DHCP_NEXT_TIMEOUT_THRESHOLD to adjust the period of the next timeout
  - DHCP_REQUEST_BACKOFF_SEQUENCE to adjust back-off times based on DHCP
request attempts
Also updates timeout type from u16 to u32 - eps useful when DHCP_COARSE_TIMER_SECS is a smaller number
2023-05-11 20:49:14 +02:00
David Cermak
00f5e179b5 dhcp: Move in-place timeout/threshold calculations to macros 2023-05-11 20:44:21 +02:00
Simon Goldschmidt
90c9a482a6 ci: fix compiling test_tcp_state.c; add to msvc project 2023-05-11 20:26:21 +02:00
David Cermak
724cc173ca ci: Add the default example_app config to the build step 2023-05-10 22:20:07 +02:00
David Cermak
187e4ededd contrib/addons: Add example of using DHCP extra options hooks 2023-05-10 22:16:57 +02:00
Chen Yu Dong
f50c87da6f ci: Add unit test suite to validate tcp state transitions 2023-05-10 22:02:43 +02:00
David Cermak
a6874a46c6 contrib/ports: Add semaphore per thread option for unix 2023-05-10 21:49:34 +02:00
Simon Goldschmidt
3a9c1e48dd altcp_tls_mbedtls: note which version of mbedtls we are compatible to
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2023-05-10 21:00:23 +02:00
Simon Goldschmidt
59ec032fa9 pppos: add new pppos unit test to vsproj 2023-05-10 20:59:36 +02:00
Simon Goldschmidt
64f75dbd89 pppos: fix compiling new pppos unit test
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2023-05-10 20:58:23 +02:00
Peter Putz
a9664395b0 pppos: fix in_tail null
happens during quick reconnect of LTE ppp session
2023-05-10 20:57:12 +02:00
David Cermak
6b734bbb2c PPP: Add test exhibiting empty packet null-deref
Also updates lcp.c to compile with PPP_AUTH_SUPPORT=0 in clang
2023-05-10 20:42:27 +02:00
Jonathan Neuschäfer
d8d1e4a015 altcp: Fix NULL pointer dereference found by fuzzing
Reproducer (in bash):

base64 -d <<< "H4sIAP/9L2QCA+3WoQ2AMBSE4QoCTFHBBJfgSRF4RDfpRmgmYBpGQRBCk4ZiSfk/+fJMK+5dZRVpzSQzSs6oPierDV4y87WxLQLwE42SfNCdDyHJB9/xZwAARPbMJbUq4JJmu4JVT1cAAACfbGIqoqcMzy90eu+aBw2+N28WFgAA" | gunzip | test/fuzz/lwip_fuzz2

Crash log:

../../src/core/altcp_tcp.c:178:13: runtime error: member access within null pointer of type 'struct tcp_pcb'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../../src/core/altcp_tcp.c:178:13 in
AddressSanitizer:DEADLYSIGNAL
=================================================================
==192415==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000048 (pc 0x557065081703 bp 0x0aae0cb71204 sp 0x7ffd034dabc0 T0)
==192415==The signal is caused by a READ memory access.
==192415==Hint: address points to the zero page.
    #0 0x557065081703 in altcp_tcp_setup_callbacks /.../lwip/test/fuzz/../../src/core/altcp_tcp.c:178:19
    #1 0x55706508206f in altcp_tcp_setup /.../lwip/test/fuzz/../../src/core/altcp_tcp.c:189:3
    #2 0x55706508206f in altcp_tcp_accept /.../lwip/test/fuzz/../../src/core/altcp_tcp.c:84:5
    #3 0x557065095592 in tcp_input /.../lwip/test/fuzz/../../src/core/tcp_in.c:380:9
    #4 0x5570650e752f in ip4_input /.../lwip/test/fuzz/../../src/core/ipv4/ip4.c:743:9
    #5 0x55706513d4de in ethernet_input /.../lwip/test/fuzz/../../src/netif/ethernet.c:186:9
    #6 0x557064fe0959 in input_pkt /.../lwip/test/fuzz/fuzz_common.c:209:9
    #7 0x557064fdeb6a in input_pkts /.../lwip/test/fuzz/fuzz_common.c:257:9
    #8 0x557064fdeb6a in lwip_fuzztest /.../lwip/test/fuzz/fuzz_common.c:669:3
    #9 0x7ff4f578e189 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #10 0x7ff4f578e244 in __libc_start_main csu/../csu/libc-start.c:381:3
    #11 0x557064f20420 in _start (/.../lwip/test/fuzz/lwip_fuzz2+0x81420) (BuildId: 8680a96430d5749c90111fe9c3a3d4f881a5dbcd)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /.../lwip/test/fuzz/../../src/core/altcp_tcp.c:178:19 in altcp_tcp_setup_callbacks
==192415==ABORTING
Aborted
2023-04-07 22:32:18 +02:00
Jonathan Neuschäfer
95a63bc352 test/fuzz: Use HTTPS URLs and mention AFL++ 2023-04-07 22:27:30 +02:00
Jonathan Neuschäfer
e8b0324f81 test/fuzz: Don't crash with assertion failure when a packet is too big
A fuzzer may generate big packets, and it will interpret assertion
failures as bugs. Instead of asserting that the packet size is
reasonable, simply skip the packet when it's not the case.
2023-04-07 22:25:50 +02:00
Renzo Davoli
0f2de1f684 contrib/ports/unix: add vdeif 2023-04-07 22:13:55 +02:00
Renzo Davoli
427b4f9b08 add posixlib 2023-04-07 22:11:27 +02:00
Renzo Davoli
6a350a0278 contrib/port/unix/lib: exclude slipif.c source 2023-04-07 22:07:17 +02:00
Simon Goldschmidt
3fe8d2fc43 get cmake to compile under windows with ms cl compiler
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2023-01-03 21:34:05 +01:00
Simon Goldschmidt
eaf4926239 UPGRADING: added a not about merging contrib 2022-12-22 22:07:16 +01:00
Simon Goldschmidt
e6341a6081 some documentation fixes after merging contrib and example apps
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2022-12-22 21:42:42 +01:00
Simon Goldschmidt
790b914fea pbuf_copy_partial_pbuf: fix warning about assigning to smaller type when using '-=' operator
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2022-12-22 20:43:18 +01:00
Steven Wartik
4b7a54c06c Added warning to cmake instructions when lwipcfg.h isn't present.
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2022-12-22 20:42:25 +01:00
yuanjm
239918ccc1 tcp: Make retransmission timeout (RTO) configurable 2022-05-09 21:24:57 +02:00
Erik Ekman
876517ea3e gitignore: *.exe moved to top level
Requested on lwip-devel list
2022-05-09 21:13:38 +02:00
Jonathan Demeyer
234d282936 mqtt: Fix typos on 'incomming' 2022-05-09 21:10:34 +02:00
Giuseppe Modugno
52b4649636 Replace C++ comment with standard C comment to avoid error during building with -Werror. 2022-05-09 21:07:14 +02:00
Simon Goldschmidt
124dc0a64e vscode: fix debugging on windows 2022-03-25 21:29:31 +01:00
Simon Goldschmidt
7807402899 cmake: fix building on windows with mingw64
- wpcap/packet libraries were wrong (.a, not .lib; not the x64 ones)
- link order resulted in undefined references

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2022-03-22 22:38:28 +01:00
Simon Goldschmidt
215dec653b fix some compile problems with mingw 2022-02-12 09:40:32 +01:00
Simon Goldschmidt
a55679224f fs: move prototypes required to implement custom files as fs addon to header 2022-02-12 09:40:32 +01:00
Florian La Roche
34e435c786 tapif: fix strncpy
Adjust the strncpy() call in tapif.c to how this is coded
in other strncpy() invocations. Also gcc warns about this.

See patch #10142
2021-12-30 22:58:52 +01:00
Florian La Roche
7c3aab2ea2 gcc warning for sign conversion
See patch #10143
2021-12-30 22:48:18 +01:00
Florian La Roche
62ac0faad8 redefine many vars as "static"
See patch #10156
2021-12-30 22:13:01 +01:00
Wouter van Gulik
5ab46f82f9 Fix failing fuzzer if compiling with ubsan
See patch #10163

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-12-30 22:04:23 +01:00
Simon Goldschmidt
7e96691ccf ignore LwipMibCompiler output files 2021-12-22 21:39:27 +01:00
weycen
9f7d9170c1 netif: fix the netif's index error
When using multiple netifs on one hardware interface (e.g. when mapping multiple IP addresses to one hardware interface), if the netif's low-level receive routine cannot decide for the correct netif, here the `netif` parameter may be a default netif, in this case, `p-> if_idx` will get a wrong netif index value. It should be placed after `netif = LWIP_ARP_FILTER_NETIF_FN(p, netif, lwip_htons(type));`.  Filter function can returns the correct netif before assigning `p-> if_idx`.
2021-12-07 00:57:48 +01:00
0x1abin
63d21c53e5 altcp mbedtls: Compile error fix. 2021-12-07 00:47:05 +01:00
Erik Ekman
562431b034 Update gitattributes after travis removal 2021-11-28 20:56:37 +01:00
Erik Ekman
ff28f73fa0 README: Update CI link 2021-11-27 21:09:06 +01:00
Erik Ekman
853258fff0 Switch from travis to github actions for CI
travis.org is no longer active
2021-11-27 20:48:02 +01:00
Erik Ekman
7c84799c4f doxygen: Remove obsolete config
warning: Tag 'PERL_PATH' at line 2212 of file '/home/runner/work/lwip/lwip/doc/doxygen/lwip.Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Tag 'MSCGEN_PATH' at line 2234 of file '/home/runner/work/lwip/lwip/doc/doxygen/lwip.Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
2021-11-27 20:40:54 +01:00
Erik Ekman
17413c28b4 httpd: Add documentation for http_set_cgi_handlers 2021-11-27 20:36:27 +01:00
Erik Ekman
5b9159ce0d api: Adapt doc comment to varying parameters 2021-11-27 20:32:59 +01:00
Erik Ekman
754d628f2d ip_addr: Add description for IP_ANY_TYPE 2021-11-27 20:32:59 +01:00
Erik Ekman
b0361f14c1 netif: Add documentation for mac filter macros 2021-11-27 20:17:30 +01:00
Erik Ekman
2711dbcac0 lwiperf: Complete documentation of lwiperf_report_fn
Doxygen did not like only annotating one parameter.
2021-11-27 20:17:30 +01:00
Erik Ekman
e594742801 altcp: Add doxygen comment for altcp_allocator_t 2021-11-27 20:17:30 +01:00
Erik Ekman
759c38b956 ip_addr: Add text descriptions for ip addr macros
Doxygen seems to ignore them otherwise.
2021-11-27 20:17:30 +01:00
Florian La Roche
089697bb1c Use NULL instead of 0 as a pointer
Recommended by 'sparse' tool
2021-11-27 15:49:20 +01:00
Erik Ekman
f3300731be example_app: Minor tweaks
- Make variables static
- Fix spelling
- Use NULL instead of 0 as a pointer
2021-11-26 22:41:06 +01:00
quanjia
553fedd443 ping: sizeof to struct not pointer 2021-11-25 00:14:59 +01:00
Florian La Roche
53c09fe921 tcp_out: move debug output to after checking pcb 2021-11-24 23:17:16 +01:00
Florian La Roche
3636b3e2d1 iteropts.sh: Fix warning on first run
Running iteropts.sh there is a warning on the first
cycle that lwipopts_test.h cannot be removed.
2021-11-24 23:04:57 +01:00
Florian La Roche
fdcfb9bdce contrib/ports: check library has moved to github 2021-11-24 22:52:18 +01:00
Bas Prins
a44fcb2e2e http_client: reset timeout when receiving data
This fixes downloads longer than 15 seconds.
See bug #60787 (http_client does not reset timeout counter)

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-11-12 23:11:22 +01:00
Simon Goldschmidt
a72fc743ef update tinydir.h to newest version
Update to cxong/tinydir commit 97a6032ddb ("Fix tinydir_file_open for root or subfolder of root in Linux.")

This should fix bug #61106 (compiling newest source fails with "-O3" optims)
2021-11-12 22:56:56 +01:00
Tom Collins
601e1bb326 altcp mbedtls: fix error in preprocessor logic setting ALTCP_MBEDTLS_PLATFORM_ALLOC
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-11-12 22:31:04 +01:00
Simon Goldschmidt
12506cda7d doc/FILES: remove outdated entries 2021-11-10 21:14:02 +01:00
Florian La Roche
e8741da9d2 contrib/ports: Remove redundant -Wredundant-decls 2021-10-03 12:45:51 +02:00
Simon Goldschmidt
39a9c5a3c5 netif: fix removing ext-callback while callback is called
When a registered netif ext-callback unregisters itself when being
called (e.g. because some state is reached by this event), the invoke
iteration might access uninitialized memory or at least stop the
iteration (because next is set to null).

Fix his by caching the next pointer during iteration before calling
callbacks.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-10-01 19:44:07 +02:00
Jannis Achstetter
7ec4e9be30 makefsdata: Support using the system's zlib instead of only minizip for deflate compression and note so in the readme
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-05-21 22:32:37 +02:00
Simon Goldschmidt
bb5ee3783a fix compiling/running tests on win32
- new files
- different warning settings
- all tests run in a single process (no fork)
2021-05-21 22:00:49 +02:00
Simon Goldschmidt
a8e8ce4108 dhcp: don't set a default gateway if dhcp server doesn't give one
see bug #60578
2021-05-14 10:32:57 +02:00
Axel Lin
919dc2019a acd: Fix updating prev pointer in acd_remove
Fixes: 3a788b6e8b4b ("dhcp: remove acd handle when stopping dhcp")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2021-05-14 13:48:43 +08:00
Eric Koldeweij
b538bff383 ip6: Fix crash in ip6_output with debug enabled
It turns out the crash only occurs if LWIP_DEBUG is enabled. If the
parameter dest is NULL the function tries to find a route using the
destination address of the packet instead. If this fails as well a
debug message is printed but it is still using dest causing a NULL
pointer dereference and crash at src/core/ipv6/ip6.c line 1312.

[erik@kryo.se: Apply fix to ip6_output_hinted as well]
2021-05-13 13:40:33 +02:00
Erik Ekman
b9056e148e acd: Fix LWIP_ASSERT argument order 2021-05-13 13:28:02 +02:00
Simon Goldschmidt
3a788b6e8b dhcp: remove acd handle when stopping dhcp
see bug #57706
2021-05-12 21:05:17 +02:00
Simon Goldschmidt
fa5ca55c9d pbuf_realloc: check that mem_trim does not move the memory
Our own implementation does not do this, but overridden implementations
calling 'realloc()' might invalidly do this
2021-05-12 21:05:17 +02:00
Erik Ekman
b0e347158d dhcp: Add missing newline to debug message 2021-03-25 20:56:21 +01:00
Simon Goldschmidt
0056522cc9 netdb: improve documentation of LWIP_DNS_API_HOSTENT_STORAGE 2021-03-05 13:04:59 +01:00
Simon Goldschmidt
8a900aa81f netdb: fix alignment warning in debug output
see bug #58650
2021-03-05 13:04:18 +01:00
Simon Goldschmidt
3ff267fbed dhcp: prevent dhcp_cleanup passing external data to heap 2021-03-04 22:20:17 +01:00
Simon Goldschmidt
c7e1b35899 dhcp: convert 'subnet_mask_given' to 'flags'
Don't waste 7 bits (in preparation for more flags)
2021-03-04 22:16:19 +01:00
Simon Goldschmidt
18b1178e0c makefsdata: add version info
This is required to make it possible to see you're using an old version if something doesn't work...
See task #15331
2021-03-04 21:51:06 +01:00
Simon Goldschmidt
f924c43621 doc: add description to get a release tgz from git 2021-03-04 21:46:58 +01:00
Harrold Spier
79c8a04152 SNMP netconn API should not check for core locked
See patch #9907
2021-03-04 21:29:20 +01:00
Hu Keping
ccea55370a Remove unnecessary files in release tarball
This patch adds a few entries in .gitattributes to specify files that
should never end up in a distribution tarball.

Signed-off-by: Hu Keping <hukeping@huawei.com>
2021-03-04 21:22:20 +01:00
Jeremy HU
4a169109a7 makefsdata: Fix flags missing
Fix the Perl script from which the generated fsdata.c cause runtime assertion: "HTTP headers not included in file system".
2021-03-04 21:16:48 +01:00
Oliver Hitz
b5176936c7 tcp: make tcp_listen() inherit the netbuf_idx of the original pcb
This simple patch causes tcp_listen() to inherit the netbuf_idx setting
of the original pcb. Without this, it is not possible to restrict a
socket to a specific interface using SO_BINDTODEVICE before listening.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-03-04 21:15:25 +01:00
Simon Goldschmidt
3666dcc66c tcp: send RST to input netif when no pcb is available
If we know there's no matchin pcb (e.g. for routing), don't even
try to pass NULL but instead send the RST to the input netif.

See also patch #9988.
2021-03-04 21:10:28 +01:00
Simon Goldschmidt
1f4a029d10 mqtt: check data_cb != NULL 2021-03-04 20:18:04 +01:00
Simon Goldschmidt
d7a0757764 mqtt: allow calling mqtt_set_inpub_callback before mqtt_client_connect
See also patch #10037
2021-03-04 20:14:46 +01:00
Christoffer Lind
600e248f06 dhcp: generate new xid for DHCP release 2021-03-02 22:49:57 +01:00
Erik Ekman
988ce1e80e netif: Add test for netif_find 2021-02-27 12:28:14 +01:00
Erik Ekman
e02d126b07 lowpan6: Use arch-independent printf formatters 2021-02-13 21:14:29 +01:00
Erik Ekman
74231d6873 netif: Add test for netif_is_flag_set() 2021-02-08 19:29:33 +01:00
Thomas Mueller
7a2923020f Fix typo in definition of netif_is_flag_set() macro 2021-02-08 19:17:20 +01:00
Simon Goldschmidt
12b45506dd fs_example: fix comment in fs_wait_read_custom
See bug #59866
2021-01-30 22:13:29 +01:00
Simon Goldschmidt
9aae444f49 pbuf_free: remove outdated comment about packet queues
See bug #59875
2021-01-30 22:08:36 +01:00
Simon Goldschmidt
3e098f90df pbuf: fix allocating large PBUF_RAM
See bug #59974
2021-01-30 22:06:46 +01:00
Mike Kleshov
6fee08daab httpd: revert part of previous change
pextension needs to be zeroed in case fs_file structure
is reused in a persistent HTTP connection
2021-01-29 08:02:56 +03:00
yuanjm
b00a05d086 lwip_selscan: lwip_selscan return -1 without setting errno number
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-01-28 21:00:37 +01:00
Simon Goldschmidt
fc5b6f7b0e lwiperf: fix double-free of pcb on error
See bug #59841 (PCB double-free happened at lwiperf TCP error)

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-01-28 20:00:11 +01:00
Mike Kleshov
9b040624c0 httpd: follow-up to previous commit
see bug #59876
2021-01-28 19:53:57 +03:00
Mike Kleshov
69725292a0 httpd: wrap fs_file::pextension in a config macro
see bug #59876
2021-01-28 08:29:25 +03:00
Mike Kleshov
89dca4588f httpd: follow-up to previous commit, replace strstr() with memcmp() 2021-01-27 19:28:19 +03:00
Mike Kleshov
fdd702e61b httpd: fix bug #58223 2021-01-26 19:19:32 +03:00
Mike Kleshov
1678b21a94 httpd: remove fs_file::is_custom_file, use fs_file::flags instead 2021-01-25 21:49:17 +03:00
Jacob Berg Potter
f7ff2d416c ports/freertos: add missing include of tcpip.h
To fix build (lock_tcpip_core is not defined otherwise)
2021-01-23 13:41:34 +01:00
Erik Ekman
651d0af0b6 netdb: Accept '0' as service in lwip_getaddrinfo
Fixes bug #59925
2021-01-22 20:20:51 +01:00
Erik Ekman
c825eb3604 tcp: Check tcp_output return values in tests
Found with clang-analyzer
2021-01-19 20:19:02 +01:00
Erik Ekman
21fba21054 test/unit: Update convenience makefile
Allow cleaning - useful when switching compiler between GCC/clang.
2021-01-19 20:19:02 +01:00
Erik Ekman
b5618c51ca altcp: Fix memory leak in altcp_tls_free_config
Reported in bug #59032 by Ondrej Lufinka,
fix suggested by David GIRAULT.
2021-01-13 22:19:47 +01:00
Erik Ekman
ecab77654a ports/unix/check: Ignore error from fail_* macros
Usage of fail_if/fail_unless macros with a message results in a
warning with the latest version of check (0.15.2+) and GCC.

Ignore this specific error (since warnings are treated as errors) for now.

Example failure:

In file included from ../../../../src/../test/unit/lwip_check.h:7,
                 from ../../../../src/../test/unit/lwip_unittests.c:1:
../../../../src/../test/unit/lwip_unittests.c: In function ‘lwip_check_ensure_no_alloc’:
../../../../src/../test/unit/lwip_unittests.c:55:7: error: too many arguments for format [-Werror=format-extra-args]
   55 |       "mem heap still has %d bytes allocated", lwip_stats.mem.used);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-01-13 21:48:03 +01:00
Erik Ekman
7b77378ed8 test/unit: Fix compilation of ip4 test
../../../../src/../test/unit/ip4/test_ip4.c: In function ‘test_ip4_icmp_replylen_short’:
../../../../src/../test/unit/ip4/test_ip4.c:291:35: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
   fail_unless(linkoutput_byte_ctr == icmp_len + sizeof(unknown_proto));

Plus minor cleanup in second icmp reply test
2021-01-13 21:31:19 +01:00
Erik Ekman
d0c214feff test/unit: Add convenience Makefile
To allow running them easily on *nix without changing directory.
2021-01-13 20:57:23 +01:00
Erik Ekman
35550eeab3 icmp: Fix copied length in response packets
Fixes bug #59364, reported by Yi Guai
2021-01-13 20:31:55 +01:00
Mike Kleshov
c6777547f6 Make sure tag insertion is complete when tag is followed by EOF.
See bug #59728.

Signed-off-by: Mike Kleshov <m.kleshov@gmail.com>
2021-01-01 11:26:30 +03:00
Erik Ekman
2d0c49adca Clean up COPYING
No need to have comment block.
2020-12-05 09:48:51 +01:00
Erik Ekman
d6a37b1ad6 fuzz: Improve Makefile
Similar to recent change to ports/unix/check:
- Split depfile into three different files
- Fix make dep
- Skip depfile generation for 'make clean'
2020-12-04 10:51:11 +01:00
Erik Ekman
45332ab38c ports/unix/check: Fix 'make dep'
It used to fail with this error after building the depfiles:

clang -DLWIP_NOASSERT_ON_ERROR -I/usr/include/check -I../../../../src/../test/unit -Wno-gnu-zero-variadic-macro-arguments -g -DLWIP_DEBUG -Wall -pedantic -Werror -Wparentheses -Wsequence-point -Wswitch-default -Wextra -Wundef -Wshadow -Wpointer-arith -Wcast-qual -Wc++-compat -Wwrite-strings -Wold-style-definition -Wcast-align -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Wunreachable-code -Wuninitialized -Wmissing-prototypes -Wredundant-decls -Waggregate-return -Wlogical-not-parentheses -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -Wdocumentation -Wno-documentation-deprecated-sync -I. -I../../.. -I../../../../src/include -I../../../ports/unix/port/include -c
clang-11: error: no input files

Also don't include depfiles while cleaning, to avoid generating them
just to remove them.
2020-12-03 21:55:45 +01:00
Erik Ekman
63fb3721ef ports/unix/check: Split depfiles for faster build
Having just one depfile (.depend) means it has to be fully regenerated
on every change, and it can't be done in parallel.

After this change the rebuild time after touching a single test file has
gone from 5.0 to 0.9 seconds. (make -j12)

Build of tests from clean has gone from 8.1 to 5.5s.

We could go even further and have one depfile per c-file, but this felt
like a simple first step giving a nice improvement.
2020-12-03 21:41:31 +01:00
Erik Ekman
c748395bda PPP: Change data argument in sio_write to const
To fix the build after ppp_output_cb started taking it as const in
commit b2d1fc119d50f0f9a9f2edb784577f9ad6585fbe.

Fixes this failure:
../contrib/examples/ppp/pppos_example.c: In function ‘ppp_output_cb’:
../contrib/examples/ppp/pppos_example.c:163:29: error: cast discards ‘const’ qualifier from pointer target type [-Werror=cast-qual]
   return sio_write(ppp_sio, (u8_t*)data, len);
                             ^
2020-12-03 09:47:00 +01:00
Sylvain Rochet
d1fc5c2ec4 PPP: add one more timer to PPP_NUM_TIMEOUTS_PER_PCB for late authentication
Authentication timer might still be running when entering network phase
for any necessary rechallenge, mostly for PPP server support.

Update the detailed analysis of simultaneously running PPP timers
taking into account the authentication timer that might still be
running and chose to increase the base number to 2 instead of
adding more unnecessary complexity.
2020-11-17 01:19:21 +01:00
Sylvain Rochet
9a9d92a59e PPP, PAP: cancel PAP timeout when authentication succeed or fail
upap_timeout is not currently stopped on authentication success or
fail events. This may have strange results if session is restarted
in a high pace because even if the timeout callback have a sanity
check against the PAP state the session can be restarted and be
back in the valid state before the timeout callback is actually
called.
2020-11-17 00:50:50 +01:00
Sylvain Rochet
3013e1fc19 PPP: remove unused ppp_pcb CHAP fields if server mode is disabled
pcb->settings.chap_timeout_time and pcb->settings.chap_max_transmits
are only used if server mode is enabled.
2020-11-17 00:26:32 +01:00
Sylvain Rochet
a4514cf416 PPP: fix unused parameter warning on prot_flavor if CHAP support is disabled
prot_flavor parameter is only used if CHAP support is enabled.
2020-11-16 22:26:00 +01:00
Sylvain Rochet
332119d7e0 PPP, magic: dot not assume LWIP_RAND will return 32 bits of randomness
Do not assume LWIP_RAND will return 32 bits of randomness because it is
probably going to be defined to directly return the rand() value. For
example, LCP magic numbers are 32-bit random values.
2020-10-27 21:52:18 +01:00
Sylvain Rochet
e239222775 PPP, magic: cleanup code and documentation
Documentation and simple code cleanup, no behavior change.
2020-10-27 21:47:26 +01:00
Sylvain Rochet
72d9132ecf PPP, PPPoL2TP: skip address & flags for PPP control packets
This is already what we inherently have always done for IPv4/IPv6
packets, so it works. Receivers must handle both cases anyway because
both behaviors are seen in the wild.
2020-10-23 17:34:25 +02:00
Sylvain Rochet
a494b990da PPP, PPPoS: drop in flight packets from the tcpip mailbox if PPP session is down
A previous call to ppp_input might have disconnected the session while
there were still packets in flight in the tcpip mailbox. Drop incoming
packets because ppp_input must never be called if the upper layer is
down.
2020-10-22 23:03:56 +02:00
Sylvain Rochet
a9f19cd7f1 PPP, PPPoS: only check open flag after events that may have changed it
Speed-up a little bit the PPPoS input parser by only checking the open
flag after calling the ppp_input function, the only one that can induce
a state change here.
2020-10-22 20:56:23 +02:00
Sylvain Rochet
22f13c24aa PPP: assert if ppp_set_* functions are called when session is not dead
ppp_set_* functions that set the PPP session parameters must only be
called when the session is in a dead state (i.e. disconnected),
otherwise not fatal but surprising results may happen.
2020-10-21 02:11:59 +02:00
Sylvain Rochet
dbb7c00aa5 PPP: add LWIP_ASSERT_CORE_LOCKED to ppp_set_notify_phase_callback
This function call the notify phase callback that should be called from
the lwIP core thread. This is especially true if the user callback
is not designed to be reentrant.
2020-10-21 01:43:57 +02:00
Freddie Chopin
c18a8dc9cc PPP, PPPoS: Remove useless cast from pppos_output_append() and pppos_output_last()
pppos_output_cb_fn() now takes `const void*`, so there is no need to
cast the payload (`void*`) to anything else.
2020-10-20 05:38:05 +02:00
Freddie Chopin
b2d1fc119d PPP, PPPoS: Use const void* instead of u8_t* in pppos_output_cb_fn()
There is no good reason why this function should take a non-const
pointer, as the output callback should never modify what lwIP gives it.
While changing that also switch to a more generic `void*` instead of
"byte".
2020-10-20 05:38:03 +02:00
Freddie Chopin
7f91a71eca Contrib, PPP: Remove trailing whitespaces in pppos_example.c 2020-10-20 05:30:59 +02:00
Freddie Chopin
34156e0594 PPP, PPPoS: Remove useless cast from pppos_input_sys()
pppos_input() now takes `const void*`, so there is no need to cast the
payload (`void*`) to anything else.
2020-10-20 05:30:21 +02:00
Freddie Chopin
5ad2f06333 PPP, PPPoS: Use const void* instead of u8_t* in pppos_input()
There is no good reason why this function should take a non-const
pointer. While changing that also switch to a more generic `void*`
instead of "byte".
2020-10-20 05:30:17 +02:00
Freddie Chopin
c5021bdc4d PPP, PPPoS: Use const void* instead of u8_t* in pppos_input_tcpip()
There is no good reason why this function should take a non-const
pointer. While changing that also switch to a more generic `void*`
instead of "byte".
2020-10-20 05:30:12 +02:00
Sylvain Rochet
3b57750715 PPP: remove LWIP_ASSERT_CORE_LOCKED on ppp_set_auth function
We do not have equivalents in PPPAPI for ppp_set_* functions because
calling them only makes sense while session is disconnected, furthermore
they are only setting structure members of the session configuration.
2020-10-20 04:15:25 +02:00
Sylvain Rochet
9b7cba9643 PPP: don't define PPP_IP if PPP_IPV4_SUPPORT is disabled
Doing so helps a lot at finding places where we have leftovers of IPv4
support when the support is disabled.
2020-10-20 03:59:34 +02:00
Sylvain Rochet
6584002826 PPP, PPPoS: only reserve header space for IPv4 and IPv6 packets if IP forwarding is enabled
We only have to reserve header space for forwarding for IPv4 and IPv6
packets, all other packets are PPP control packets. Doing so reduce
the need of having to coalesce the PBUF chain before PPP processes
control packets.
2020-10-20 03:53:07 +02:00
Sylvain Rochet
e801307738 PPP: set mtu6 too when setting PPP netif MTU
PPP peer can negotiate its MRU, therefore we don't know the MTU we are
going to use before starting PPP. This is an issue because netif_add
function assume that the netif init callback function will set the MTU,
netif_add will then copy mtu to mtu6. We have then to update mtu6 each
time we update mtu to keep them in sync. Doing so is fine because PPP
netif MTU is only updated when the netif is in link down state.
2020-10-20 02:53:46 +02:00
Sylvain Rochet
a39ce0f53b PPP, PPPoS: drop input packets much bigger than our MRU
Our current HDLC decoder does not protect against starving the Rx
PBUF POOL for one packet, most likely due to received garbage on
the serial port.

Prevent starving the Rx pool by checking incoming packets length
against PPP_MRU with a 10% margin because we only want to avoid
filling all PBUFs with garbage, we don't have to be pedantic.

Fixes bug #58441: Invalid PPP data accumulates forever.
2020-10-20 02:18:48 +02:00
Sylvain Rochet
51c6548631 PPP: allow negotiating MRU with PPP_MRU config option
PPP_MRU is now free to be used for what it should have been. Now using
it at PPP init stage to set the wanted MRU value, triggering a MRU
negotiation at the LCP phase.

I doubt anyone needs it anyway, but, well, at least it is fixed and the
MRU/MTU config mess is cleaned.

And while we are at it, better document PPP MRU config values.
2020-10-19 00:53:11 +02:00
Sylvain Rochet
90874392e3 PPP: force default MRU to 1500
RFC1661 mandates that default MRU value, that must be used prior
negotiation of MRU value and if MRU value is not negotiated later, must
be 1500.

That is, any PPP host must accept control frames of at least 1500 when
the PPP session start (there are no way to split them in multiples
frames anyway) and must use a value of 1500 if MRU is no negotiated
during LCP exchanges.

Therefore, having it configurable in ppp_opts is a mistake. It was wrong
and never worked because changing the value never triggered a MRU value
negotiation because it changed both the wanted MRU value and the RFC
default value to which the wanted value is compared to trigger a MRU
negotiation if values are not equal.
2020-10-18 23:54:48 +02:00
Sylvain Rochet
b8640678d6 PPP, LCP: merge PPP_MRU into PPP_DEFMRU
This is actually the same thing, both values are used interchangeably in
various places but their value must be the same.
2020-10-18 22:36:53 +02:00
Sylvain Rochet
331fe2dea2 PPP: rename netif_set/get_mtu to ppp_netif_set/get_mtu
Those are private functions, using the netif_ prefix here is not really
nice, especially with functions named netif_set_mtu and netif_get_mtu
for obvious reasons.
2020-10-18 22:11:18 +02:00
Sylvain Rochet
7633c24213 PPP, PPPoE, PPPoL2TP: remove persistent retries if sending packets fails
We currently retry indefinitely if sending packets fails, for example
if the output interface is down. We are even doing it if we are in
a middle of a connection process. This is not a very nice behavior
because PPP low level will retry indefinitely to connect and the user
application will never be warned that something is wrong.

We have the persist boolean in PPP settings to achieve more or less
the same thing anyway. Except it does it better at only retrying
indefinitely the initiation packet.
2020-10-18 17:10:13 +02:00
Sylvain Rochet
39cb84466d PPP: remove PPP_USE_PBUF_RAM configuration option
Having it configurable does not really make sense anymore, we already
need PBUF_RAM in all transmit paths. There are no real reason to keep
allocating PPP response buffers from the PBUF_POOL which should be now
reserved for receive paths only.
2020-10-18 16:44:23 +02:00
Sylvain Rochet
012fadd77f PPP: enable PPP_USE_PBUF_RAM by default
We need PBUF_RAM for quite a while for PPP, e.g. through pbuf_coalesce
and for all PPP transmit paths. There are no real reason to keep
allocating packets from PBUF_POOL for PPP control packets transmit path
by default today.
2020-10-18 02:34:43 +02:00
Sylvain Rochet
6b30cf62cc PPP, PPPoL2TP: fix displayed length in debug message
Packet length is p->tot_len here, not len.
2020-10-18 02:29:42 +02:00
Sylvain Rochet
5bf9cebb54 PPP: check that pbuf_coalesce succeed
When pbuf_coalesce fails it does nothing and returns the previous buffer
chain. Adds checks that pbuf_coalesce succeeded, otherwise drop incoming
packet.
2020-10-18 02:18:50 +02:00
Sylvain Rochet
7c0c3879b2 PPP, PPPoS: use PBUF_RAM in transmit pathway
Allocate Tx chunk in PBUF_RAM, using PBUF_POOL_BUFSIZE as a great
chosen value for chunk size.
2020-10-18 01:44:09 +02:00
Sylvain Rochet
3779cf7856 PPP, PPPoS: wait for next packet when we drop a packet before it is complete
If we fail to receive a full packet, for exemple if a memory allocation
fail for some reason, we currently do not wait for next packet flag
character and we start filling a new packet at next received byte. Then
we expect the checksum check to discard the packet.

The behavior seem to have been broken one or two decades ago when adding
support for PFC (Protocol-Field-Compression) and ACFC
(Address-and-Control-Field-Compression).

Rework to drop any character until we receive a flag character at init
and when we drop a packet before it is complete.
2020-10-17 20:09:35 +02:00
Sylvain Rochet
88ac7460f0 PPP: cleanup
Code cleaning only (misleading indents or comments, etc.), no behavior
change.
2020-10-17 17:53:04 +02:00
Sylvain Rochet
bedb4e4745 PPP: disable VJ support by default
VJ support is known to be broken when built with some compiler
optimizations enabled, disabling it by default until someone needs it
and fixes it.

It was mostly used with dial-up modems, it is useless with PPPoE and
PPPoL2TP and is probably useless as well with cellular modems, so
disabling it by default makes sense anyway.
2020-10-17 01:19:35 +02:00
Sylvain Rochet
729b3da96d PPP: remove casts from unsigned (strlen return value) to signed when checking auth
In theory, if provided username or password is over 0x80000000 byte long
(err...), casts to signed integer of strlen() return values is going to
return negative values breaking lengths checks.

Fix it by only using unsigned integer or size_t (guaranteed to be
unsigned) comparisons.
2020-10-16 21:16:05 +02:00
Sylvain Rochet
49bbc2d4bf PPP, PPPoE: prevent integer overflows when computing packets length
Check that service_name and concentrator_name strings length will not
trigger integer overflows when computing packets length.
2020-10-16 19:27:46 +02:00
Sylvain Rochet
678a7a4044 PPP, PPPoE: remove casts from unsigned (strlen return value) to signed
Those casts do not serve any purpose and can be safely removed.
2020-10-16 17:17:40 +02:00
Erik Ekman
c385f31076 Remove @ref to fix doxygen build
Generating docs for file src/incl/home/travis/build/lwip-tcpip/lwip/src/include/lwip/ip4_addr.h:151:s
error: unable to resolve reference to `ip4_addr_eq' for \ref command (warning treated as error, aborting now)
2020-07-07 18:59:50 +02:00
Erik Ekman
264a5a3e97 Rename IP and Ethernet equality checkers from _cmp to _eq
Functions ending in cmp are expected to return 0 on equality but these
return non-zero.

eth_addr_cmp -> eth_addr_eq

ip_addr_cmp -> ip_addr_eq
ip4_addr_cmp -> ip4_addr_eq
ip6_addr_cmp -> ip6_addr_eq

ip_addr_netcmp -> ip_addr_net_eq
ip4_addr_netcmp -> ip4_addr_net_eq
ip6_addr_netcmp -> ip6_addr_net_eq

ip_addr_cmp_zoneless -> ip_addr_zoneless_eq
ip6_addr_cmp_zoneless -> ip6_addr_zoneless_eq

ip6_addr_cmp_zone -> ip6_addr_zone_eq
ip6_addr_netcmp_zoneless -> ip6_addr_net_zoneless_eq
ip6_addr_nethostcmp -> ip6_addr_nethost_eq
ip6_addr_cmp_packed -> ip6_addr_packed_eq
ip6_addr_cmp_solicitednode -> ip6_addr_solicitednode_eq

All call sites have been changed, and fallback macros have been added to not
break external users.
2020-07-07 18:51:45 +02:00
Erik Ekman
047f3b3306 dns: Verify setting/getting servers in unit test 2020-07-04 18:57:41 +02:00
Erik Ekman
5b7524e10e unit: Enable DNS
Avoid allocating in dns_init by enabling random source port.
2020-07-04 14:24:40 +02:00
Erik Ekman
8363c24e45 zepif: Copy possibly chained output pbuf properly
Fixes bug #58554
2020-07-03 18:55:08 +02:00
Erik Ekman
2bf8fcd7c2 pbuf: Add pbuf_copy_partial_pbuf library function
Like pbuf_copy, but can copy part of a pbuf to an offset in another.
pbuf_copy now uses this function internally.

Replace pbuf_take_at loop in icmp6 with pbuf_copy_partial_pbuf().
2020-07-03 18:55:02 +02:00
Erik Ekman
942ca825d0 ip4: Fix missing END_TEST in ip4 test case 2020-07-01 21:09:49 +02:00
Erik Ekman
776e612872 Remove extra newlines in LWIP_ASSERT messages 2020-07-01 20:52:12 +02:00
Erik Ekman
ec5f3a1563 ip6: Add ipv6 fragmentation test
Seems to work the same as ipv4, and that I was just confused by all the
loops when reading the code.
2020-07-01 20:17:29 +02:00
Erik Ekman
0bda621d3d ip4: Verify ipv4 fragmentation sends all chunks right away
Ahead of investigation how ipv6 code behaves.
2020-07-01 20:16:24 +02:00
Erik Ekman
2faa2d7009 ip6: Rename pbuf in unit test
../../../../src/../test/unit/ip6/test_ip6.c: In function ‘test_ip6_dest_unreachable_chained_pbuf’:
../../../../src/../test/unit/ip6/test_ip6.c:314:16: error: ‘main’ is usually a function [-Werror=main]
   struct pbuf *main = pbuf_alloc(PBUF_RAW, sizeof(udp_hdr), PBUF_ROM);
                ^~~~
cc1: all warnings being treated as errors
2020-07-01 10:46:33 +02:00
Erik Ekman
8fe567b86f ip6: Fix incorrect assert in ip6_frag()
New test case now passes.

Fixes bug #57374 (Found by Hiromasa Ito).
2020-06-30 01:27:37 +02:00
Erik Ekman
e2ae25d158 ip6: Add test for fragmenting special packet
Reproduces bug #57374 (Found by Hiromasa Ito).
2020-06-30 01:27:32 +02:00
Erik Ekman
90b3e45c31 pbuf: Add pbuf_copy test operating on chained pbufs
With the payload lengths not matching between source and destination.

Also remove redundant allocation check in other test, it is now done
in the test setup code.
2020-06-29 19:45:18 +02:00
Erik Ekman
a49c347b7e pbuf: Update documentation for pbuf_copy
Remove detail from when the method was called pbuf_take
which worked on packet queues.
2020-06-25 10:04:43 +02:00
Erik Ekman
488d4ad246 icmp6: Don't copy too much data
Fix of the fix for bug #58553
2020-06-24 01:09:37 +02:00
Erik Ekman
bc1da0bddb pbuf: Remove redundant tests that pbufs are freed
Already checked by lwip_check_ensure_no_alloc() in teardown function.
2020-06-24 01:00:12 +02:00
Erik Ekman
489405839a icmp6: Fix copying of chained pbuf in reply
Fixes bug #58553, and the newly added unit test.

The pbuf_take_at loop should probably be made into a pbuf library
function, which would avoid this mistake in the future and provide
a simpler implementation of pbuf_copy.
2020-06-24 01:00:12 +02:00
Erik Ekman
dd913250a9 icmp6: add test case for returning copy of chained pbufs
Currently fails due to bug #58553
2020-06-24 01:00:12 +02:00
Erik Ekman
b58e0061e0 unit: Improve message when the mem heap has usage
Show "mem heap still has 216 bytes allocated"
instead of "Assertion 'lwip_stats.mem.used == 0' failed"
2020-06-24 01:00:02 +02:00
Erik Ekman
ff67ce6e07 unit: Improve message when a memp pool has entries
Show "memp pool 'PBUF_REF/ROM' still has 2 entries allocated"
instead of "Assertion 'lwip_stats.memp[i]->used == 0' failed"
2020-06-22 00:51:09 +02:00
Daniel Pauli
0b370fbade add API function mdns_resp_netif_active() that can be used to test if an MDNS responder is active for a given network interface.
Signed-off-by: Erik Ekman <erik@kryo.se>
2020-06-19 16:23:34 +02:00
Erik Ekman
e80d4ff2cc tcp: Fix double free in tcp_split_unsent_seg()
Fixes bug #57377 (found by Hiromasa Ito).
2020-06-19 15:39:15 +02:00
Erik Ekman
ea111c511e unit: Support check v0.13.0 and later
Function name no longer needs to be fed separately when adding tests.

Also fix collision of non-static net_test variables in dhcp and netif
tests.
2020-06-19 15:39:15 +02:00
Erik Ekman
9b1056ef0e fuzz: Fix compile error in simulated glibc rand
When using LWIP_RAND_FOR_FUZZ_SIMULATE_GLIBC:

fuzz_common.c: In function ‘lwip_fuzz_rand’:
fuzz_common.c:683:11: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Werror=sign-compare]
  683 |   if (idx >= sizeof(rand_nrs)/sizeof((rand_nrs)[0])) {
      |           ^~
cc1: all warnings being treated as errors
2020-06-19 13:26:58 +02:00
Erik Ekman
0ed8f754c5 Restore travis-ci link in README 2020-06-07 13:59:31 +02:00
Erik Ekman
897bcb7d4e Update README
Remove text about contrib as separate git repo
Remove link to old travis-ci setup
Update links to https
2020-06-06 18:49:08 +02:00
Sylvain Rochet
3f47b04f16 PPP: add FIXME about removing netif_set_up() call later
User application code should be responsible to call netif_set_up() but
let's not break compatibility for now.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2020-04-09 03:52:47 +02:00
Sylvain Rochet
c8fda8d46c PPP: use netif_set_up() instead of setting NETIF_FLAG_UP flag
NETIF_FLAG_UP flag is not supposed to be set by netif init callback
anymore, call netif_set_up() instead.

Sure it would be better to let user application code call netif_set_up()
by itself as it is now meant to be but let's not break compatibility for
now and add a FIXME for next release with allowed behavior break.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2020-04-09 03:45:44 +02:00
Sylvain Rochet
cfe5ce9d49 init: raise an error if PPP CCP_SUPPORT==1 but MPPE_SUPPORT==0
Building PPP CCP support without adding any compressor support serve
no real use case. Forbid doing so instead of bloating the code with
more ifdef.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2020-04-09 03:17:30 +02:00
Sylvain Rochet
cd140b1105 Revert "ppp: fix compiling with CCP_SUPPORT=1 but MPPE_SUPPORT=0"
This reverts commit 6e7ea92d56e43de65c46396b82ceebce2b95e8af.

We better forbid building configurations that does not make sense instead
of bloating the code with more ifdef. Here building CCP support without
adding any compressor support serve no real use case.
2020-04-09 03:05:30 +02:00
Hannes Gredler
f36e51e9c9 tcp_out: fix tcp_output_fill_options() arguments
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-04-02 20:15:58 +02:00
Simon Goldschmidt
003d34eebd tcp: fix sequence number comparison
This fixes both undefined behavior (see bug #51447) as well as a possible bug
where sequence numbers in 31 bit distance may come through.
2020-03-27 22:59:05 +01:00
Simon Goldschmidt
e30d50710d fuzz: allow overriding LWIP_RAND for fuzz tests
Fuzz tests need reproducible code, so we need an "unsafe" version of
LWIP_RAND() in this case...

Also, to reproduce fuzz tests cases from Linux on Windows,
LWIP_RAND_FOR_FUZZ_SIMULATE_GLIBC provides the first 20 random numbers that
glibc would have...
2020-03-27 22:42:06 +01:00
Simon Goldschmidt
003f5cc12d fuzz: whitespace fixes 2020-03-09 21:50:50 +01:00
Simon Goldschmidt
b795784832 fuzz: make CC overridable from 'afl-gcc'
e.g. for debugging crashes
2020-03-09 21:40:30 +01:00
Simon Goldschmidt
412c8d1902 fuzz: fix compiler error "missing prototype" 2020-03-08 20:41:53 +01:00
Simon Goldschmidt
34352e9649 altcp: mbedtls: no need for SYS_ARCH locking 2020-03-05 21:48:08 +01:00
Simon Goldschmidt
33f2b313c7 altcp: mbedtls: coding style fixes 2020-03-05 21:45:20 +01:00
Simon Goldschmidt
87618e2f2a Revert "altcp_tls_mbedtls: ensure configuration is properly freed"
This reverts commit d84a84e5ca8e8b4b86f2788d4ea77f41508c1a9a.

This commit seemed to be merged in an invalid order
2020-03-05 21:40:23 +01:00
Simon Goldschmidt
21cde5dc9e altcp: mbedtls: fix compiling altcp_mbedtls_lower_sent() 2020-03-05 21:36:59 +01:00
Simon Goldschmidt
74cd9a8644 ip4: add unit test for ip4addr_aton 2020-03-05 21:28:52 +01:00
Karol Domagalski
2e175a23cb ip4: ip4addr_aton: fix parsing of the octal IP representation 2020-03-05 21:27:59 +01:00
Simon Goldschmidt
adbc5b5f71 tcp: tighten up checks for received SYN
Any malicous segment could contain a SYN up to now (no check).
A SYN in the wrong segment could break OOSEQ queueing.
Fix this by allowing SYN only in states where it is required.

See bug #56397: Assert "tcp_receive: ooseq tcplen > rcv_wnd"

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-03-05 21:20:35 +01:00
Simon Goldschmidt
a02f34a193 fuzz: add pcap output to help debugging fuzz crashes 2020-03-05 21:00:00 +01:00
Simon Goldschmidt
a9052caf10 fuzz: add debug output to help debugging fuzz crashes 2020-03-05 20:49:41 +01:00
Harrold Spier
0192fe773e Fix allowing negative offset for snmp_pbuf_stream_seek()
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-21 17:28:33 +01:00
Simon Goldschmidt
349c077feb Fix last commit for all netif loopback traffic 2020-02-21 17:25:51 +01:00
Nick Ballhorn-Wagner
349ec76ee5 fix memory leak in netif_loop_output if tcpip_try_callback fails
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-21 17:17:08 +01:00
Simon Goldschmidt
d05be56a50 fuzz: add more fuzz tests
From: Hiromasa Ito <v3hertz@gmail.com>

See bugs #57374-#57380 found by this new test mode.
2020-02-20 21:55:13 +01:00
Simon Goldschmidt
a07e0a82c9 test: split fuzz into different files and binaries
This is in preparation to add more fuzzing code...
2020-02-17 22:05:46 +01:00
Simon Goldschmidt
fc85b055d7 sys: add the possibility to fuzz what sys_now() returns 2020-02-17 21:39:46 +01:00
Simon Goldschmidt
9b5a6fe1dc win32 port: fix LWIP_RAND() being called without sys_init()
This can happen in tests...
2020-02-17 21:28:04 +01:00
Simon Goldschmidt
04cf6bbe66 pcapif: add option PCAPIF_RX_READONLY to simulate readonly RX
This uses VirtualAlloc/VirtualProtect on windows to simulate RX buffers
that are readonly to lwIP (see task #14807).

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-16 20:43:33 +01:00
Simon Goldschmidt
ea9726056c and another codespell fix 2020-02-15 21:54:24 +01:00
Simon Goldschmidt
1ffcc5079c Fix-more-typos-using-codespell
Committing nearly all changes done by 'codespell_check.sh -w'

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-15 21:45:53 +01:00
jona
d6a6b661d9 Fix typos using codespell
Conservative strategy was used, maybe other typos remain.

Rebased: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-15 21:45:41 +01:00
Simon Goldschmidt
69c4c8a074 codespell: change file names, add possibility to write changes
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-15 21:45:22 +01:00
jona
8e0c6cd164 Add codespell wrappers : check.sh,changed_files.sh
Files adapted from the RIOT project : https://github.com/RIOT-OS/RIOT

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-15 21:44:49 +01:00
Simon Goldschmidt
6e7ea92d56 ppp: fix compiling with CCP_SUPPORT=1 but MPPE_SUPPORT=0
Even if that might not make much sense, it still shouldn't
result in compiler warnings.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-15 20:53:47 +01:00
Paul Mackerras
d281d3e959 PPP, EAP: ignore received EAP messages when not doing EAP
This adds some basic checks to the subroutines of eap_input to check
that we have requested or agreed to doing EAP authentication before
doing any processing on the received packet.  The motivation is to
make it harder for a malicious peer to disrupt the operation of pppd
by sending unsolicited EAP packets.  Note that eap_success() already
has a check that the EAP client state is reasonable, and does nothing
(apart from possibly printing a debug message) if not.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Sylvain Rochet <gradator@gradator.net> (ported to lwIP PPP pcb struct)
2020-02-10 23:37:33 +01:00
Paul Mackerras
2ee3cbe69c PPP, EAP: fix bounds check in EAP code
Given that we have just checked vallen < len, it can never be the case
that vallen >= len + sizeof(rhostname).  This fixes the check so we
actually avoid overflowing the rhostname array.

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Sylvain Rochet <gradator@gradator.net> (compiler warning fix about int vs uint comparisons)
2020-02-10 23:37:25 +01:00
Simon Goldschmidt
5e52d1a4b1 win32: fix 2 compiler warning nits in win32 port
Reported-by: Gisle Vanem <gisle.vanem@gmail.com>
2020-02-10 21:55:32 +01:00
Simon Goldschmidt
cc6d5b7a29 ppp: fix compiling eap after changing debug functions 2020-02-06 20:51:02 +01:00
Simon Goldschmidt
d843e47a1d icmp6: keep to the RFC and send as much as possible with icmp6 error messages
See bug 56013

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-05 20:43:25 +01:00
Simon Goldschmidt
4f30e0daff httpd: post example: fix typo in last version
See bug #57742

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-04 22:25:04 +01:00
Gao Qingshui
a9ac18aebb ip6: enable ip6_autoconfig_enabled by default
See bug #56135

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-04 22:23:58 +01:00
Simon Goldschmidt
3034e9fad0 httpd: post example: free pbuf in httpd_post_receive_data
See bug #57742

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-04 22:12:14 +01:00
Simon Goldschmidt
064d816ea1 altcp: fix altcp_tcp_close for LISTEN pcb
See bug #55219

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-03 22:13:07 +01:00
Simon Goldschmidt
84228d4f4b nd6: cache neighbour index for each next hop, not globally
See bug #47792

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-03 21:53:22 +01:00
Simon Goldschmidt
dc41eabf5f nd6: check defines for global tables for validity
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-03 21:49:57 +01:00
Simon Goldschmidt
b3046d938e nd6: use a pointer where appropriate to make the code more readable
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-03 21:33:21 +01:00
Simon Goldschmidt
177bb6ca06 nd6: update addr_hint only if the index has actually changed 2020-02-03 20:57:28 +01:00
Simon Goldschmidt
4c15191b1d snmp: update documentation 2020-02-03 20:35:22 +01:00
Simon Goldschmidt
5de4967f23 ip4: forward: try to fix the build...
... by adding a default case
2020-01-30 23:22:00 +01:00
Simon Goldschmidt
38894637e7 ip4: forward: remove invalid const modifiers
This should fix the build...
2020-01-30 23:13:07 +01:00
Simon Goldschmidt
61c67fc229 ip_forward: fix IPv4 forwarding with multiple netifs/offloading
When we have multiple netifs where at least one has checksum offloading
capabilities, IP forwarding needs to set various checksum fields to 0
to prevent HW algorithms on calculating an invalid checksum.

-> set checksum fields of IP/UDP/TCP/ICMP to 0 in ip4_forward().

See bug #56288

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-01-30 23:02:16 +01:00
Simon Goldschmidt
695c323164 icmp: add a dedicated struct for the standard ICMP header
This is just to keep the code clean and prevent using the "echo" header
where any ICMP header is meant.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-01-30 22:50:25 +01:00
Simon Goldschmidt
75b2db4438 makefsdata: error files must start with "<errnr>." to match HTTP status
This is to prevent files like "4001.jpg" getting HTTP status 400 instead
of 100.

See bug #56290.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-01-30 21:22:36 +01:00
Simon Goldschmidt
0f5bf0aa37 httpd: error files must start with "<errnr>." to match HTTP status
This is to prevent files like "4001.jpg" getting HTTP status 400 instead
of 100.

See bug #56290.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-01-30 21:22:03 +01:00
Patrick Schlangen
8d7e436a9d Fix select_waiting not being decremented for sockets closed while in lwip_select()
See bug #57445. Short version of the description there: lwip_select() failed
to decrement 'select_waiting' of a socket since that code part failed on
'free_pending' sockets. However, the code does not have to check that as it
has marked the socket to be in use itself earlier.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-01-30 21:04:37 +01:00
Simon Goldschmidt
32a72b1a20 sntp: ensure sntp_retry_timeout reaches the configured limit
See bug #57620

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-01-30 20:47:19 +01:00
Felix Werner
3b2d7e289a Additional Debug-Print in api_msg.c
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-01-30 20:43:56 +01:00
Simon Goldschmidt
a4b578b483 pbuf: avoid using multiple PBUF_POOL buffers for IPv6
Use 'PBUF_IP_HLEN+PBUF_TRANSPORT_HLEN' instead of '40' to calculate
PBUF_POOL_BUFSIZE (the size of each PBUF_POOL buffer) since the former
can be 60 when IPv6 is enabled.

See bug #56355

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-01-30 20:42:15 +01:00
Simon Goldschmidt
dae8eb8d6e adapt unit test to new netif ext callback reason 2020-01-13 19:37:59 +01:00
Simon Goldschmidt
d6b5b5222f opt: make LWIP_IPV6_SEND_ROUTER_SOLICIT default to LWIP_IPV6
This ensures struct netif doesn't contain 'rs_count' if LWIP_IPV6
is disabled but LWIP_IPV6_SEND_ROUTER_SOLICIT is at its default.

See bug #56509
2020-01-12 20:34:18 +01:00
Simon Goldschmidt
8a8058a436 netif: add IPV4_ADDR_VALID ext status callback reason
This ext-callback reason is always issued when an IPv4 config
has been set, even if it has not changed (e.g. DHCP reboot)

See bug #55121
2020-01-12 20:30:38 +01:00
Simon Goldschmidt
bb31fbd737 ip6: fix printing rx packet headers
The call to ip6_debug_print needs to be moved before the
next-header parsing code.

See bug #56708
2020-01-10 23:10:49 +01:00
Simon Goldschmidt
bf1285e3c9 ppp: don't link debug functions if disable
This converts all ppp_*() debug functions to ppp_*(()) macros that
ensure the code is left out by the linker if the corresponding debug
setting is disabled.

Downside is that many lines of code are touched, but since these
already differ to upstream PPP sources, I figured that's ok...

See bug #55199

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-01-10 21:42:45 +01:00
Simon Goldschmidt
827b60c155 debug: split debug enable checks from LWIP_DEBUGF to LWIP_DEBUG_ENABLED
In order to reuse the debug-enable checks for PPP debug macros,
move the flag and level checks from LWIP_DEBUGF to a new macro
that can be used elsewhere.
2020-01-10 20:50:25 +01:00
Simon Goldschmidt
b43f081b9a sockets: ioctl: fix _IO macros for 16 bit platforms
See bug #57565
2020-01-10 20:46:23 +01:00
David Girault
5c2887a241 sntp: remove existing timeout before creating new
This prevents sntp using more than 2 timeouts.
See bug #56431
2020-01-10 20:42:17 +01:00
Axel Lin
555812dcec netif_find: correctly check if atoi means '0' or error
Fixes: 4528215c99ba ("netif_find: check if atoi means '0' or error")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2019-12-12 09:23:11 +08:00
Simon Goldschmidt
f857260e29 fix compiling fuzz test under Linux after merging contrib to main repo 2019-12-11 22:20:14 +01:00
David Girault
2be031e238 altcp_tls: ensure no memory leaks and entropy counter is protected 2019-12-11 21:22:42 +01:00
David Girault
dc7ba26e69 altcp_tls: use ERR_CLSD only for handshake error
This allow better handling of handshake error in application.
2019-12-11 21:22:42 +01:00
David Girault
316dbc792f altcp_tls: call the application sent() callback with usefull len
First calculate and sum TLS overhead when altcp_mbedtls_write() is called.
Then take care of it when calling application sent callback. Give reveived
len from inner_conn, minus calculated overhead.
2019-12-11 21:22:41 +01:00
David Girault
f97dacd014 altcp_tls: support for saving/restoring session information
According to mbedTLS source code and documentation, calls to
`mbedtls_ssl_conf_session_cache` and `mbedtls_ssl_conf_session_tickets_cb`
are only available if mbedTLS is configured for server mode (ie. MBEDTLS_SSL_SRV_C
is defined). This cannot be used on client mode to resume a previous session.

To allow session reuse in client mode, application must save session parameters
(including tickets provided by the server if any) after successfull connection
and restore them before attemting to reconnect. Since `alctp_close()` free the
structure, it cannot be used to store the required information.

So, two new API were added, directly wrapped to mbedTLS functions, allow application
to do that by itself.

Also added full declaration of `struct altcp_tls_session` in altcp_tls.h to allow
easier usage in application when using mbedTLS port.
2019-12-11 21:22:41 +01:00
David Girault
d84a84e5ca altcp_tls_mbedtls: ensure configuration is properly freed 2019-12-11 21:22:41 +01:00
Simon Goldschmidt
44a3f631b3 inet: added missing IN6_IS_ADDR_* macros 2019-12-11 21:11:55 +01:00
Simon Goldschmidt
a9e73bc412 ip6addr_aton: support scoped address strings (via '%')
See task #15393

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:43:28 +01:00
Simon Goldschmidt
4528215c99 netif_find: check if atoi means '0' or error
Since atoi() returns 0 on error, we need to check if name[2] is '0'.
If it's not, atoi() failed.
2019-12-11 20:42:36 +01:00
Simon Goldschmidt
fbe032d05d mdns: fix clang warning about documentation error 2019-12-11 20:23:14 +01:00
David Girault
4baf17d5b2 mdns: restart probing when IP addresses has changed
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:13:10 +01:00
David Girault
4ca115a08e mdns: move MDNS_PROBE_DELAY_MS to mdns_opts.h to allow customisation
In some noisy WiFi environment, it may be necessary to increase this value to
300ms to accomodate WiFi latencies which may result in less than the required
250ms between two probe frames received by the Apple BCT application.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:13:10 +01:00
David Girault
2441c6fa3f mdns: abort packet analysis if conflict detected
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:13:10 +01:00
David Girault
6302423d7f mdns: handle tiebreaking loose like conflict
- Count tiebreaking loss in num_conflicts to include them in rate limit detection
- Restart probing using mdns_resp_restart allowing rate limiting for those cases

This ensure rate limiting is well activated during Apple Bonjour Conformance Tests.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:13:10 +01:00
David Girault
9301225895 mdns: support for multi-packet known answer (questions with TC bit)
This allow Apple Bonjour Conformance Test to not fail with the following tests:
- DISTRIBUTED DUPLICATE SUPPRESSION
- MULTIPLE QUESTIONS - DISTRIBUTED DUPLICATE SUPPRESSION

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:13:01 +01:00
David Girault
e85e473838 mdns: remove service TXT record from probe packets
TXT records isn't required to be unique in network, so it shouldn't be
included in probe packets.

Additionnaly, when TXT record is present, the Bonjour Conformance Test
from Apple Inc. always fail because generated probe nevert have TXT record.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:12:26 +01:00
David Girault
710b7fc158 mdns: add mdns_resp_restart_delay to allow re-probe delay selection
Called with `MDNS_INITIAL_PROBE_DELAY_MS` or `MDNS_PROBE_DELAY_MS` according to
needs.

When `mdns_resp_restart_delay()` called by `mdns_resp_rename_(netif|service)()`
functions, it is assumed this is because a conflict. So we should not use
`MDNS_INITIAL_PROBE_DELAY_MS` because the Bonjour Conformance Test will
complain like this:

```
START (PROBING)
NOTICE  16:40:09.501911: conflicting probe:
        smarTrEMotE-f8d0a4.Local.
ERROR   16:40:09.607288: Device did not provide a sufficient time gap between receiving a conflicting probe and reprobing.
ERROR   16:40:09.607333: expected_time_gap=237,actual_time_gap=105
```

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:12:04 +01:00
David Girault
cd278c426d mdns: remove duplicate acd_state_enum_t declaration
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:11:13 +01:00
David Girault
aa79b90d3c mdns: update probe conflict function to provide service in conflict
- Send service slot index to the mdns result function. In case of conflict, the user
  will have to remove the service or rename it.
- Break after hostname conflict in order to managed it first, and managed service name
  conflict after.
- Provide a function to get the TXT userdata for a service (allowing app to match with
  its own data).

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:11:13 +01:00
David Girault
a2498898b0 mdns: increase mDNS output packet size
When more than one service (just 2) need to be probed for conflict, generation
of the probe packet fail because pbuf is too small!

So OUTPACKET_SIZE renamed to MDNS_OUTPUT_PACKET_SIZE and moved to mdns_opts.h
to allow configuration. Default configuration raise it to 1450 to have enough
space when MDNS_MAX_SERVICES > 1 else it remain 512.

Extract from RFC 6762, chapter 17, Multicast DNS Message Size:

   The 1987 DNS specification [RFC1035] restricts DNS messages carried
   by UDP to no more than 512 bytes (not counting the IP or UDP
   headers).  For UDP packets carried over the wide-area Internet in
   1987, this was appropriate.  For link-local multicast packets on
   today's networks, there is no reason to retain this restriction.
   Given that the packets are by definition link-local, there are no
   Path MTU issues to consider.

   Multicast DNS messages carried by UDP may be up to the IP MTU of the
   physical interface, less the space required for the IP header (20
   bytes for IPv4; 40 bytes for IPv6) and the UDP header (8 bytes).

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:11:13 +01:00
Simon Goldschmidt
cb3f0a9b17 fuzz: adapt to changes in mdns
mdns_resp_add_netif() takes only 3 arguments
2019-12-11 19:50:50 +01:00
Simon Goldschmidt
0caacf82b4 netif_add: zero-init netif->acd_list 2019-12-11 19:49:50 +01:00
Simon Goldschmidt
e0be5a7f6d default_netif.c: add missing include
For sys_msleep(), we need to include sys.h
2019-12-11 19:49:26 +01:00
Joan Lledó
2b6d9a56f7 Contrib: Add kFreeBSD to the Unix port
* cc.h:
  * Identify kFreeBSD by macros
  * Use standard error codes for this OS

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-10 21:55:22 +01:00
Christoffer Lind
f47d2ed5fe sys_arch_mbox_tryfetch not validated correctly
sys_arch_mbox_tryfetch() shall return SYS_MBOX_EMPTY or 0 according
to the documentation. Wherever the function is used the return
value is incorrectly compared to SYS_ARCH_TIMEOUT. For now
SYS_MBOX_EMPTY is defined to SYS_ARCH_TIMEOUT so this is not an
issue as long as SYS_MBOX_EMPTY isn't re-defined.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-10 21:46:47 +01:00
Simon Goldschmidt
af0499131f autoip: fix typo
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-10 21:43:47 +01:00
David Girault
30d445bd39 acd: inform address is good only when going in ongoing state
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-10 21:37:03 +01:00
David Girault
05ffe144dd acd: reset conflict count to ensure fast re-probing after announcing
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-10 21:37:03 +01:00
David Girault
e09add37c1 acd: fix MAX_CONFLICTS check accorting RFC.
As written in RFC5227 in 2.1.1 Probe Details:

   A host implementing this specification MUST take precautions to limit
   the rate at which it probes for new candidate addresses: if the host
   experiences MAX_CONFLICTS or more address conflicts on a given
   interface, then the host MUST limit the rate at which it probes for
   new addresses on this interface to no more than one attempted new
   address per RATE_LIMIT_INTERVAL.

But `acd_restart` restart function check for `acd->num_conflicts > MAX_CONFLICTS`
which allow one more probe than expected.

So this commit change the test to `acd->num_conflicts >= MAX_CONFLICTS`.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-10 21:37:03 +01:00
Georgy Komarov
eaa8f34f6a lowpan6.c: fix unuinitialized variable if LWIP_6LOWPAN_IPHC==0 2019-12-10 21:19:53 +01:00
Simon Goldschmidt
fe25ca66af httpd: makefsdata: fix passing deflate level via commandline
See bug #57187

Reported-by: Anton Chasnyk <anton.chasnyk@gmail.com>
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-02 21:13:45 +01:00
Simon Goldschmidt
bef201e162 sockets: fix IS_SOCK_ADDR_ALIGNED() for 16 bit platforms
See bug 57344

Reported-by: Victor Brzeski <VBrzeski@gmail.com>
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-02 20:53:13 +01:00
Simon Goldschmidt
03998f5147 autoip: fix 'autoip_remove_struct()' after changing storage to 'netif_client_data'
Reported-by: Amena El Homsi <amena.elhomsi@gmail.com>
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-11-21 22:19:35 +01:00
Dirk Ziegelmeier
79cd89f99d Fix possible NULL pointer dereference in autoip_start()
autoip variable is dereferenced (autoip->state) before it is checked for NULL pointer
2019-08-28 07:24:31 +02:00
Joan Lledó
7fd158a109 Make socket functions depend on LWIP_SOCKETS
* Socket functions definitions moved out of the
  #define LWIP_SOCKET_EXTERNAL_HEADERS as all users who
  set LWIP_SOCKETS to 1 will need them regardless they use
  lwip's or external socket headers.
2019-08-16 10:59:31 +02:00
Joan Lledó
0aad45593f Unix port: sio module: memset struct sigaction to 0
* Use memset to set all struct sigaction fields to 0
  instead of doing it field by field, since fields
  depend on the architecture.
2019-08-16 10:57:35 +02:00
Joan Lledó
785b7aba3c Sockets: Unit tests and apps corrections
* Include lwip/inet.h in some unit tests and apps
  * Since they use htons() and pals.
* test/unit/api/test_sockets.c:
  * write() could be declared by external socket headers
    * Call lwip_write() instead.
  * Code expects fcntl() to return 6
    * But O_RDWR could have another value if external
      socket headers are present
    * Replace 6 by O_RDWR.
* apps/tftp/tftp.c:
  * recv() could be declared by external socket headers
    * Rename it to tftp_recv()
2019-08-11 20:12:47 +02:00
Joan Lledó
f92d6702bc Sockets: declare msghdr->msg_iovlen as msg_iovlen_t
* Lwip declares msghdr->msg_iovlen as int, but when
  using external socket headers, some systems declare
  msg_iovlen as size_t or others.
* This patch creates a new type msg_iovlen_t and
  expects users to typedef it to the type they need
  for their system.
2019-08-11 20:12:02 +02:00
Simon Goldschmidt
c4f33be3f3 fix compiling last commit (save before committing...) 2019-08-06 22:34:17 +02:00
Simon Goldschmidt
19e22f870f add https example 2019-08-06 22:17:55 +02:00
Joan Lledó
2f5305c259 Unix port: improve support for the Hurd
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-08-01 21:10:36 +02:00
Simon Goldschmidt
602a66fe58 sockets: convert _HAVE_SA_LEN to lwip style 2019-08-01 21:04:06 +02:00
Joan Lledó
f126750ccd Add support for struct sockaddr with no sa_len field.
Lwip's struct sockaddr includes sa_len, but some systems
like Linux doesn't have this filed, which produces many
compilation problems when using external headers.

A set of macros has benn added to detect the absence of
sa_len and adapt sockets.c
2019-08-01 20:49:54 +02:00
Simon Goldschmidt
c53a8444e8 dhcp: don't use LWIP_ERROR in dhcp_parse_reply()
See bug #56643

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-07-26 20:43:08 +02:00
Simon Goldschmidt
6b3ed88d9c ALTCP_TLS_MBEDTLS: include mbedtls/net_sockets.h instead of deprecated mbedtls/net.h
See patch #9815

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-07-26 20:29:27 +02:00
Joan Lledó
fa6f8054eb Move LWIP_MARK_TCPIP_THREAD to include/lwip/sys.h
* LWIP_MARK_TCPIP_THREAD moved to include/lwip/sys.h
* Unix port macro definitions moved to sys_arch.h
  * LWIP_MARK_TCPIP_THREAD
  * LOCK_TCPIP_CORE
  * UNLOCK_TCPIP_CORE

(goldsimon@gmx.de: fixed unix Makefile build and win32 build)
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-07-26 20:09:40 +02:00
Freddie Chopin
8291ff3dc0 Fix definition of LWIP_NUM_SYS_TIMEOUT_INTERNAL
In timeouts.c commit 7d1c26cc0c18d02cc72f348f9189dd1c3a06bfca replaced
timeout for AUTOIP with a timeout for ACD, however the value of
LWIP_NUM_SYS_TIMEOUT_INTERNAL was not updated and still counts
LWIP_AUTOIP instead of LWIP_ACD. If user has AUTOIP disabled (or not
explicitly enabled) and DHCP enabled, then ACD gets automatically
enabled too. In this case there will be one timeout too little for lwIP
and first TCP packet received causes an assertion.

Also add LWIP_IPV6_DHCP6 to the value of LWIP_NUM_SYS_TIMEOUT_INTERNAL,
as it was also not accounted for.
2019-07-26 19:44:35 +02:00
Joan Lledó
9dca4a0211 New function tcpip_callback_wait() * Call a function inside the tcpip thread and block the calling thread until the callback finishes.
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-07-13 20:52:48 +02:00
Joan Lledó
3546a0a4a0 IF_NAMESIZE: define it only if it's not defined before by system headers 2019-07-13 20:49:48 +02:00
Simon Goldschmidt
5465fdfd69 netconn: add callback arg storage
This reuses the member 'int socket' by making it a union containing
both int and void pointer.

See bug #56593.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
Suggested-by: Wilfred <wilfrednilsen@hotmail.com>
2019-07-13 20:46:36 +02:00
Simon Goldschmidt
f37925dad2 api_lib: fix duplicate NULL check with sys_sem_valid() 2019-07-10 21:55:28 +02:00
Simon Goldschmidt
2ebebe7287 fix compiling unit tests after adding compile-time check for LWIP_NETCONN_FULLDUPLEX 2019-07-10 21:29:13 +02:00
Simon Goldschmidt
aa545fbbc6 LWIP_NETCONN_FULLDUPLEX is not alpha any more 2019-07-10 21:14:35 +02:00
Giuseppe Modugno
832490eec8 Added the configuration option ALTCP_MBEDTLS_AUTHMODE to set the certificate verification mode.
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-06-11 21:15:45 +02:00
Giuseppe Modugno
edeeef0d20 mqtt: fix ping request coming too late
See bug #56022 and patch #9813

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-06-11 21:13:05 +02:00
Axel Lin
b3a939417e sockets: Get rid of sock_set_errno
The err field is removed from struct lwip_sock since commit e0a2472706ee
("netconn/sockets: remove fatal error handling, fix asynchronous error handling, ensure data before RST can be received")
sock_set_errno() simply calls set_errno() now, so use set_errno() instead.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Dirk Ziegelmeier <dziegelmeier@de.pepperl-fuchs.com>
2019-05-06 19:47:56 +08:00
Dirk Ziegelmeier
0255106d55 Fix bug #56136: The netif->mtu6 was updated by Router Advertisement abnomally
Using patch from Gao Quingahui plus improvement
2019-05-06 12:37:19 +02:00
Our Air Quality
ff17530997 mdns mdns_search_service mdns_search_stop: define the request id as unsigned. 2019-04-30 14:53:58 +02:00
Dirk Ziegelmeier
3d7ff53070 Apply patch for bug #56098: Support for MQTT over TLS port 443 instead of 8883 2019-04-30 13:22:09 +02:00
Dirk Ziegelmeier
295996f912 Apply patch for bug #56239: compile fail when disable TCP 2019-04-30 13:16:30 +02:00
Dirk Ziegelmeier
534d3a794c Minor compile fix for last commit 2019-04-30 13:05:50 +02:00
David Girault
fc8f6e8fd9 mqtt: fix first packet checking which fail if MQTT_VAR_HEADER_BUFFER_LEN > 1516
If client reception buffer is bigger than the first frame we receive, the first packet test
will always fail for the second one if it is shorter the the diffence between reception
buffer size and first frame length.

For example, if we receive a PUBLISH message with length = 1517 (payload len = 1514 +
header len = 3), this result in total message length of 1517.

altcp_tls will send MQTT client frame up to 1516 bytes max. This result to PUBLISH
message splitted in two frame: first is 1516 bytes, the second of 1 bytes.

If MQTT_VAR_HEADER_BUFFER_LEN is 1520 (1516 + 4 bytes for stored fixed header), the
second frame of 1 bytes is considered as first publish frame because
client->msg_idx (1517) < MQTT_VAR_HEADER_BUFFER_LEN (1520).

This result in disconnection AND application callback never called for the end of the
payload.

The fix will check `(client->msg_idx - (fixed_hdr_len + length)) == 0` which can be
only true for the first frame of a message.

Below logs showing the bug:
```
April 3rd 2019, 23:14:05.459    lwip_dbg    mqtt_parse_incoming: Remaining length after fixed header: 1514
April 3rd 2019, 23:14:05.460    lwip_dbg    mqtt_parse_incoming: msg_idx: 1516, cpy_len: 1513, remaining 1
April 3rd 2019, 23:14:05.460    lwip_dbg    mqtt_incomming_publish: Received message with QoS 1 at topic: v2/inte...
April 3rd 2019, 23:14:05.461    lwip_dbg    mqtt_parse_incoming: Remaining length after fixed header: 1514
April 3rd 2019, 23:14:05.461    lwip_dbg    mqtt_parse_incoming: msg_idx: 1517, cpy_len: 1, remaining 0
April 3rd 2019, 23:14:05.461    lwip_dbg    mqtt_message_received: Received short PUBLISH packet
```
2019-04-30 12:57:48 +02:00
David Girault
df0699c143 mqtt: support mostly zero-copy message analysis
also ensure no parts of message are lost because cpy_len != buffer_space!
2019-04-30 12:57:40 +02:00
Our Air Quality
156bb74d17 mdns_resp_add_service: simplify the max services guard. 2019-04-30 12:41:19 +02:00
Our Air Quality
224b884c1e mDNS: output search queries to the IP v4 and v6 groups.
These had been broadcasting to the *_ANY addresses.
2019-04-30 12:38:07 +02:00
Our Air Quality
c156cd2a33 ND6: add an explicit queue size check.
When using the MEMP_MEM_MALLOC option, memp_malloc() can not be relied on to
limit the number of allocations allowed for each MEMP queue, as the ND6 code
had been. This caused the ND6 queue to keep growing until the heap allocation
failed when using the MEMP_MEM_MALLOC option. So add an explicit queue size
check in ND6.
2019-04-30 12:34:43 +02:00
Our Air Quality
46bbfe4ee2 mdns: defined the service slot id as unsigned rather than signed. 2019-04-30 12:33:22 +02:00
Our Air Quality
2229c51704 mdns_search_service: simply the search for a free slot. 2019-04-30 12:29:43 +02:00
Our Air Quality
af5906370f mDNS: change some debug line terminations to just newlines.
Some of there were using carriage-return and newline, yet the
rest of the code base consistently uses only newline.
2019-04-30 12:29:08 +02:00
Freddie Chopin
ec11b289cb Fix and simplify newlines in doxygen documentation
Replace '\n' with '<br>', as this allows doxygen to understand reference
names followed by newline. For some cases just drop the newline if it's
not required.

Doxygen 1.8.15 doesn't like if the name of reference is followed by
anything else than (selected?) punctuation or whitespace.

bug #56004
2019-03-28 08:18:20 +01:00
Freddie Chopin
c594599350 Fix doxygen @ref in altcp.c
Doxygen 1.8.15 doesn't like if the name of reference is followed by
anything else than (selected?) punctuation or whitespace.

bug #56004
2019-03-28 08:18:19 +01:00
Dirk Ziegelmeier
53818ad3e4 Add #define for minimum IPv6 MTU length 2019-03-28 08:16:47 +01:00
Dirk Ziegelmeier
bda6909df8 Fix bug #56003: -Wc++-compat causes build failure when using mbedtls
Build without -Wc++-compat when MBEDTLS is included in project
Works around problem in MBEDTLS headers
2019-03-26 20:11:37 +01:00
Dirk Ziegelmeier
ecd8c5b936 Fix bug #55702: SSI bug
Apply patch from Stanislav
2019-03-24 21:47:56 +01:00
Dirk Ziegelmeier
d0d86b5ba1 Fix compile of last patch 2019-03-24 21:46:43 +01:00
Dirk Ziegelmeier
aa7009b2fc Fix bug #55972: The Neighbour Solicitation used to do IPv6 address resolution was wrong
Apply patch from Gao Qingshui
2019-03-24 21:34:08 +01:00
Dirk Ziegelmeier
4f6fd6c845 Fix bug #55973: The parsing of max response time in MLD Query message was wrong
Apply patch from Gao Qingshui
2019-03-24 21:32:26 +01:00
Dirk Ziegelmeier
ff93961ff4 Update .gitignore for latest VSCode 2019-03-20 20:50:35 +01:00
Dirk Ziegelmeier
4b10b4dab3 Add note about MEMP_NUM_SYS_TIMEOUT in four apps 2019-03-20 20:50:17 +01:00
Dirk Ziegelmeier
a329bdd607 Fix bug #55964: CMake's LWIP_COMPILER_FLAGS should be split for C and C++
CMakeCommon.cmake: Use conditional for flags that only make sense for C code
2019-03-20 11:20:35 +01:00
Simon Goldschmidt
3b5eb7ca90 udp_bind: fix missing parenthesis warning
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-02-27 10:29:55 +01:00
Simon Goldschmidt
752cdb1a53 udp: fix udp_bind for IPADDR_TYPE_ANY
See bug #55171

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-02-26 14:48:44 +01:00
Dirk Ziegelmeier
e479bd56df Fix LWIP_ERROR macro - it should never be fatal (LWIP_ASSERT)
The only difference should be:
- LWIP_DEBUG enabled  -> print a diag message
- LWIP_DEBUG disabled -> NO diag message is printed
2019-02-08 12:29:05 +01:00
Dirk Ziegelmeier
049cae841d More cleanups to travis.sh - run all test even if some fail
Try to get maximum on information in one build run
2019-02-03 09:36:44 +01:00
Dirk Ziegelmeier
a7b06bef5f Fix iteropts.sh to correctly return error code 2019-02-03 09:31:26 +01:00
Dirk Ziegelmeier
32bc761245 iteropts.sh: -j 4 is sufficient 2019-02-03 09:09:50 +01:00
Dirk Ziegelmeier
8a08c4cd4f Cleanup travis build script 2019-02-03 09:03:22 +01:00
Dirk Ziegelmeier
71f56714dd Remove iteropts test errors again, still not working 2019-02-02 23:17:39 +01:00
Dirk Ziegelmeier
95dbe78821 Add bug to iteropts test to check if travis fails now 2019-02-02 23:10:31 +01:00
Dirk Ziegelmeier
c03e949ca9 Try to fix iteropts build, try to make travis fail when iteropts test fails 2019-02-02 23:04:52 +01:00
Dirk Ziegelmeier
3f4e183e3f Disable documentation warning in iteropts test
Fails because some functions have different parameter lists depending on lwIP options (e.g. netif_add())
2019-02-02 22:59:54 +01:00
Dirk Ziegelmeier
78a0a62484 Add missing newline at end of file 2019-02-02 22:58:53 +01:00
Dirk Ziegelmeier
27c226b5d6 Fix a few documentation errors in MDNS 2019-02-02 22:44:57 +01:00
Dirk Ziegelmeier
dc607c5be4 Fix lwip_port_rand()
(Didn't stash again after last change)
2019-02-02 22:38:49 +01:00
Dirk Ziegelmeier
aa4668cc47 Add lwip_port_rand() to unix port 2019-02-02 22:37:18 +01:00
Simon Goldschmidt
cbc80a0920 revert accidentally committed files 2019-01-30 21:14:01 +01:00
Solganik Alexander
b1d3dcb8d7 tcp: don't reset dupack count upon non-empty packet receive
According to rfc5681:

https://tools.ietf.org/html/rfc5681

Paragraph 3.2.  Fast Retransmit/Fast Recovery
The TCP sender SHOULD use the "fast retransmit" algorithm to detect
and repair loss, based on incoming duplicate ACKs.  The fast
retransmit algorithm uses the arrival of 3 duplicate ACKs (as defined
in section 2, without any intervening ACKs which move SND.UNA) as an
indication that a segment has been lost.  After receiving 3 duplicate
ACKs, TCP performs a retransmission of what appears to be the missing
segment, without waiting for the retransmission timer to expire.

Now consider the following scenario:
Server sends packets to client P0, P1, P2 .. PK.
Client sends packets to server P`0 P`1 ... P`k.

I.e. it is a pipelined conversation. Now lets assume that P1 is lost, Client will
send an empty "duplicate" ack upon receive of P2, P3... In addition client will
also send a new packet with "Client Data", P`0 P`1 .. e.t.c. according to sever receive
window and client congestion window.

Current implementation resets "duplicate" ack count upon receive of packets from client
that holds new data. This in turn prevents server from fast recovery upon 3-duplicate acks
receive.
This is not required as in this case "sender unacknowledged window" is not moving.

Signed-off-by: Solganik Alexander <sashas@lightbitslabs.com>
2019-01-30 21:13:22 +01:00
Simon Goldschmidt
5666f305ce sntp: obey KoD when using multiple servers
See bug #55253 (SNTP retry next server instantly result as a flood of NTP request).
Added 'sntp_getkodreceived()' to check the status.
2019-01-30 20:42:56 +01:00
Simon Goldschmidt
8e86555f93 mdns: fix compiler errors and coding style 2019-01-30 20:15:26 +01:00
David Girault
b4be0d8808 mdns: added support for searching services
Two new API:
err_t mdns_search_service(const char *name, const char *service, enum mdns_sd_proto proto,
                          struct netif *netif, search_result_fn_t result_fn, void *arg,
                          s8_t *request_id);
void mdns_search_stop(s8_t request_id);

One compilation flags:
LWIP_MDNS_SEARCH

One options flags:
MDNS_MAX_REQUESTS

Some structure declarations moved to allow use by callback result function.

Result domain names are early uncompress before calling application callback
because it cannot be made by application itself.

Allow search services with multiples labels included, like '_services._dns-sd'.

Search for `_services._dns-sd._udp.local.` is handled in a special way.
Only `PTR` answers are send back to the application.

The `mdns_search_service()` function won't assert if no more space in `mdns_request`
table, just return an error if too many simultanous requests.
2019-01-30 20:05:51 +01:00
Ivan Warren
9263d44847 Small documentation fix for TFTP
Apparently the TFTP server now also invokes the error() function in the
tftp_context struct.

Some tftp clients (for example Windows 10 TFTP client) will open the
remote file before checking the local file can be opened - and will then
send an error indication to the server to indicate there was an error
opening the local file. When the happens, the LWIP tftp server will
invoke the error() member of the tftp_context.
2019-01-30 19:56:49 +01:00
David J. Fiddes
8f2f43f093 Implement RFC4075 Receive SNTP servers via DHCPv6
This adds support for RFC4075 SNTP server configuration via DHCPv6.
The DHCPv6 options transmitted are now conditional on how LwIP is
configured.

A new SNTP application option SNTP_GET_SERVERS_FROM_DHCPV6 is used
to enable. For simplicity this is configured to use the global
LWIP_DHCP6_GET_NTP_SRV configuration setting.

Tests:
 - Check the global options now control the DHCPv6 request sent
   in Wireshark
 - Check against 0, 1 and 3 SNTP servers configured on an odhcpd
   server configured to support RFC 4075 SNTP server lists.
   Verify that the SNTP server list is updated on connection
   establishment on an ESP8266 WeMOS D1.
 - Verify that SNTP packets are sent and recieved from a
   configured server and that system time is updated.

Signed-off-by: David J. Fiddes <D.J@fiddes.net>
2019-01-30 17:49:18 +01:00
David Girault
3cb6ae7770 altcp_tls: assert in altcp_mbedtls_bio_recv if bad state 2019-01-30 17:42:52 +01:00
David Girault
b04d8a6a6c altcp: support for setting keepalive parameters 2019-01-30 17:42:46 +01:00
David Girault
b298afabdc altcp_tls_mbedtls: remove entropy/ctr_drbg from altcp_tls_config struct
Use only one entropy/ctr_drbg context for all altcp_tls_config structure allocated.

(Small adjustments before committing: fix coding style, adapt to changes in master)
2019-01-30 17:42:39 +01:00
Simon Goldschmidt
2037ec371c test: fix compiling unit test on win32 2019-01-30 14:53:41 +01:00
David Girault
2cc420e434 mqtt: remove bad assert in mqtt_message_received()
- client->msg_idx can be > MQTT_VAR_HEADER_BUFFER_LEN in long message splitted in multiple pbufs
- renamed fixed_hdr_idx to fixed_hdr_len because it is length of fixed header in rx_buffer, not an index to it
- removed the cpy_start as data always copied right after the fixed header
2019-01-30 14:29:21 +01:00
Simon Goldschmidt
ed561a578b tcp: improve debug message a little 2019-01-30 14:27:16 +01:00
Simon Goldschmidt
3e59b224fa tcpecho_raw: fix bogus pbuf_free on error 2019-01-30 14:20:16 +01:00
Dirk Ziegelmeier
4c19a909c2 Fix bug #55537: Crash in SYN_SENT state when TCP_INPUT_DEBUG logs are ON 2019-01-28 14:21:34 +01:00
Dirk Ziegelmeier
941300c21c Apply patch #9737: Fix DHCPv6 DNS server assignment 2019-01-28 14:19:15 +01:00
Dirk Ziegelmeier
3efc43531b Fix bug #55536: lwIP 2.1.2: netconn_delete() called twice from lwip_accept()
netconn is deleted in free_socket() call
2019-01-28 14:13:52 +01:00
Dirk Ziegelmeier
a215eba50e Add documentation on how to debug memory pool sizes 2019-01-28 14:05:05 +01:00
Dirk Ziegelmeier
8bf2e21b4d TCP/UDP documentation: Add reference to PCB mempool #defines 2019-01-28 13:47:03 +01:00
Dirk Ziegelmeier
926e399355 Fix bug #55513: Uninitialized variable in struct netconn
using patch from Karol Domagalski
2019-01-18 20:51:58 +01:00
Dirk Ziegelmeier
ea14b774c8 Replace several occurences of stdint types by lwIPs portability typedefs
Fixes bug #55405: Usage of uint8_t instead of ui8_t in TCP code
2019-01-06 21:19:04 +01:00
Dirk Ziegelmeier
d504e27142 dhcp.c: Fix typo in debug message 2019-01-04 11:08:46 +01:00
Jacob Kroon
2f098c42a7 Fix compile of UDP unit test
Fix building unit tests via contrib/ports/unix/check on Debian 9, gcc 6.3.0.

Fixes:
  <snip>/ip_addr.h:105:58: error: the comparison will always evaluate as ‘true’ for the address of ‘ip1’ will never be NULL [-Werror=address]
   #define IP_SET_TYPE(ipaddr, iptype)     do { if((ipaddr) != NULL) { IP_SET_TYPE_VAL(*(ipaddr),iptype); }}while(0)

Signed-off-by: Jacob Kroon <jacob.kroon@gmail.com>
2019-01-03 07:09:51 +01:00
Jacob Kroon
c02fea0961 PPP, PPPoE: use service name and concentrator name
Make pppoe_create() actually store the passed service name and
concentrator name, so that they are passed in the PADI/PADR/PADS
packets.

Assume that the user application won't be freeing the strings and just
copy the string pointers, therefore remove the mem_free() in
pppoe_destroy().

Since only the pointers are copied now, make them 'const' in
pppoe_softc.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2018-12-20 13:24:04 +01:00
Sylvain Rochet
48615984c7 PPP, PPPoE: remove leftover from PPPOE_SCNAME_SUPPORT support
Stupid me managed to push a pending patch, remove it.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2018-12-18 22:19:37 +01:00
Jacob Kroon
7eab5947af PPP, PPPoE: fix build when PPPOE_SCNAME_SUPPORT is defined
lwip/src/netif/ppp/pppoe.c:768:24: error: pointer targets in passing argument 1 of ‘strlen’ differ in signedness [-Werror=poin$
     l1 = (int)strlen(sc->sc_service_name);
lwip/src/netif/ppp/pppoe.c:772:24: error: pointer targets in passing argument 1 of ‘strlen’ differ in signedness [-Werror=poin$
     l2 = (int)strlen(sc->sc_concentrator_name);

sc->sc_service_name and sc->sc_concentrator_name are best defined as
char* because there are passed to libc strings functions which expect
a char*.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2018-12-18 22:13:46 +01:00
Sylvain Rochet
96548ede2b PPP, PPPoE: rename PPPOE_TODO to PPPOE_SCNAME_SUPPORT, prepare service name and concentrator support
Rename PPPOE_TODO to PPPOE_SCNAME_SUPPORT because this is the only
feature enclosed by them. Prepare for proper service name and
concentrator name support by moving PPPOE_SCNAME_SUPPORT define to
ppp_opts.h.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2018-12-18 22:09:48 +01:00
Dirk Ziegelmeier
2ff0db9a9b Fix bug #55171: Binding UDP PCB with different IP type PCBs does not work
by additionally checking IP address type
2018-12-06 14:40:57 +01:00
Dirk Ziegelmeier
91037b4c28 Add testcase for bug #55171: Binding UDP PCB with different IP type PCBs does not work 2018-12-06 14:40:20 +01:00
Jasper Verschueren
75f33081c2 DEF: added lwip_strnistr() for case insensitive matching 2018-12-05 19:59:45 +01:00
Simon Goldschmidt
dcb29c591f nd6: fix copying more than one DNS server
See bug #55163
2018-12-05 19:56:48 +01:00
Simon Goldschmidt
282389a332 altcp_tls_mbedtls: listen: free members of the ssl context
The ssl context is not used on listening pcbs. This includes freeing
input/output buffers, so saves ~32KByte by default.
2018-12-03 07:14:02 +01:00
Dirk Ziegelmeier
930eb27ba7 CMake: add debug info only for debug builds 2018-11-28 22:43:21 +01:00
Dirk Ziegelmeier
aaf7f03d95 List supported build types in top-level CMakeLists.txt 2018-11-26 09:26:37 +01:00
Dirk Ziegelmeier
0df4109074 Fix MSVC optimization flags 2018-11-26 08:11:39 +01:00
Dirk Ziegelmeier
781a4ccb62 mdns_domain.c: Fix doxygen comments 2018-11-25 14:39:31 +01:00
Dirk Ziegelmeier
c79af6e53e Doxygen: Warnings are errors 2018-11-25 14:38:16 +01:00
Dirk Ziegelmeier
982b86fa48 CMake: Add support for Debug/Release builds 2018-11-25 14:25:23 +01:00
Dirk Ziegelmeier
92a18bf638 Fix bug #55078: Add custom data to pbuf struct
Add a #define that users can use to store custom data on a pbuf
2018-11-25 14:01:23 +01:00
Simon Goldschmidt
3f583a1757 altcp_tls: add functions to create servers with multiple certificates 2018-11-24 13:41:34 +01:00
Simon Goldschmidt
6f232b7c3f altcp_tls_mbedtls: add session tickes, improve configuration for session cache 2018-11-23 22:39:58 +01:00
Simon Goldschmidt
54448559bb altcp_tls_mbedtls: add debug output of mbedtls library 2018-11-23 22:25:21 +01:00
Simon Goldschmidt
7859c6832b makefsdata: fix compiling for win32 2018-11-23 12:59:07 +01:00
Axel Lin
d116d235a5 apps/smtp: Remove redundant LWIP_ASSERT checking in smtp_send_mail_bodycback
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2018-11-23 19:28:24 +08:00
Dirk Ziegelmeier
b1fbb5ad45 Fix warnings about ignored return values in makefsdata.c
These only show up when compiling with -O3
2018-11-22 21:53:12 +01:00
Dirk Ziegelmeier
e31f1b918c mdns.c: Fix accessing potentially uninitialized variable
myprobe_inpkt.pbuf may not be set to NULL in mdns_handle_probe_tiebreaking()
2018-11-22 13:36:20 +01:00
Dirk Ziegelmeier
45a055840d snmp_traps.c: Portability fix: Don't use non-constant initializers 2018-11-22 13:25:43 +01:00
Dirk Ziegelmeier
5da6c0cfd0 CMake build system: Fix STREQUAL comparisons and set /Wall for MSVC 2018-11-22 13:25:43 +01:00
Craig McQueen
ef76bbe3f0 DNS: Allow a DNS look-up with a trailing dot in the name
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-11-22 13:14:41 +01:00
Simon Goldschmidt
9071db11af snmp: don't allocat outbound msg for GET RESP (inform cb) 2018-11-22 12:54:50 +01:00
Simon Goldschmidt
ed59260b92 snmp: fix coding style
no need to initialize global static variables to NULL
2018-11-22 12:51:46 +01:00
Dirk Ziegelmeier
c23aa713f9 Try to fix compile warning in mdns.c
src/apps/mdns/mdns.c: In function 'mdns_debug_print_answer':
src/apps/mdns/mdns.c:796:24: warning: ', rdata = ' directive output may be truncated writing 10 bytes into a region of size between 8 and 15 [-Wformat-truncation=]
   snprintf(string, 35, "Type = %2d, class = %1d, rdata = ", a->info.type, a->info.klass);
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/apps/mdns/mdns.c:796:3: note: 'snprintf' output between 31 and 38 bytes into a destination of size 35
   snprintf(string, 35, "Type = %2d, class = %1d, rdata = ", a->info.type, a->info.klass);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2018-11-22 11:37:24 +01:00
Dirk Ziegelmeier
10e0130a4a netbiosns_name_decode: Take CONST char* as first argument 2018-11-21 21:03:36 +01:00
Jens Nielsen
b0c753da96 Fix netbiosns expecting too large packet 2018-11-21 20:50:35 +01:00
Dirk Ziegelmeier
30b2d07362 Fix compile error with GCC 8 in makefsdata
lwip/lwip/src/apps/http/makefsdata/makefsdata.c:929:56: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=]
   snprintf(qualifiedName, sizeof(qualifiedName), "%s/%s", curSubdir, filename);

/home/dziegel/lwip/lwip/src/apps/http/makefsdata/makefsdata.c:929:3: note: ‘snprintf’ output 2 or more bytes (assuming 257) into a destination of size 256
   snprintf(qualifiedName, sizeof(qualifiedName), "%s/%s", curSubdir, filename);

Reduce subdir string length by 3 bytes to make the warning go away. The whole file path including directory AND filename is limited to MAX_PATH_LEN - so it is reasonable to reserve 3 bytes less for directory - the filename won't fit anyway in the remaining 3 bytes.
2018-11-20 20:34:29 +01:00
Jasper Verschueren
ee1bab3411 mDNS: conflict resolution added
If the host observes a response (after probing) containing RR's
that he thought were unique to him, there is a conflict. If a host
observes such conflict, it resets back to probing and the probing
procedures will resolve the conflict. (RFC6762 section 9)
2018-11-20 12:49:58 +01:00
Simon Goldschmidt
3bd84aba4b snmp_v3: use strlen, not strnlen
strnlen is not portable.
In this case, it does not matter as we zero-terminate the string before.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-11-19 20:13:30 +01:00
Axel Lin
4413576494 doc/mdns.txt: Update document for mdns API changes
Update mdns.txt for below API changes:
* mdns_resp_add_netif() no longer has dns_ttl argument
* mdns_resp_add_service() no longer has dns_ttl arguemnt
* mdns_resp_add_service() uses enum mdns_sd_proto for proto argument
* Add missing const qualifier at appropriate places

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2018-11-19 23:26:38 +08:00
Dirk Ziegelmeier
aa83bdf490 Fix bug #55034: apps/smtp.c fails to compile with strict C compatibility because of strnlen
by replacing strnlen with strlen. It's a user-supplied string, so we can assume it is correctly \0 terminated (as done several times elsewhere in the code)
2018-11-19 14:43:26 +01:00
Dirk Ziegelmeier
4adcd68ce4 Fix compile of mdns.c
Add missing stdio.h for snprintf()
Fix variable declaration in code
2018-11-19 14:32:05 +01:00
Jasper Verschueren
19cbf2a652 mDNS: probe rate limiting if more then 15 conflicts occur in 10s
According to RFC6762 section 8.1:
If fifteen conflicts occur within any ten-second period, then the
host MUST wait at least five seconds before each successive
additional probe attempt.
If the host restarts mDNS, instead of a probe wait timeout randomly
chosen between 0 and 250ms, we wait 5s if more then 15 conflicts
occured in 10seconds. This flag is reset from the moment probing
succeeded.
2018-11-19 14:26:25 +01:00
Jasper Verschueren
593c02aed4 mDNS: probe tiebreaking added
mDNS: first version probe tiebreaking added

This first version works for our MCU boards but does only compare
the first question and answer. It does not sort the list of answers
and it does not search for answers or questions.

mDNS: improved probe question handling

For every probe question in our packet, we check the presence
in the incomming packet until we find a match. then we perform
the tiebreaking. At the moment we still only look at the first
answer.

mDNS: evaluate all answers in the authoritative section

The authoritative sections of both messages are evaluated.
The records that answer the probe question are sorted in to lists.
Then the lists are compared pairwise. A winner and a loser are
chosen and the host reacts on the outcome (ignore or stop probing).

mDNS: add support for name decompression in rdata when comparing.

For probe tiebreaking we need to compare RR's. It is possible that
the rdata of an RR contains compessed names (SRV record). We need
to decompress it first before we do the comparison.
2018-11-19 14:25:31 +01:00
Jasper Verschueren
a09646c507 mDNS: split probe packet definition and split outpkt creation
Probe packet creation -> by splitting the definition and the sending
we can use the definition function for probe tiebreaking.
outpkt creation -> by splitting the creation and sending we can use
the creation function for probe tiebreaking.
2018-11-16 14:52:40 +01:00
Simon Goldschmidt
2a236088ae add new mdns files to win32 msvc project 2018-11-14 20:33:10 +01:00
Jasper Verschueren
861ce296b9 mDNS: respond to probe via multicast added
The host only responded to a probe query via unicast because
according to the RFC, a probe should have the QU bit on.
This is a should and not a must so we need to be careful.
We added multicast probe answering support with the needed timouts.
Avahi for example probes with the QM queries. With this commit the
conflict is resolved.
2018-11-14 16:52:17 +01:00
Dirk Ziegelmeier
530a4ccdce Fix return value of sys_arch_mbox_tryfetch() in Win32 port
It should be SYS_MBOX_EMPTY, not SYS_ARCH_TIMEOUT.
SYS_MBOX_EMPTY is defined to SYS_ARCH_TIMEOUT, so there is no bug.
But for good readability of the code,  SYS_MBOX_EMPTY should be used.
2018-11-13 20:35:53 +01:00
Dirk Ziegelmeier
915e923809 Fix bug #55017: Wrong return value in sys_arch_mbox_tryfetch() in FreeRTOS port 2018-11-13 20:34:18 +01:00
Dirk Ziegelmeier
d386388fb5 Move netif_mdns_data() and get_mdns_pcb() to mdns_priv.h 2018-11-13 12:22:24 +01:00
Dirk Ziegelmeier
2adc6d2687 MDNS: Minor compile fix, declare variables before code 2018-11-13 12:20:57 +01:00
Jasper Verschueren
405fc4d802 Revert "mDNS: authority section of probe message needs to contain all records"
This reverts commit e959e6efaf8a1cb57e9a5d4d8e0056c7ea52179f.
2018-11-13 12:18:19 +01:00
Jasper Verschueren
ee7ed8c87d mDNS: cleanup probing and announcing sequence
The implementation was not fully to the standard. This commit adds
a nicer state machine implementation and multiple announce messages
with a minimum of 2.
2018-11-13 12:18:04 +01:00
Jasper Verschueren
65eb36b10d mDNS: ignore responses with src port != 5353 (rfc6762 section 6) 2018-11-13 12:17:38 +01:00
Jasper Verschueren
16da67bb21 mDNS: source address check added
RFC6762 section 5.5 and 11 define that we should check that all
packets originated on the local link.
2018-11-13 12:17:38 +01:00
Jasper Verschueren
331368e3aa mDNS: add new files to filelists + solve compile errors
ttl setting removed from example code.
string.h included where needed.
2018-11-13 12:17:38 +01:00
Jasper Verschueren
201e772e15 mDNS: author comment update + things left to implement update 2018-11-13 12:17:38 +01:00
Jasper Verschueren
4289293061 mDNS: add support for output delaying
See below commit messages for more information

mDNS: support for direct and delayed sends

There are two ways to send a response, directly and after a delay.
A probe or an announce msg are now send via the direct way and
all responses are send via the delayed way.

mDNS improved delay vs direct send behavior on questions

All multicast answers are delayed at the moment. While all unicast
answers are send out directly. A unicast answer is send when this
is requested by the QU bit, when a unicast question was send or
when the question originated from a legacy querier.

mDNS: add probe query detection.

If a probe query is detected a direct unicast respond is send.
Independent of the QU/QM bit.

mDNS split delayed multicast msgs into ipv4 and ipv6 buffers.

We are implementing a two resolvers in one (IPv6 and IPv4 together).
For directly send answers, this does not matter. But for delayed
answers, we need to make a separate buffer for both.

mDNS: addr bug, we should not clear full outmsg

memset deleted also the dest_addr and dest_port, which should remain
and is constant. This commit contains a function that resets only the
needed parts of the outmsg struct.

mDNS: do not multicast a rr within one second.

RFC6762 section 6: prevent network flooding. When a multicast packet
is send out, we start a timeout of 1s within this 1 second all
multicast requests are ignored. We do not make a difference between
the records, we set the delay for all records.

mDNS: improved split for unicast vs multicast and direct vs delayed

unicast delayed message are now possible and multicast direct msgs to.

MDNS: changed printfs to lwip debug messages

MDNS: change timeouts from max time to random time

mDNS: send multicast response on QU questions if not multicasted recently.

If a QU question is received, the responder should multicast the
answer if it did not multicast that record within 25% of it's ttl.

we implemented a stripped down version, meaning that we look at the
records as one set and use one timer for all records. So if the
responder multicasted a record within 30s of the QU question it
will respond with a unicast answer. if not, it will respond
multicast.

mDNS: timeouts -> create function for mdns timeout handling

mdns_set_timeout will check if the timer is running or not and will
update the flag to running after starting the timer.
Multicast timeouts were not set everywhere they needed to be. This
is solved.
mulit <-> multi typo fixed.

mDNS: solve commenting and style issues

mDNS: add #if LWIP_IPVx to new code

LWIP_IPV4/6 can be enabled or disabled, all combination should work.
2018-11-13 12:17:37 +01:00
Jasper Verschueren
4ea5110662 mDNS: remove netif from mDNS structs
it's more practical to use netif as a wrapper instead of wrapping
netif in the mdns packets. netif contains all information.
Netif is passed along were needed.
2018-11-13 12:17:37 +01:00
Jasper Verschueren
62fb2fd749 mDNS fix TTL bug
MDNS_TTL changed to MDNS_IP_TTL for clarity.
The mDNS RR ttl does not need to be settalbe, this is against the
RFC. RFC6762 states that for rr's with the hostname in them
somewhere, the ttl should be 120s. If it's not in their it should
be 75 minutes and if the answer is send to a legacy dns querier,
it should be no more then 10s.
This patch corrects the ttl behavior to the RFC.
2018-11-13 12:17:37 +01:00
Jasper Verschueren
c4321330d0 mDNS: authority section of probe message needs to contain all records
see RFC 6762 section 8.2: for tiebreaking to work correctly in all
cases, the Authority section must contain all the records and
proposed rdata being probed for uniqueness.
2018-11-13 12:17:37 +01:00
Jasper Verschueren
3043d9d023 mDNS: move domain related functions and output related funtions
mDNS.c needed to become cleaner. Domain related functions are
moved to the mdns_domain.c util module. The output related
functions are split off (clear separation between defining the
packet and generating the packet). The output functions can
now be found in mdns_out.c.

mDNS move probe question packet generation to mdns_send_outpacket

The probe any questions were added to the pbuf in the send_probe
routine. It is better if we move all pbuf generation to the output
function so later on packets can be delayed etc. keep it all in
one place.

mDNS: move legacy question generation to mdns_send_outpacket

It's better to do the pbuf generation in one place.
Especially important for message delaying etc.

mDNS take out domain related functionality and put in other file.

The mDNS file is getting very big and a lot still needs to be added.
For clarity reasons it's better to split these domain functions
from the main mDNS file.

mDNS split off output related functionality and put in other file

A lot of functions are only needed for the generation of the pbuf,
by separating them into another file we clean up the mdns file.
We only need the mdns_send_outpacket function as interface.
Packet definition is now completely separated from packet
generation.
2018-11-13 12:17:36 +01:00
Simon Goldschmidt
1a10a942f2 tcp_recved: fix overflow check
Improved fix instead of patch #9699.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
(cherry picked from commit 98d1cb1c000577468e2b1b54137b4bb37f161f85)
2018-11-12 21:01:47 +01:00
Simon Goldschmidt
18b91b2841 Revert "tcp_recved: check for overflow and warn about too big values"
This reverts commit 684adaca2990b713b1708e46bda150f9a6e3c297.

It changes the behaviour to assert for applications running good so far.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-11-12 21:01:05 +01:00
Simon Goldschmidt
a29fc52633 sync CHANGELOG after releasing 2.1.1 2018-11-09 17:23:17 +01:00
Axel Lin
292bd85db6 sockets: Trivial comment fixes
lwip_getsockopt_internal/lwip_setsockopt_internal were renamed to
lwip_getsockopt_impl/lwip_setsockopt_impl. Update the comment accordingly.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2018-11-09 17:14:20 +08:00
Simon Goldschmidt
1d2567c7bf doc: update our docs for upload to savannah download area 2018-11-08 22:36:59 +01:00
Axel Lin
7bcf0d3334 sockets: Fix missing err_to_errno conversion for ERR_VAL in lwip_recvmsg
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2018-11-08 22:43:51 +08:00
Dirk Ziegelmeier
7869d7c5f7 More snmp_traps.c documentation fixes 2018-11-08 08:35:39 +01:00
Dirk Ziegelmeier
98e31f7ba6 SNMP: Simplify two informs functions 2018-11-07 21:23:28 +01:00
Dirk Ziegelmeier
0e3bc53432 Fix comments in new SNMP code 2018-11-07 21:21:23 +01:00
Dirk Ziegelmeier
2e9c60b410 Fix unused variable in snmp_example.c when SNMP is disabled 2018-11-07 21:09:30 +01:00
Dirk Ziegelmeier
65033b6ba5 Apply patch for task #15072: SNMP support for notifications and informs (v2c)
Original author: Ognjen Bjelica
with minor fixes from Dirk Ziegelmeier
2018-11-07 21:04:53 +01:00
Dirk Ziegelmeier
93c3cfd2b1 Fix initialization of mqtt example IP 2018-11-07 21:04:53 +01:00
Dirk Ziegelmeier
0df1559056 Improve comments in setup-tapif 2018-11-07 21:04:53 +01:00
Simon Goldschmidt
f72227aadc fix compiling ETHARP_SUPPORT_VLAN without LWIP_HOOK_VLAN_SET and LWIP_VLAN_PCP 2018-11-07 10:49:06 +01:00
Simon Goldschmidt
153c295b6f altcp_tls_mbedtls: use mbedtls_entropy_func for mbedtls_ctr_drbg_seed
This is the default way for mbedTLS. Add entropy sources via defines (see
mbedtls_entropy_init).

This removes the use of ALTCP_MBEDTLS_RNG_FN

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-11-06 21:28:45 +01:00
Dirk Ziegelmeier
fe05be110d Unix port setup-tapif: Add bridge to TAP interface 2018-11-04 08:59:41 +01:00
Dirk Ziegelmeier
feee9d903a Unix port: Give threads a name on Linux
May also work on Darwin, but I can't test it :-)
2018-11-02 20:22:22 +01:00
Dirk Ziegelmeier
ba8d9b0018 lwipopts.h: Raise number of UDP PCBs
Was not sufficient when all apps are enabled
2018-11-02 20:21:50 +01:00
Dirk Ziegelmeier
ba705d3f7f Fix assertions in udpecho.c 2018-11-02 20:19:52 +01:00
Dirk Ziegelmeier
33325bbf3b Make setup-tapif script executable 2018-11-02 19:32:39 +01:00
Joan Lledó
284659156d Remove assertion about the end of pollfd array
See bug #54933.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-11-01 21:56:58 +01:00
Simon Goldschmidt
3c17c1e82e fix typo in comment 2018-11-01 21:42:09 +01:00
Dirk Ziegelmeier
7c2267b966 Fix bug #54670: 127.0.0.1 sent out to netif_default? 2018-11-01 21:36:24 +01:00
Dirk Ziegelmeier
48c2056d5b Implement unit test for bug #54670: 127.0.0.1 sent out to netif_default? 2018-11-01 21:35:46 +01:00
Dirk Ziegelmeier
0c34597b9e netif: Add getter for loopif for unit tests 2018-11-01 21:35:06 +01:00
Dirk Ziegelmeier
26a84d9307 Minor: add parenthesis for cleaner code 2018-10-28 21:08:24 +01:00
Dirk Ziegelmeier
5698e57da3 VS code workspace: add unit tests 2018-10-27 22:35:54 +02:00
Florent Matignon
ffbe075d56 bug #54700: Unexpected expiry of pending ARP table entry
New etharp queries should restart the 5 second timeout on the ARP
table entry if it is still pending.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-26 20:59:10 +02:00
Simon Goldschmidt
fa37888da2 altcp_tls_mbedtls: update list of todos
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-26 20:43:06 +02:00
David GIRAULT
6e994f9df2 bug #54744: if altcp_close() called from recv() callback, there is some write to freed memory
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-26 19:56:54 +02:00
Simon Goldschmidt
a352f4e11c Explicitly check for TCP_MSS to be <= ~16 kByte
See bug #54890

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-26 19:43:13 +02:00
Simon Goldschmidt
a41c1fcc62 patch #9350: Sockets API: use OS's sys/socket.h instead of lwip/sock
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-26 19:33:47 +02:00
Dirk Ziegelmeier
6b92dd6907 CMakeCommon.cmake: Add missing newline 2018-10-24 15:08:02 +02:00
Dirk Ziegelmeier
ec28364a2f SNMP_ERR_NOTWRITABLE is a more appropriate return value for the last two commits
The instance of the SNMP node was found, that's why the functions have been called. So if set_test() and/or set_value() do not exist, it means the SNMP node instance is not writable.
2018-10-24 09:59:06 +02:00
Dirk Ziegelmeier
ee2f5c52d1 Fix the same issue as in snmp_scalar.c in snmp_threadsync.c 2018-10-24 08:54:08 +02:00
Dirk Ziegelmeier
36e2d2255e Fix wrong return value in snmp_scalar_array_get_value() 2018-10-24 08:34:32 +02:00
Simon Goldschmidt
6a1fbc7433 snmp: fix coding style in last commit 2018-10-23 20:01:06 +02:00
Dirk Ziegelmeier
2e7b4573a5 SNMP: Avoid NULL pointer dereference in snmp_scalar.c 2018-10-23 14:26:29 +02:00
Simon Goldschmidt
ff8d1a384f httpd: SSI types should be overridable (task #15071)
Add define LWIP_HTTPD_SSI_EXTENSIONS to make the extension list
overridable, clarify documentation of LWIP_HTTPD_SSI_BY_FILE_EXTENSION
a bit.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-23 08:17:45 +02:00
Simon Goldschmidt
f6b728b24c makefsdata: obey LWIP_HTTPD_SSI_BY_FILE_EXTENSION
Don't check SSI extension list if LWIP_HTTPD_SSI_BY_FILE_EXTENSION == 0

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-23 08:16:49 +02:00
Simon Goldschmidt
688b0935e2 Try to catch missing std includes on travis
By defining LWIP_PLATFORM_ASSERT to a function, we can prevent arch.h
from including stdio.h and stdlib.h

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-23 08:00:37 +02:00
Simon Goldschmidt
a6cf42a937 fix compiling win32 port (packet.lib not found)
Library search path changed after moving contrib

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-23 07:59:00 +02:00
Simon Goldschmidt
ef02b1dc20 fix missing standard includes
These were a problem only if arch.h does not include them.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-23 07:46:13 +02:00
Dirk Ziegelmeier
06cc825431 Whitespace cleanup lwIP 2018-10-22 20:53:58 +02:00
Dirk Ziegelmeier
64e0ede1a1 Whitespace cleanup in contrib dir 2018-10-22 20:53:58 +02:00
Simon Goldschmidt
e0e4240875 Revert "Allow the use of external Sockets headers"
This reverts commit 413b26a7e1f746108e2d7f200baf1e08071329c2.

It breaks the build if LWIP_SOCKET is disabled.
Plus it breaks git history for inet.h and sockets.h for no real reason.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-22 20:37:56 +02:00
Dirk Ziegelmeier
3aef9c5305 VSCode cleanups 2018-10-22 19:48:01 +02:00
Dirk Ziegelmeier
f53932d7ca Travis: Remove "-j 4" command line option - does not make sense for ninja-build 2018-10-22 17:18:34 +02:00
Dirk Ziegelmeier
3f690e0bf0 Improve build system documentation 2018-10-21 20:30:48 +02:00
Dirk Ziegelmeier
95aba99f41 Implement task #11620: Add outgoing VLAN PCP support for Ethernet level QoS
Apply rebased patch from Timmy Brolin
2018-10-19 22:30:17 +02:00
Dirk Ziegelmeier
64bc2c3df7 Fix bug #54805: IP address can not be obtained over dhcp if PBUF_POOL_BUFSIZE is too small
Patch by Christoph Chang
2018-10-19 21:06:15 +02:00
Joan Lledó
413b26a7e1 Allow the use of external Sockets headers
New macro LWIP_SOCKET_HEADERS can be used to replace
    LwIP sockets headers by OS's headers.

    By default LWIP_SOCKET_HEADERS==LWIP_SOCKET, when LWIP_SOCKET==1
    and LWIP_SOCKET_HEADERS==0, user must provide their custom headers
    by setting LWIP_INCLUDE_SOCKETS and LWIP_INCLUDE_INET.
2018-10-19 20:30:24 +02:00
Dirk Ziegelmeier
5405c3d97d Cleanup iteropts.sh output a bit 2018-10-18 22:36:59 +02:00
Dirk Ziegelmeier
c05b07c314 Fix iteropts test 2018-10-18 21:59:36 +02:00
Dirk Ziegelmeier
8f8c0d26ef Try to find out what goes wrong on travis... 2018-10-18 21:22:47 +02:00
Dirk Ziegelmeier
ca8f0254cf Try to get iteropts test running on Travis 2018-10-18 21:15:48 +02:00
Dirk Ziegelmeier
cf4cefd73c Try to get ninja-build running on Travis 2018-10-18 11:05:07 +02:00
Dirk Ziegelmeier
23945d2e3f Try to build documentation on travis, too 2018-10-18 10:58:29 +02:00
Dirk Ziegelmeier
daeceeeca0 Next try to get CMake up and running on Travis 2018-10-18 10:47:51 +02:00
Dirk Ziegelmeier
5840b090d4 Travis: Use CMake from /usr/local/bin 2018-10-18 10:33:35 +02:00
Dirk Ziegelmeier
95eada2119 Revert a change that was made for old cmake version
Lets see if it works now on travis...
2018-10-18 10:17:19 +02:00
Dirk Ziegelmeier
2e51e0dc81 Travis: Use newer CMake, install Ninja 2018-10-18 10:05:57 +02:00
Simon Goldschmidt
9171960c11 update ignore list 2018-10-18 09:04:38 +02:00
Simon Goldschmidt
0be3e35bf2 tftp: mode_to_string() should be static 2018-10-17 21:53:04 +02:00
Simon Goldschmidt
f098c4515e tftp: added example for tftp client
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-17 21:39:37 +02:00
Simon Goldschmidt
0ee4784d0c tftp client: pass 'mode' as an enum, not as a string constant 2018-10-17 21:37:46 +02:00
Simon Goldschmidt
4edbec760a README: put wiki after mailing lists (it's not that good...) 2018-10-17 20:27:00 +02:00
Dirk Ziegelmeier
ee269ceec5 Fix bug #54850: lwip definition of htonX and ntohX do not properly cast to unsigned when byte order is Big Endian
Changes suggested by Ivan Warren
2018-10-17 20:23:28 +02:00
Dirk Ziegelmeier
c2892ed0fb Travis: Try to use Clang-7 2018-10-15 08:58:43 +02:00
Dirk Ziegelmeier
f99f304c20 Add special compile config for Travis 2018-10-14 09:44:12 +02:00
Dirk Ziegelmeier
8dd931ab27 Fix cyclic linking dependency when using MBEDTLS 2018-10-14 09:43:22 +02:00
Simon Goldschmidt
fa76861481 tftp: fix cast warnings; return all error codes
Also keep tftp_mode in tft_state

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-13 20:26:06 +02:00
Simon Goldschmidt
f272a75b6a implement 'keypressed()' in the unix port
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-13 16:31:01 +02:00
Simon Goldschmidt
7c10065bd2 Revert "Try to implement platform-independent keypressed()"
This reverts commit a0d7b01186ffaba8369d2b5f2e50275ae03af96b.

The new 'keypressed()' wasn't platform-independent but broke
the win32 port.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-13 16:26:25 +02:00
Dirk Ziegelmeier
a0d7b01186 Try to implement platform-independent keypressed() 2018-10-13 11:26:59 +02:00
Dirk Ziegelmeier
c35dd079ee Adapt launch.json to top-level CMakeLists.txt 2018-10-13 11:26:32 +02:00
Dirk Ziegelmeier
31545ed787 Getting CMake build running on travis 2018-10-13 11:06:00 +02:00
Dirk Ziegelmeier
ea1337d5a2 Travis: Next try for CMake... 2018-10-13 10:57:26 +02:00
Dirk Ziegelmeier
31dbc5722c Another try to get CMake run on travis 2018-10-13 10:54:54 +02:00
Dirk Ziegelmeier
22c1c4ec8d Try to get CMake build running on travis 2018-10-13 10:45:58 +02:00
Dirk Ziegelmeier
d03d4c16fb Travis/LSAN: reenable thread logging, sudo REQUIRED solved the problem 2018-10-13 10:32:37 +02:00
Dirk Ziegelmeier
d33098a8d8 Travis: Try sudo:required 2018-10-13 10:23:42 +02:00
Dirk Ziegelmeier
60afb13e60 Play with LSAN_OPTIONS 2018-10-13 10:00:18 +02:00
Dirk Ziegelmeier
f521d779fb Work on Travis-CI 2018-10-13 09:49:48 +02:00
Dirk Ziegelmeier
ded63c12f1 Try to use more recent compilers on travis 2018-10-13 09:27:18 +02:00
Simon Goldschmidt
ed999f0195 Update travis-CI URL 2018-10-12 22:57:47 +02:00
Simon Goldschmidt
eeef3f65b8 Add a unit test for bug #54833 (tcp_abort with wrong ports)
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-12 22:57:24 +02:00
Simon Goldschmidt
a63a7d3c76 Fix bug #54806 (ppp: invalid LWIP_ASSERT_CORE_LOCKED() check)
pppos_input() is safe to call from outside tcpip_thread when
PPP_INPROC_IRQ_SAFE == 1, so only check if PPP_INPROC_IRQ_SAFE == 0

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-12 22:26:51 +02:00
Dirk Ziegelmeier
06016cc939 Disable CMake build for now, seems I need a newer CMake version 2018-10-12 22:22:35 +02:00
Simon Goldschmidt
426a6004bf Revert "tcp_abandon: no need to buffer pcb->local_port"
This reverts commit 1570dd8ad1c6afd2438dcb8b18d9eed794f78baa.

Buffering pcb->local_port is needed because TCP_PCB_REMOVE_ACTIVE()
sets it to 0 via tcp_pcb_remove() (comment: "reset the local port
to prevent the pcb from being 'bound'").

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-12 22:14:23 +02:00
Dirk Ziegelmeier
1bba969a4a Next try to fix CMake build on Travis 2018-10-12 22:12:07 +02:00
Dirk Ziegelmeier
1c5c2967e4 Try to fix Travis-CI CMake build 2018-10-12 22:06:10 +02:00
Dirk Ziegelmeier
6826130d6f CMake: Use include_guard only when CMake >= 3.10.0 2018-10-12 22:01:25 +02:00
Dirk Ziegelmeier
a63b5aeaa7 Rename test.sh to travis.sh 2018-10-12 21:44:47 +02:00
Dirk Ziegelmeier
75bc361156 Add example app to travis (using cmake) 2018-10-12 21:42:41 +02:00
Simon Goldschmidt
0528f68c6d Fixed the remaining dhcp unit tests after adding ACD
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-12 21:37:17 +02:00
Simon Goldschmidt
8d05e22f9a Fix some dhcp unit tests after adding ACD, disable the rest
I disabled the yet unfixed tests to test if the new travis
integration works. Still working on them...

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-12 21:20:23 +02:00
Simon Goldschmidt
b406a54389 Fix mqtt unit test broken after 684adaca
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-12 21:18:39 +02:00
Simon Goldschmidt
e3cd915fb9 Fix whitespace error introduced when merging 684adaca
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-12 21:18:17 +02:00
Simon Goldschmidt
0d4e1beec4 Fix compiling ACD without LWIP_RAND
Copy bad rand implementation from old one in autoip.c

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-12 21:05:19 +02:00
Dirk Ziegelmeier
e16cc67b70 Fix Makefile-based builds 2018-10-12 20:43:22 +02:00
Simon Goldschmidt
39162c2d0c Add new files to msvc projects 2018-10-12 20:32:34 +02:00
Dirk Ziegelmeier
5a8ad9d4ba Make test.sh executable 2018-10-12 20:26:22 +02:00
Dirk Ziegelmeier
a3a4103d66 Start working on Travis-CI integration 2018-10-12 20:09:58 +02:00
Dirk Ziegelmeier
437e0a6756 Fix C++ style comments in TFTP 2018-10-12 14:27:31 +02:00
Jonas Rabenstein
d1da9ec5d3 err.h: move typedef of err_t after enum definition
This allows for 'typedef err_enum_t err_t' and thus strong type checking
of the enum in c++.
2018-10-11 07:32:55 +02:00
Jonas Rabenstein
684adaca29 tcp_recved: check for overflow and warn about too big values 2018-10-11 07:31:54 +02:00
Dirk Ziegelmeier
f61e57965f Minor coding style fix in tftp.c 2018-10-09 09:07:08 +02:00
Dirk Ziegelmeier
27835fd798 Minor build system docs improvments 2018-10-08 22:19:31 +02:00
Dirk Ziegelmeier
ef5bc352fb Document CMake build system 2018-10-08 22:17:03 +02:00
Dirk Ziegelmeier
65b1a395f4 TFTP: Fix doxygen docs 2018-10-08 22:16:40 +02:00
Dirk Ziegelmeier
a6dc31433e Restructure CMake build system a bit
This should be easier to use for application devlopers
2018-10-08 21:18:18 +02:00
Dirk Ziegelmeier
cba4e1f2a7 CMake: MBEDTLSDIR -> LWIP_MBEDTLSDIR 2018-10-08 21:17:32 +02:00
Dirk Ziegelmeier
2124becd04 Give lwIP a top-level CMakeLists.txt
(as it is common in other projects)
This breaks iteropts.sh for now
2018-10-08 21:02:43 +02:00
Dirk Ziegelmeier
abcf42b655 Fix compile of TFTP using GCC 2018-10-08 20:21:32 +02:00
Dirk Ziegelmeier
c8808f69b2 Fix tftp_init_client signature 2018-10-08 12:56:27 +02:00
Dirk Ziegelmeier
5a8bd37509 Improve TFTP comments 2018-10-08 12:48:16 +02:00
Dirk Ziegelmeier
6c2fd2d25d Improve TFTP implementation
- implement server/client mode (API is nicer to use)
- Increase TFTP_MAX_MODE_LEN to be able to contain "netascii" transfer mode
- Adapt tftp_example to changes
2018-10-08 12:45:29 +02:00
Dirk Ziegelmeier
de81e8bf19 VS Code again: Fix tasks.json for windows 2018-10-08 11:42:52 +02:00
Dirk Ziegelmeier
54fc708c76 Apply fix from Axel Lin
(Build issue if LWIP_DHCP is set to 0)
2018-10-08 11:42:28 +02:00
Dirk Ziegelmeier
7ba69d875c Some TFTP cleanups 2018-10-08 11:41:51 +02:00
Ben Wijen
b2713601f0 tftp: Add client functionality
* add helper functions
* add tftp_get/tftp_put
* rename files
2018-10-08 09:00:20 +02:00
Joan Lledó
c683427bfd alloc_socket(): Check for LWIP_SOCKET_POLL when setting select-related variables 2018-10-08 08:51:55 +02:00
Dirk Ziegelmeier
0f100b8c5b VSCode: Fix windows command line 2018-10-08 08:14:55 +02:00
Dirk Ziegelmeier
ff44049baf Rename DHCP_DOES_ACD_CHECK ->LWIP_DHCP_DOES_ACD_CHECK 2018-10-05 11:04:48 +02:00
Dirk Ziegelmeier
a3cdf3c4cc Move two #defines from acd.h to acd.c since they are only useful in there 2018-10-05 10:58:30 +02:00
Dirk Ziegelmeier
015cff75fd Fix "switch missing default case" in dhcp.c 2018-10-05 10:49:21 +02:00
Dirk Ziegelmeier
7492bfb0dc Enable DHCP_DOES_ACD_CHECK by default 2018-10-05 08:38:13 +02:00
Dirk Ziegelmeier
67d4fc9ff0 Minor cmake code cleanp 2018-10-05 08:04:22 +02:00
Dirk Ziegelmeier
d9c9b55766 CMake: add an include guard since files are intended to be included in other projects 2018-10-05 08:02:34 +02:00
Dirk Ziegelmeier
1f554efcbb Add ACD to several documents 2018-10-04 21:13:32 +02:00
Dirk Ziegelmeier
d4c8b3e7e8 Apply patch #9694: Update prev pointer when skipping entries in tcp_slowtmr to prevent hitting assertion 2018-10-04 17:38:17 +02:00
Dirk Ziegelmeier
5c4ada2098 Add VS Code workspace settings 2018-10-04 17:34:44 +02:00
Dirk Ziegelmeier
562f875533 Work on VS Code settings 2018-10-04 17:34:44 +02:00
Dirk Ziegelmeier
9a80c865b0 Filelists.cmake: Minor message improvement 2018-10-04 17:34:44 +02:00
Dirk Ziegelmeier
9c86302113 acd.h: No "," at last enum element 2018-10-04 17:34:44 +02:00
Dirk Ziegelmeier
f8ed17082d A few ACD compile and doc fixes 2018-10-04 17:34:44 +02:00
Jasper Verschueren
7d1c26cc0c ACD module added + update and improve DHCP + AUTOIP behavior
Squashed commit of the following:

commit 2d98d8e2ef1941c3824ffb874f1e529d284667fc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Thu Sep 13 16:15:06 2018 +0200

    AUTOIP: correct functionality autoip_supplied_address

    It does not mean that if autoip is bound, it also supplied the
    netif address. A check is added.

commit 2ca0a2183991ef73860c4207d95799b37acc64cc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Thu Sep 13 16:06:49 2018 +0200

    AUTOIP: keep using the same link local address as much as possible

    Only calculate a new link local address at start up or when a
    conflict occured. On link up or down -> keep same address.

    TODO: in the future a function for persistent storage should be
    added.

commit aa70a693351e4c898aa28d8521308794614838f1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Thu Sep 13 14:43:14 2018 +0200

    ACD, AUTOIP & DHCP: make link up & down functions where needed

    When the link goes down or up the approriate functions should be
    stopped or started again. To accomodate this, network_changed is
    adjusted to network_changed_link_up and network_changed_link_down.
    DHCP does not need to control AUTOIP. AUTOIP can take care of
    itself. The only thing DHCP needs to do is starting it when
    discovering is failing. The AUTOIP state variable is removed from
    DHCP.

commit ad469eb006b47f8a8c37f7c0de0216f47a8c19c7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Thu Sep 13 11:25:58 2018 +0200

    ACD: add address change listener + passive conflict detection mode

    In the case their previously was a LL address on a netif that
    is now configured with a routable address, we want the LL
    address to be able to keep receiving packets.
    for as long as the LL address is available on the interface it
    should do ongoing conflict detection. But we cannot defend when
    the LL address is not the netif address any more.
    An address change listener is added to detect when an ACD module
    needs to go from active ongoing conflict detection to passive.
    When a conflict is detected autoip is stopped and will not be able
    to receive packets any more. Because we have a valid routable
    address on the netif, autoip is not restarted.

commit 07c4ec20cea78e2b4a6f5599569abaf075619c62
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Tue Sep 11 16:25:37 2018 +0200

    ACD: make module reusable within a netif

    DHCP and AUTOIP both have ACD running simultaniously. The ACD
    struct is added to the DHCP and AUTOIP structs. In the netif a list
    of ACD modules is kept to loop over if functions need to perform
    some action on all ACD modules (for example tmr function). With
    acd_add a module can be added to the list. ACD_FOREACH loops over
    the list similar to NETIF_FOREACH.

commit ee3b4585b7768f5353dd80190a2929bad45f7ff4
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Mon Sep 10 16:36:18 2018 +0200

    etharp & acd: add probe and announce functions to etharp.

    The new probe and announce functions are independent of
    netif->ip_addr. This means we can keep the LL address working
    while we start to probe for the newly received routable address.
    The netif->ip_addr does not need to be any for probing to work
    with this patch.

commit 7d3032bae8f1b8081368a807682388eb642729e0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Mon Sep 3 13:35:51 2018 +0200

    autoip -> unused random function removed + small comment update

commit be749ba4eb26ddc69233c85d532dc035741275c5
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Fri Aug 31 16:37:36 2018 +0200

    ACD: update comment in header

commit 4491842991c90b3a58fa327f70aa42f04174546b
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Fri Aug 31 15:44:45 2018 +0200

    ACD: subscribe to link down messages to stop the acd process

    When the link goes down the acd process should be stopped
    independent of the acd client. Otherwise the acd will keep probing
    or announcing while their simply is no connection.

commit 71f668aa7583354e132c20b3b50ba2c86bf08738
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Fri Aug 31 13:59:44 2018 +0200

    DHCP coop autoip bug fix: wait after last discovery before starting autoip

    After the last dhcp discovery we need to give the dhcp server the
    time to respond. Currently the discovery message is send and autoip
    is started simultaniously. This is changed. Autoip will now be started
    after the next discovery timeout.

commit 0da16604ec079195533f2591f0d0f04bdf212a72
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Fri Aug 31 11:23:31 2018 +0200

    ACD: rate limit interval bug solved -> first decline then wait then restart.

    According the the ACD RFC we need to limit the rate of acquiring
    and probing addresses after MAX_CONFLICTS. It is important to first
    decline the address and stop the netif from using the address before
    the time is started. After this rate limit time, the address acquiring
    process can be started again.

    To make this possible we had to change the callback function and
    the location in the process were the rate limiting is done.

commit a89a0601a251acb14abe270116f38c6d25c2d7a9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Thu Aug 30 17:27:10 2018 +0200

    DHCP: after a succesful dhcp_reboot, the address should be probed.

    Reboot means that the connection was gone for some amount of time.
    This is seen as a new connection for the ACD module so should be
    the address should be probed before use.

commit 853afb448ba35c6e2b35e8238c9c367c599dece7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Thu Aug 30 17:19:12 2018 +0200

    DHCP_DOES_ARP_CHECK changed to DHCP_DOES_ACD_CHECK

    small update in opt.h to add the correct dependencies.

commit e28b4766bdef69e76f6170c470c93f5b251c579a
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Thu Aug 30 17:05:43 2018 +0200

    DHCP check code replaced by ACD module.

    when DHCP_DOES_ARP_CHECK is enabled, the ACD module will take care
    of address conflict detection. Via a call back function the DHCP
    state machine will continue and bind to an address if no conflicts
    are found.
    dhcp_arp_reply is obsolete because the ACD module replaces its
    function.

commit 52193a0f5d13e8786a4db2fff1f1a8f1367a4eba
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Mon Aug 27 16:05:22 2018 +0200

    Issue 2 + 3 from Comment #5, task #13508 solved

    Removed C++ comments and // ----... marks as requested.

commit 7faaf61275d67ccfb88ea7e26c249428c3088536
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Mon Aug 27 15:55:24 2018 +0200

    Issue 1 from Comment #5, task #13508 solved

    Comments added to clarify how arp messages are handled.

commit 9348aea22623b705759fd30b873f06a50a104d16
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Tue Jul 24 11:45:35 2018 +0200

    acd: add comment for callback function

commit 49fdd1177c05b74d49fa179564dcaa5e650adbcc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Tue Jul 24 11:42:59 2018 +0200

    autoip: Add debugging output and complete comments

commit 591856b82c029687a657a1b1ccc674522e6f4be0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Tue Jul 24 11:25:18 2018 +0200

    Removed autoip from timeouts.c

    We do not need a timer anymore. All timing is part of acd.

commit 3b3272fdd14015cfca0b3b6d149505b1cf0e36b6
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Tue Jul 24 11:22:32 2018 +0200

    autoip_network_changed -> first bring down the netif and then acd

    Make it do what it says in the comment

commit 77b0ccf96efd22774279c6f9b5bade18c5e42c59
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Tue Jul 24 11:21:23 2018 +0200

    Simplified the autoIP states + update autoip_start()

commit 96e0581d36857f8b70c4b4cce4fb323fd3dd51ab
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Tue Jul 24 11:10:48 2018 +0200

    Deleted unused variables, functions and defines from autoip module

    The functionality is now embedded in the acd module so can be
    removed from autoip.

commit 9296e2ebb4b51019aaccfc47e8b9f51b265d37cd
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Tue Jul 24 11:07:34 2018 +0200

    Bug fix acd -> rate limiting needs to be after MAX conflicts

    It was only after MAX conflicts + 1.

commit c55e16903c045d0ea84336b50eccbf24d3d097e9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Mon Jul 23 17:52:45 2018 +0200

    Small intruduction to module added

commit d1498a37293bd9f97f6b938b48e5980ab0a01bd1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Mon Jul 23 17:49:58 2018 +0200

    Copyright information added

    I based the copyright text on the other files. I'm not sure this
    is how its done. I kept Dominik in their because I copied quite
    some code from the autoip module.

commit 359a845ef5e73061832069f364b370634ee0b071
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Mon Jul 23 17:08:44 2018 +0200

    Fixing comments in acd.c

commit 100d72549d0ef44157143d031848a727f5dfbe69
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Mon Jul 23 15:43:40 2018 +0200

    Probe wait time and Probe interval time made random via lwip_rand

    According to the RFC a random amount of time needs to be waited
    before probing can be started also a random amount of time
    needs to be waited between the probes.
    The random time is calculated via the LWIP_RAND function (see
    lwipopts and sys_arch).

commit f7f037c32e9416f8b803c3c7af617b871b55ee35
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Tue Jul 17 16:56:48 2018 +0200

    autoip will start probing again when the network has changed

commit 1f40f6274195f24aa1b05caf82b79285ad189c2a
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Tue Jul 17 16:55:47 2018 +0200

    Duplicate code removed -> already present in autoip_start

commit be59431271da862a8ca330dbca638842c87765bc
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Tue Jul 17 16:52:49 2018 +0200

    add rate limiting to acd when too many conflicts are detected.

    When more then max conflicts are detected during device on time,
    the rate at which probing for a new address starts is limited.
    For clarity we combined the conflict counting and the callback into
    a new function acd_restart.

commit 91448455e95edb24c1f418c341b6fb306391f4f1
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Tue Jul 17 15:50:01 2018 +0200

    ARP packet conflict detection added.

    If a conflict is detected between the begin until after announce
    wait, a new address needs to be chosen immediatly.
    This can occur in two situations:
    1) another host already has this ip address
    2) another host is also probing for the same address.
    If a conflict is detected during announcing or during the ongoing
    conflict detection, we defend our ip address once. If a second
    conflict occurs during defend interval, we take another ip address.
    If not we can keep our address and connections.

    When a conflict occurs and it's decided we need a new address,
    autoip is simply restarted. To do: test if a acd stop is needed.
    This will become more important when DHCP is added I believe.

commit 65f47ba9444d8b9f767dc908319579323eeb8664
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Tue Jul 17 15:33:44 2018 +0200

    Update ACD state machine with PROBE_WAIT and and ANNOUNCE_WAIT

    By adding the ANNOUNCE_WAIT state, we could remove duplicate code
    that was present in the original autoip state implementation.
    But because we cannot directly go to ANNOUNCING we needed this
    extra state during the wait period. It also makes the different
    states clearer.
    Their is no need to number the enum because the compiler takes
    care of this standard numbering.
    Also a indent issue on the state machine code is solved here.

commit 2d9f4414c7b1f2ed35c0b5cea78dabb9c9afee77
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Tue Jul 17 15:28:33 2018 +0200

    Added an extra check for etharp responses.

    Their is no need to answer a request that is initiated by ourselves.
    In my test case, a conflicting request would be seen here as a
    request needing a reply. Which off course isn't needed at all.
    The acd module will let the requester know that it is using our
    ip address.
    I could not think of a reason not to add this extra check but please
    check if this doesn't break other functionality.

commit f84cc1dba4061219bd1aadb97bd340278db07cd7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Tue Jul 17 15:27:13 2018 +0200

    Redirect all incoming ARP messages to the ACD module.

    The ACD module will scan the packets and react on conflicts.
    autoip does not need the arp packets any more.

commit 9faf266993cc2df0b9434720b59b5922f17d7d33
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Tue Jul 17 10:08:39 2018 +0200

    Initiate acd from autoip implementation.

    The state machine in autoip is now replaced by the acd module.

commit 40a5a40d911c98e6ee8566c0adce7716f26f20e0
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Tue Jul 17 10:05:59 2018 +0200

    Add simple acd state machine to timer function.

    This state machine will be started from acd_start and will go
    through the probing and the announcing state. At this moment the
    timings are made fixed for easy debugging. Will be made variable
    afterwards.

commit 0a2629bf1f7942e80ec11bcc3e163ac1a2b9a580
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Tue Jul 17 09:44:19 2018 +0200

    Disable gratuitous ARP send from netif_issue_report when acd is enabled

    The acd module needs to be fully under control on what arp messages are
    send. It wouldn't be a clean solution if we kept this announce as one
    of the announce messages.
    So when ACD is enabled, this message will not be send.

commit a7b9a4d5039168723c2043677176c5c8fc69f8df
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Tue Jul 17 09:42:46 2018 +0200

    ARP probe and announce functions added.

    Both use etharp_requests to send out an arp message.

commit e2f1ce3fa84e2ce01bc944d8049412e156cd7cc7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Tue Jul 17 09:26:07 2018 +0200

    Add conflict callback mechanism to acd module

    When starting the acd with acd_start, a conflict callback has to be
    provided. After probing when no conflict is detected, the callback
    is called with the conflict variable on 0. From the moment a conflict
    is detected, it will be called set to 1.
    By not making a fixed link between acd, autoip and dhcp but working
    with callback functions the user (caller) can easily use it for
    fixed ip too. This keeps the acd module completely independent from
    the other application layer protocols.

commit 21e7995888d2941601e99873ee129d1ea927e3f7
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Mon Jul 16 14:41:52 2018 +0200

    acd_stop function added.

    When calling this function the acd state machine will be put in
    ACD_STATE_OFF. This will disable the acd functionality until
    acd_start is called.

commit 503037fb462504e46a14ce7486bc763dbc6a8690
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Mon Jul 16 14:35:48 2018 +0200

    acd_start function added

    This function will allocate a struct for the acd module if one wasn't
    added with acd_set_struct. It will then initialize the acd struct
    and start the probe wait timer (for now fixed).

commit e439f6dffc44e93078a2976783bdebfe17304d8c
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Mon Jul 16 14:22:39 2018 +0200

    ACD_DEBUG define added for enabling / disabling debug messages.

commit 80d33e1eaf092934ace1045fac096464cd5be5e9
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Mon Jul 16 11:39:37 2018 +0200

    ACD struct added together with set struct function

    ACD needs some variables: state, timing, probe counter etc.
    We added the struct as netif data. For now one ACD module per netif
    is enough. We found some unclarities about ACD with multiple IP
    address on one interface. For now, ACD will only be implemented for
    the IP address that is going to be used / is being used on the netif.

commit 2c4cca36744973318c3efe7cbae6384b52dc71a8
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Mon Jul 16 11:35:06 2018 +0200

    Add acd timer to timeouts.c with interval of 100ms.

    This timer will be used for time to wait counting etc.
    Very similar to the auto ip timer.

commit e2ed447e00c4df790df21509acb4ab09b5b79e66
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Fri Jul 13 16:56:39 2018 +0200

    Add ACD protocol definitions

commit 445733214460eae18817556439bed979e9b3747c
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Fri Jul 13 16:07:58 2018 +0200

    Add c++ option (to use C code module in c++)

commit 63d78bc1f77ac6698c3d663a1c67b40a0c297125
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Fri Jul 13 15:57:34 2018 +0200

    Added on off option for ACD module

commit d5ec4b69eb4175d4dd569bcfc80ae0e192780015
Author: Jasper Verschueren <jasper.verschueren@apart-audio.com>
Date:   Fri Jul 13 15:09:40 2018 +0200

    ACD IPv4 module files added

    The files for IPv4 ACD or Address Conflict Detection are added
    to the lwip source.
2018-10-04 17:34:44 +02:00
Simon Goldschmidt
164210ab73 fix mbedtls with msvc project files after merging contrib
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-03 15:13:57 +02:00
Martine Lenders
a47d30ffc7 lowpan6.c: Fix IEEE 802.15.4 address setting
Reverts a regression introduced in
3a8af612b3b818a89de5846cc9b046756af184cc:

Use hardware address fetched from neighbor cache *not* the hardware
address of the interface as destination address.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-03 14:38:58 +02:00
Simon Goldschmidt
a5c00e369d fix msvc project files after merging contrib
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-03 14:38:04 +02:00
Dirk Ziegelmeier
787a7bb919 Start creating a VSCode workspace 2018-10-02 20:50:37 +02:00
Dirk Ziegelmeier
730b3d3f86 Add contrib subdir to FILES 2018-10-02 13:15:41 +02:00
Dirk Ziegelmeier
0ef2514b6a Remove unmaintained contrib/ports/FILES 2018-10-02 13:08:12 +02:00
Dirk Ziegelmeier
7bd2c565e6 CMake: Make MBEDTLSDIR and WPDPACK_DIR (Win32) overridable 2018-10-02 13:06:01 +02:00
Dirk Ziegelmeier
04ff7926e7 CMake build system: It is now sufficient to set LWIP_DIR for build 2018-10-02 12:54:56 +02:00
Dirk Ziegelmeier
4b672a1f3c Adapt several comments to contrib rep move 2018-10-02 12:42:14 +02:00
Dirk Ziegelmeier
8068aab9f7 Commit new version info in doxygen file and init.h 2018-10-02 12:35:06 +02:00
Dirk Ziegelmeier
0244dc714b Work on fixing the build (integration of contrib) 2018-10-02 12:34:26 +02:00
Dirk Ziegelmeier
ac46e42aa2 Import lwIP contrib rep
... from http://git.savannah.gnu.org/cgit/lwip/lwip-contrib.git/ into contrib/ subdir, STABLE-2_1_0_RELEASE tag
lwIP contrib is now officially frozen
TODO: Fix build
2018-10-02 12:19:13 +02:00
Dirk Ziegelmeier
dd1ab2bf59 lwIP 2.2.0 development cycle start now 2018-09-30 09:02:15 +02:00
Simon Goldschmidt
e6a8415df3 Prepare 2.1.0 release
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-09-26 21:11:39 +02:00
Simon Goldschmidt
54a8112eb9 Documentation improvements for 2.1.0 (changelog, altcp) 2018-09-26 14:37:52 +02:00
Simon Goldschmidt
b9fc8cae68 Documentation improvements for 2.1.0 (mainly altcp/altcp_tls) 2018-09-24 22:44:32 +02:00
Simon Goldschmidt
a044c807f8 altcp_tls: rename altcp_tls_new -> altcp_tls_wrap, add altcp_tls_new
The new altcp_tls_new() is a type safe version of altcp_tls_alloc()

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-09-24 22:29:54 +02:00
Simon Goldschmidt
6229f9ef71 icmp_send_response: fix parameter order for LWIP_HOOK_IP4_ROUTE_SRC 2018-09-17 21:28:50 +02:00
Simon Goldschmidt
66838a70f3 more documentation preparations for v2.1.0 release 2018-09-17 21:16:58 +02:00
Simon Goldschmidt
dea74a24aa Fix CHANGELOG consistency from 2.0.3 branch to 2.1.0 2018-09-16 21:41:33 +02:00
Simon Goldschmidt
effdeef2fe some preparations for v2.1.0 release 2018-09-16 21:17:40 +02:00
Simon Goldschmidt
c18df357d9 some preparations for v2.1.0 release 2018-09-14 21:32:11 +02:00
Simon Goldschmidt
74c5ac7302 cpack: change file name of generated sources file
This should match the old release ZIPs: "lwip-x.y.z.zip"

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-09-13 21:54:58 +02:00
Simon Goldschmidt
0189e7b02f mqtt: allow user + pass longer than 255 chars
See bug #54655:
"MQTT brokers such as Google Cloud IoT Core requires MQTT clients
to send JSON Web Token (JWT) as password field of the MQTT Connect
packet. JWT can be more than 255 bytes.
Currently, the MQTT library restricts password to be less than 256
bytes, thus it prevents connectivity to Google Cloud IoT Core."

Fix that by just converting the local variables for these from u8_t
to u16_t.

Suggested-by: Richmond Umagat <richmond.umagat@brtchip.com>
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-09-13 14:59:08 +02:00
Dirk Ziegelmeier
796f98beb2 Fix no newline at end of http_client.c 2018-09-12 22:41:07 +02:00
Simon Goldschmidt
fc24d4139f altcp_tls_mbedtls: convert #error on too small TCP_WND to warning
Many TLS use cases are OK with a small TCP_WND, so don't prevent these
by having a preprocessor check that cannot be disabled.
2018-09-12 22:24:05 +02:00
Simon Goldschmidt
bbf80b05c8 ppp: fix implicit conversion from size_t to u8_t
Found when compiling with VS2017
2018-09-12 22:22:10 +02:00
Simon Goldschmidt
bc48eb512e Fix bug #54506 (LWIP_CHECKSUM_ON_COPY causes wrong checksum (0xFFFF))
one's complement sum was not correctly done, which could result in the
checksum being 0xFFFF instead of 0 in some cases.
2018-09-12 21:56:16 +02:00
Dirk Ziegelmeier
cdfa3dfa9d http_client.c: Fix compile when TCP is disabled 2018-09-12 08:27:43 +02:00
Dirk Ziegelmeier
be18fa98e4 Fix cleanup of existing documentation of target lwipdocs 2018-09-11 08:16:01 +02:00
Dirk Ziegelmeier
257dc1d6fd Fix doxygen warnings in altcp_proxyconnect.c 2018-09-10 13:30:50 +02:00
Dirk Ziegelmeier
236d6df495 Fix lwipdocs target in Filelists.cmake
EXCLUDE_FROM_ALL is not supported at add_custom_target()
2018-09-10 13:28:01 +02:00
Simon Goldschmidt
93b2074f2b Remove LWIP_DHCP_CHECK_LINK_UP define as it's useless
See bug #54574

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-09-07 21:01:32 +02:00
Simon Goldschmidt
7749088a83 Fix 2way-auth connections for TLS clients
TLS clients that need 2-way authentication (e.g. Amazon AWS IoT cloud mqtt)
need to pass a certificate and private key when creating the tls altcp_pcb.

Added a new function altcp_tls_create_config_client_2wayauth() for this that
replaces altcp_tls_create_config_client() for such clients.

See bug #54601.
2018-09-07 20:59:31 +02:00
Dirk Ziegelmeier
24fc93e12f Remove checks that the SO_* socket options and SOF_* lwIP-internal flags match
not needed any more since commit b0344518e82887057395f195fdf4d73384f15900
"sockets.c: Don't rely on #defines in socket.h to be in sync with ip.h
Map SO_* to SOF_* #defines"

Reported by Joan Lledó on mailinglist 6.Sep.2018
2018-09-07 10:01:59 +02:00
Martine Lenders
264b89764d Make zepif dependent on LWIP_UDP config
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-09-04 22:10:53 +02:00
Sylvain Rochet
fa3826a1d3 PPP: improve randomization of LCP magic number after power-up
magic_init() is first time called from ppp_init(), which is called from
lwip_init(). If system has no RTC, sys_jiffies() returns same value in
this moment after every power-up or system reset. This value used in LCP
magic number generation after ppp_connect(), which leads to same magic
number after every restart. Subsequent magic_randomize() calls takes
place in ppp_input(), after magic number generation.

Call magic_randomize() somewhere near start of ppp_connect() (and
ppp_listen()) as it might be called later at a random time.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2018-08-31 10:12:50 +02:00
Dirk Ziegelmeier
dac4cb05f7 Fix bug #54569: Compiler warning in ip4.c: unused parameter dest 2018-08-29 08:55:25 +02:00
Axel Lin
7b7bc349ae netif/lowpan6_ble: Fix comment for parameter order of ble_addr_to_eui64
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2018-08-19 22:47:43 +08:00
Axel Lin
bcd6c8a2d3 apps/sntp: Fix parameter name in doxygen comments
Make the parameter name in doxygen comments consistent wit the code.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2018-08-19 21:41:47 +08:00
Simon Goldschmidt
0674aa60fe sntp_getservername: fix parameter name in doxygen comments
Reported-by: Gisle Vanem <gisle.vanem@gmail.com>
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-08-18 20:23:24 +02:00
Dirk Ziegelmeier
e351937ea4 More cmake build system cleanups 2018-08-09 09:50:29 +02:00
Simon Goldschmidt
e8683ea9df api_lib: fix NETCONN_MBOX_WAITING_DEC() for LWIP_NETCONN_FULLDUPLEX
This was a copy & paste bug from ...INC()
2018-08-07 13:39:41 +02:00
Simon Goldschmidt
6363edc1db mqtt: fix reference function name in comment 2018-08-07 13:38:39 +02:00
Dirk Ziegelmeier
a19ea8b8d6 Cleanup CMAKE build system
Use target-specific commands for compile flags only
2018-08-06 13:05:35 +02:00
Dirk Ziegelmeier
aafc0adfe1 Fix bug #54381: SNMP RAW_DATA support is broken 2018-07-26 14:16:00 +02:00
Dirk Ziegelmeier
298951c738 Remove .clang-format for now, not sure if we are going to use it 2018-07-24 09:32:26 +02:00
Simon Goldschmidt
258cab1b22 fix bug #54315 (IPV6_V6ONLY socket accepts IPV4 connections)
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-07-23 21:47:33 +02:00
Simon Goldschmidt
c3d8b1ca80 add 'extern "C" {}' for cplusplus in ppp headers 2018-07-23 20:04:56 +02:00
Simon Goldschmidt
b5b31d86b2 fix dependencies in lwip/prot/dhcp.h and lwip/prot/igmp.h 2018-07-23 17:33:28 +02:00
Simon Goldschmidt
5bef7ea72f add 'extern "C" {}' for cplusplus in many headers 2018-07-19 22:05:43 +02:00
Simon Goldschmidt
633205ba78 fix bug #54254 (ppp/utils.c: use lwip_isdigit()) 2018-07-19 21:48:04 +02:00
Dirk Ziegelmeier
eeb2218b3d Revert "Test / RFC: Reformat a few files using clang-format"
This reverts commit 8b4a8159a898795ef0fc9226dae1ce66531ad487.

We do not want to do this shortly before a release. Reformatting (buggy reformatting) may introduce new bugs.
2018-07-18 08:34:01 +02:00
Dirk Ziegelmeier
0985e925a1 Fix bug #54327: V2.1.0rc1 pbuf.c misses stdint.h include
... without reformatting the document (clang-format)
2018-07-18 07:31:47 +02:00
Dirk Ziegelmeier
cffb5cc087 Revert "Fix bug #54327: V2.1.0rc1 pbuf.c misses stdint.h include"
This reverts commit 4e74421dac26f2646200b96d5f493982da522ef1.
2018-07-18 07:30:41 +02:00
Dirk Ziegelmeier
8b4a8159a8 Test / RFC: Reformat a few files using clang-format
Does it compile? Does it look good (enough)?
2018-07-17 21:15:48 +02:00
Dirk Ziegelmeier
4e74421dac Fix bug #54327: V2.1.0rc1 pbuf.c misses stdint.h include 2018-07-17 20:45:09 +02:00
Dirk Ziegelmeier
cd1dd4f5b1 Clang-format: Remove "AlignConsecutiveAssignments: true"
This seems to be "Dirk Ziegelmeier-Style" not lwIP-Style :-)
2018-07-16 11:00:23 +02:00
Dirk Ziegelmeier
8841fdc8ea Add .clang-format file that matches lwIP style "close enough" 2018-07-15 11:46:22 +02:00
Dirk Ziegelmeier
02d6716ffd Remove non-working astylerc 2018-07-15 10:24:13 +02:00
609 changed files with 76422 additions and 4764 deletions

6
.gitattributes vendored
View File

@ -2,3 +2,9 @@
*.txt text
*.c text
*.h text
# For git archive
.gitignore export-ignore
.gitattributes export-ignore
.github export-ignore
.vscode export-ignore

45
.github/workflows/ci-linux.yml vendored Normal file
View File

@ -0,0 +1,45 @@
name: CI
on:
push:
branches: [master]
pull_request:
branches: '*'
jobs:
build:
strategy:
matrix:
compiler: [gcc, clang]
env:
CC: ${{ matrix.compiler }}
LSAN_OPTIONS: verbosity=1:log_threads=1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install deps
run: sudo apt-get install check ninja-build doxygen
- name: Copy lwipcfg.h for example app
run: cp contrib/examples/example_app/lwipcfg.h.ci contrib/examples/example_app/lwipcfg.h
- name: Build unit tests with make
run: make -C contrib/ports/unix/check
- name: Run unit tests
run: make -C contrib/ports/unix/check check
- name: Run cmake
run: mkdir build && cd build && cmake .. -G Ninja
- name: Build with cmake
run: cd build && cmake --build .
- name: Build docs with cmake
run: cd build && cmake --build . --target lwipdocs
- name: Validate combinations of options
run: cd contrib/ports/unix/example_app && ./iteropts.sh
- name: Build the default example app
run: |
cp contrib/examples/example_app/lwipcfg.h.example contrib/examples/example_app/lwipcfg.h
make -C contrib/ports/unix/example_app TESTFLAGS="-Wno-documentation" -j 4

View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
sudo apt-get install check ninja-build doxygen
cp contrib/examples/example_app/lwipcfg.h.ci contrib/examples/example_app/lwipcfg.h
make -C contrib/ports/unix/check
mkdir build && cd build && cmake .. -G Ninja && cmake --build .

124
.github/workflows/codeql.yml vendored Normal file
View File

@ -0,0 +1,124 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ "master" ]
pull_request:
branches: '*'
jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
queries: security-and-quality
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
#- name: Autobuild
# uses: github/codeql-action/autobuild@v3
# Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
- run: |
./.github/workflows/codeql-buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
upload: false
id: step1
# Filter out rules with low severity or high false positve rate
# Also filter out warnings in third-party code
- name: Filter out unwanted errors and warnings
uses: advanced-security/filter-sarif@v1
with:
patterns: |
-**:cpp/path-injection
-**:cpp/world-writable-file-creation
-**:cpp/poorly-documented-function
-**:cpp/potentially-dangerous-function
-**:cpp/use-of-goto
-**:cpp/integer-multiplication-cast-to-long
-**:cpp/comparison-with-wider-type
-**:cpp/leap-year/*
-**:cpp/ambiguously-signed-bit-field
-**:cpp/suspicious-pointer-scaling
-**:cpp/suspicious-pointer-scaling-void
-**:cpp/unsigned-comparison-zero
-**/cmake*/Modules/**
input: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
- name: Upload CodeQL results to code scanning
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ steps.step1.outputs.sarif-output }}
category: "/language:${{matrix.language}}"
- name: Upload CodeQL results as an artifact
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: codeql-results
path: ${{ steps.step1.outputs.sarif-output }}
retention-days: 5
- name: Fail if an error is found
run: |
./.github/workflows/fail_on_error.py \
${{ steps.step1.outputs.sarif-output }}/cpp.sarif

34
.github/workflows/fail_on_error.py vendored Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/env python3
import json
import sys
# Return whether SARIF file contains error-level results
def codeql_sarif_contain_error(filename):
with open(filename, 'r') as f:
s = json.load(f)
for run in s.get('runs', []):
rules_metadata = run['tool']['driver']['rules']
if not rules_metadata:
rules_metadata = run['tool']['extensions'][0]['rules']
for res in run.get('results', []):
if 'ruleIndex' in res:
rule_index = res['ruleIndex']
elif 'rule' in res and 'index' in res['rule']:
rule_index = res['rule']['index']
else:
continue
try:
rule_level = rules_metadata[rule_index]['defaultConfiguration']['level']
except IndexError as e:
print(e, rule_index, len(rules_metadata))
else:
if rule_level == 'error':
return True
return False
if __name__ == "__main__":
if codeql_sarif_contain_error(sys.argv[1]):
sys.exit(1)

74
.gitignore vendored
View File

@ -1,19 +1,67 @@
*.o
*.so
*.a
*.exe
*lwip_unittests.xml
*.suo
*.swp
*.log
.depend*
/.vscode/ipch
/doc/doxygen/output/html
/src/apps/snmp/LwipMibCompiler/CCodeGeneration/bin/
/src/apps/snmp/LwipMibCompiler/CCodeGeneration/obj/
/src/apps/snmp/LwipMibCompiler/LwipMibCompiler/bin/
/src/apps/snmp/LwipMibCompiler/LwipMibCompiler/obj/
/src/apps/snmp/LwipMibCompiler/MibViewer/bin/
/src/apps/snmp/LwipMibCompiler/MibViewer/obj/
/src/apps/snmp/LwipMibCompiler/LwipSnmpCodeGeneration/bin/
/src/apps/snmp/LwipMibCompiler/LwipSnmpCodeGeneration/obj/
/src/apps/snmp/LwipMibCompiler/SharpSnmpLib/bin/
/src/apps/snmp/LwipMibCompiler/SharpSnmpLib/obj/
/src/apps/snmp/LwipMibCompiler/LwipMibCompiler.userprefs
/src/apps/snmp/LwipMibCompiler/*.suo
/test/fuzz/output
/test/fuzz/lwip_fuzz
/test/fuzz/lwip_fuzz2
/test/fuzz/lwip_fuzz3
/test/fuzz/.depend
/build
/build
/contrib/examples/example_app/lwipcfg.h
/contrib/examples/example_app/lwipopts_test.h
/contrib/ports/unix/example_app/build
/contrib/ports/unix/example_app/example_app
/contrib/ports/unix/example_app/makefsdata
/contrib/ports/unix/check/build
/contrib/ports/unix/lib/build
/contrib/ports/unix/check/lwip_unittests
/contrib/ports/win32/example_app/build
/contrib/ports/win32/lwipcfg_msvc.h
/contrib/ports/win32/msvc/Debug
/contrib/ports/win32/msvc/Debug unittests
/contrib/ports/win32/msvc/Debug fuzz
/contrib/ports/win32/msvc/Debug fuzz2
/contrib/ports/win32/msvc/Debug fuzz3
/contrib/ports/win32/msvc/Release
/contrib/ports/win32/msvc/Release unittests
/contrib/ports/win32/msvc/Release fuzz
/contrib/ports/win32/msvc/Release fuzz2
/contrib/ports/win32/msvc/x64
/contrib/ports/win32/msvc/*.user
/contrib/ports/win32/msvc/*.ncb
/contrib/ports/win32/msvc/*.cache
/contrib/ports/win32/msvc/*.suo
/contrib/ports/win32/msvc/ipch
/contrib/ports/win32/msvc/*.opensdf
/contrib/ports/win32/msvc/*.sdf
/contrib/ports/win32/mingw/*.map
/contrib/ports/win32/mingw/cov-int
/contrib/ports/win32/msvc/.vs
/contrib/apps/LwipMibCompiler/.vs
/contrib/apps/LwipMibCompiler/CCodeGeneration/bin
/contrib/apps/LwipMibCompiler/CCodeGeneration/obj
/contrib/apps/LwipMibCompiler/LwipMibCompiler/bin
/contrib/apps/LwipMibCompiler/LwipMibCompiler/obj
/contrib/apps/LwipMibCompiler/LwipSnmpCodeGeneration/bin
/contrib/apps/LwipMibCompiler/LwipSnmpCodeGeneration/obj
/contrib/apps/LwipMibCompiler/MibViewer/bin
/contrib/apps/LwipMibCompiler/MibViewer/obj
/contrib/apps/LwipMibCompiler/SharpSnmpLib/bin
/contrib/apps/LwipMibCompiler/SharpSnmpLib/obj

28
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,28 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/src/include",
"${workspaceFolder}/contrib",
"${workspaceFolder}/contrib/examples/example_app",
"${workspaceFolder}/contrib/ports/unix/port/include",
"${workspaceFolder}/contrib/ports/unix/example_app"
],
"defines": [],
"intelliSenseMode": "gcc-x64",
"browse": {
"path": [
"${workspaceFolder}/**"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"configurationProvider": "vector-of-bool.cmake-tools"
}
],
"version": 4
}

62
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,62 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch example_app",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": true,
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"preLaunchTask": "Build example_app",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"linux": {
"cwd": "${workspaceFolder}/build/contrib/ports/unix/example_app",
"program": "${workspaceFolder}/build/contrib/ports/unix/example_app/example_app",
},
"windows": {
"cwd": "${workspaceFolder}/build/contrib/ports/win32/example_app",
"program": "${workspaceFolder}/build/contrib/ports/win32/example_app/example_app",
"miDebuggerPath": "gdb.exe",
}
},
{
"name": "(gdb) Launch unit tests",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": true,
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"preLaunchTask": "Build unit tests",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"linux": {
"cwd": "${workspaceFolder}/contrib/ports/unix/check/build",
"program": "${workspaceFolder}/contrib/ports/unix/check/build/lwip_unittests",
},
"windows": {
"cwd": "${workspaceFolder}/contrib/ports/win32/check/build",
"program": "${workspaceFolder}/contrib/ports/win32/check/build/lwip_unittests",
"miDebuggerPath": "gdb.exe",
}
}
]
}

10
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,10 @@
{
"editor.tabSize": 2,
"editor.insertSpaces": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"files.associations": {
"*.h": "c"
}
}

54
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,54 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build example_app",
"type": "shell",
"options": {
"cwd": "${workspaceFolder}/build"
},
"problemMatcher": "$gcc",
"group": {
"kind": "build",
"isDefault": true
},
"command": "cmake --build ."
},
{
"label": "Build unit tests",
"type": "shell",
"problemMatcher": "$gcc",
"group": "build",
"linux": {
"options": {
"cwd": "${workspaceFolder}/contrib/ports/unix/check/build"
},
},
"windows": {
"options": {
"cwd": "${workspaceFolder}/contrib/ports/win32/check/build"
},
},
"command": "cmake --build ."
},
{
"label": "Configure example_app",
"type": "shell",
"problemMatcher": "$gcc",
"group": "build",
"command": "cd ${workspaceFolder}; mkdir build; cd build; cmake .."
},
{
"label": "Generate documentation",
"type": "shell",
"problemMatcher": [],
"group": "none",
"options": {
"cwd": "${workspaceFolder}/build"
},
"command": "cmake --build . --target lwipdocs"
}
]
}

119
BUILDING Normal file
View File

@ -0,0 +1,119 @@
Building lwIP
=============
lwIP uses a CMake based build system.
The CMake files in this project are designed to
be included into your own CMake files. They are
mainly variable definitions containing a list of
source files and predefined static libraries to
be linked against application code.
1) lwIP sources:
src/Filelists.cmake provides file lists containing
the lwIP core library.
The file also contains two static libraries, lwipcore
and lwipallapps, where you can link your app against.
This is the file that is useful to all lwIP users.
2) Example applications:
contrib/Filelists.cmake provides several file lists
containing the example applications.
The file also contains several static libraries
for these example apps.
This file is only useful for you, if you can use one
of the examples in your application, which is normally
not the case.
3) OS/platform port:
Usually the OS port needs to be provided by the user.
If a port to Linux, Windows or MacOS is useful for
you, you can use
contrib/ports/{win32, unix}/Filelists.cmake
that contains file lists and libraries for
these operating systems.
VARIABLES
=========
In all cases, you need to provide two variables.
"LWIP_DIR" pointing to the lwIP directory
Example:
set(LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/externals/lwip)
"LWIP_INCLUDE_DIRS" that contains the include base paths
- for lwIP itself (${LWIP_DIR}/src/include)
- for lwIP contrib if you use it (${LWIP_DIR}/contrib)
- to a directory containing an OS port
- to a directory containing lwipopts.h
Example:
set (LWIP_INCLUDE_DIRS
"${LWIP_DIR}/src/include"
"${LWIP_DIR}/contrib"
"${LWIP_DIR}/contrib/ports/unix/port/include"
"${LWIP_DIR}/contrib/examples/example_app"
)
Putting it all together
=======================
To get a working application, your CMake system
needs to provide the variables described above, e.g.
set (LWIP_DIR <path to lwip sources>)
set (LWIP_INCLUDE_DIRS
"${LWIP_DIR}/src/include"
"${LWIP_DIR}/contrib"
"<path to my port>/include"
"<path to lwipopts.h>"
)
You may add some defines:
set (LWIP_DEFINITIONS LWIP_DEBUG=1)
Then include the filelists you need:
include(${LWIP_DIR}/src/Filelists.cmake)
include(${LWIP_DIR}/contrib/Filelists.cmake)
Then, declare you executable:
add_executable(my_app <my source files> <my lwip port files>)
Add lwIP include dirs to your app:
target_include_directories(my_app PRIVATE ${LWIP_INCLUDE_DIRS})
Link your app against the lwIP libs from the filelists you need:
target_link_libraries(my_app lwipcontribapps lwipallapps lwipcore)
Working example
===============
Working build examples can be found in the
contrib/ports/{win32, unix}/example_app
subdirectory.
To use them, create a build directory and call cmake with
the lwIP root dir:
- mkdir build
- cd build
- cmake ..
- cmake --build .
The CMakeLists.txt will autoselect the correct port
for your system (supported: Linux, Windows, Darwin).
To configure the example app to your needs, you need to copy the file
contrib/examples/example_app/lwipcfg.h.example
to
contrib/examples/example_app/lwipcfg.h
and edit to your needs.
Makefile based build system
===========================
lwIP also maintains file lists for Makefile-based
build systems. Look for Filelists.mk files
in the source tree. We try to maintain them,
but lwIP's mainly focused build system is CMake.
MS Visual Studio
================
lwIP also provides basic support for MSVS in the win32 port
folder under 'msvc'. We try to maintain these files,
but lwIP's mainly focused build system is CMake.

478
CHANGELOG
View File

@ -1,10 +1,253 @@
HISTORY
* These are only the most important changes. For a full list, use git log:
http://git.savannah.nongnu.org/cgit/lwip.git
(git master)
* [Enter new changes just after this line - do not remove this line]
++ Bugfixes:
2025-06-03: Simon Goldschmidt
* ip4_frag/ip6_frag: fix potential NULL-pointer access on memory errors
(STABLE-2.2.1):
++ New features:
2023-10-11: Faidon Liambotis
* Add MEM_CUSTOM_ALLOCATOR and make LIBC a subset of it
2023-09-29: Jiri Findejs
* mqtt: support binary Will Message
++ Bugfixes:
2024-02-19: Simon Goldschmidt
* tcpip: fix that TCPIP_CORE_LOCK is not released for LWIP_TIMERS==0
2024-01-09: Simon Goldschmidt
* snmp v3, ppp: prevent possible timing attacks by using a constant-runtime-memcmp when
checking credentials
2023-01-04: Simon Goldschmidt
* makefsdata: update tinydir.h to newest version (1.2.6)
2023-10-12: Borys Szefler
* dhcp: fix memory corruption when LWIP_DHCP_MAX_DNS_SERVERS > DNS_MAX_SERVERS
2023-10-11: Mazakazu
* sockets: fix socket leak when using setsockopt/getsockopt hook with LWIP_NETCONN_FULLDUPLEX==1
2023-10-10: Simon Goldschmidt
* sockets: fix bug #63898: allow socket option IPV6_CHECKSUM for both IPPROTO_IPV6 and IPPROTO_RAW
2023-10-10: Simon Goldschmidt
* ipv6: fix ip6_current_header() after reassembly
2023-10-07: Simon Goldschmidt
* ipv6 reassembly: fix detecting holes in reassembled packets
2023-10-04: Simon Goldschmidt
* apps: http client: improve the HTTP client; ensure connection settings are passed
2023-10-03: Simon Goldschmidt
* ipv6: frag: fix bogus icmp6 response on reassembly timeout
2023-09-28: Szabolcs Szekelyi
* httpd: ensure headers are parsed case-insensitive
2023-09-28: Erik Ekman
* Fix ND6 Router Advertisement parsing when NETIF_MAX_HWADDR_LEN is above 6.
2023-09-27: Hardy Griech
* Fix iperf byte counting mode
(STABLE-2.2.0):
2018-10-02: Dirk Ziegelmeier
* Integrate contrib repository into main lwIP repository
++ New features:
2022-04-05: David Cermak
* contrib/addons: Add example of using DHCP extra options hooks
2023-05-11: David Cermak
* dhcp: Add macro for appending extra client's request options
2023-05-11: xueyunfei
* dhcp: Enable custom config for timeouts, thresholds, backoff time
2021-04-26
* test/unit: added more unit tests
2020-03-27: Simon Goldschmidt
* test/fuzz: improve fuzz test
2019-12-11: Simon Goldschmidt
* ip6addr_aton: support scoped address strings (via '%')
2019-08-28: Joan Lledó
* Contrib: Add kFreeBSD to the Unix port
2019-07-14: Joan Lledó
* Unix port: improve support for the Hurd
++ Bugfixes:
2019-12-11: David Girault
* altcp_tls: support for saving/restoring session information
2018-11-16: Craig McQUeen
* dns: allow a DNS look-up with a trailing dot in the name
2018-10-19: Timmy Brolin
* Add outgoing VLAN PCP support for Ethernet level QoS
2018-10-08: Ben Wijen
* apps/tftp: added TFTP client
2018-10-04: Jasper Verschueren
* Implement IPv4 ACD (Address Conflict Detection)
2023-05-10
* altcp_tls_mbedtls: note which version of mbedtls we are compatible to
* altcp_tls_mbedtls: multiple compatibility fixes
2023-04-26: Jan Breuer, Harrold Spier, Ognjen Bjelica, Dirk Ziegelmeier, Simon Goldschmidt
* apps/snmp: multiple fixes and improvements to snmp
2022-01-12: Simon Goldschmidt
* httpd: clean up custom file handling
2021-11-25: quanjia
* ping: fix sockaddr len in ping_send() for PING_USE_SOCKETS==1
2021-11-12: Bas Prins
* http_client: reset timeout when receiving data
2020-07-07: Erik Ekman
* Rename IP and Ethernet equality checkers from _cmp to _eq
2020-03-05: Simon Goldschmidt
* tcp: tighten up checks for received SYN
2020-01-30: Simon Goldschmidt, David Girault, David J. Fiddes, Tom Ferrin
* apps/sntp: multiple fixes and improvements for sntp
2020-01-30: Simon Goldschmidt
* ip_forward: fix IPv4 forwarding with multiple netifs/offloading
2019-06-11: David Girault, Giuseppe Modugno
* apps/mqtt: multiple fixes for mqtt
2019-05-19: Joan Lledó
* New function tcpip_callback_wait()
Call a function inside the tcpip thread and block the calling thread until
the callback finishes
2018-08-15: Jasper Verschueren, David Girault, Our Air Quality
* apps/mdns: greatly improved the mdns client
(STABLE-2.1.2):
++ Bugfixes:
2018-11-21: Jens Nielsen
* netbiosns.c: fix expecting too large packet (bug #55069)
2018-11-19: Dirk Ziegelmeier
* smtp.c: fix compiling with strict C compatibility because of strnlen (bug #55034)
2018-11-12: Simon Goldschmidt
* tcp.c: fix overflow check in tcp_recved triggering invalid assertion (bug #55015)
2018-11-12: Simon Goldschmidt
* tcp.c: fix a bug in sending RST segments (sent from port 0)
(STABLE-2.1.1):
++ Bugfixes:
2018-11-01: Joan Lledó
* sockets.c: fix bad assertion in lwip_poll_dec_sockets_used() (bug #54933)
2018-11-01: Dirk Ziegelmeier
* ip4.c: don't send 127.* to default netif (bug #54670)
2018-10-23: David Girault
* altcp_tls_mbedtls.c: fix use-after free (bug #54774)
2018-10-23: Ognjen Bjelica, Dirk Ziegelmeier
* snmp_scalar.c: Avoid NULL pointer dereference (bug #54886)
2018-10-23: Simon Goldschmidt
* Fix missing standard includes in multiple files
2018-10-17: Ivan Warren
* def.h: fix casting htonX and ntohX to u16_t (bug #54850)
2018-10-12: Simon Goldschmidt
* Revert "tcp_abandon: no need to buffer pcb->local_port" (fix that source port was 0 for RST
called when aborting a connection)
2018-10-11: Jonas Rabenstein
* tcp.c: tcp_recved: check for overflow and warn about too big values (patch #9699)
2018-10-06: Joan Lledó
* sockets.c: alloc_socket(): Check for LWIP_SOCKET_POLL when setting select-
related variables (patch #9696)
2018-10-04: Spencer
* tcp.c: Update prev pointer when skipping entries in tcp_slowtmr (patch #9694)
2018-09-27: Martine Lenders
* lowpan6.c: Fix IEEE 802.15.4 address setting (bug #54749)
(STABLE-2.1.0):
++ New features:
2018-06-17: Simon Goldschmidt
* lwiperf: implemented iPerf client mode
2018-04-23: Dirk Ziegelmeier
* added cmake build files
2018-03-04: Ray Abram
* netbios responder: respond to '*' queries
2018-02-23: Benjamin Aigner
* 6lowpan: add 6lowpan-over-BLE netif (based on existing 6lowpan netif)
2018-02-22: Simon Goldschmidt
* ipv6: add support for stateless DHCPv6 (to get DNS servers in SLAAC nets)
2018-02-16: Simon Goldschmidt
* add raw API http(s) client (with proxy support)
2018-02-01: Simon Goldschmidt
* tcp: add hooks to implement additional socket options
2018-02-01: Simon Goldschmidt
* tcp: add hooks to implement tcp md5 signatures or similar (see contrib/addons for an example)
2018-01-05: Simon Goldschmidt
* Added sys_mbox_trypost_fromisr() and tcpip_callbackmsg_trycallback_fromisr()
These can be used to post preallocated messages from an ISR to the tcpip thread
(e.g. when using FreeRTOS)
2018-01-02: Dirk Ziegelmeier
* task #14780: Add debug helper asserts to ensure threading/locking requirements are met
2017-11-21: Simon Goldschmidt
* task #14600: tcp_alloc(): kill TF_CLOSEPEND connections before other ESTABLISHED
2017-11-21: Simon Goldschmidt
* makefsdata: added option "-ssi:<filename>" to control SSI tag checking/insertion
through a list of filenames, not by checking the file extension at runtime
2017-11-20: Joel Cunningham
* netconn: add LWIP_HOOK_NETCONN_EXTERNAL_RESOLVE to use external DNS resolver (patch #9427)
@ -44,7 +287,7 @@ HISTORY
* dhcp: added two hooks for adding and parsing user defined DHCP options
2017-04-25: Joel Cunningham
* sockets: added CMSG and IP_PKTINFO for use with recvmsg (task #14247)
* sockets: added recvmsg for UDP (together with CMSG and IP_PKTINFO) (task #14247)
2017-04-20: Joel Cunningham
* tcp: added Appropriate Byte Counting support (task #14128)
@ -53,6 +296,13 @@ HISTORY
* netconn/sockets: remove fatal error handling, fix asynchronous error handling,
ensure data before RST can be received
2017-03-30: Simon Goldschmidt
* added "application layered TCP" connection API (altcp) for seamless integration
of TLS or proxy connections
2017-03-09: Simon Goldschmidt
* sockets: add recvmsg for TCP
2017-03-02: Joel Cunningham
* netconn/sockets: vectorize netconn_write for TCP, treating a vectored I/O write
atomically in regards to TCP segmentation (patch #8882)
@ -63,21 +313,15 @@ HISTORY
2017-02-28: Simon Goldschmidt
* Added LWIP_SINGLE_NETIF for small targets with only one netif
2017-02-17: Simon Goldschmidt
* Improved DNS_LOCAL_HOSTLIST interface
2017-02-10: David van Moolenbroek
* Implement UDP and RAW multicast support for IPv6 (core API, not netconn/sockets)
2017-02-10: Simon Goldschmidt
* tcp_close does not fail on memory error (instead, FIN is sent from tcp_tmr)
2017-02-04: David van Moolenbroek
- IPv6 scopes support
* IPv6 scopes support
2017-01-20: Joel Cunningham
* sockets: add interface name/index APIs (task #14314)
2017-01-08: David van Moolenbroek
* Extensions to RAW API (patch #9208)
- Connected RAW PCBs
@ -86,6 +330,34 @@ HISTORY
++ Bugfixes:
2018-06-19: Simon Goldschmidt
* tcp: fix RTO timer not working if link is down
2018-06-15: Sylvain Rochet
* ppp: multiple smaller bugfixes
2018-05-17: Simon Goldschmidt
* etharp: arp table can now be bigger than 127 entries
2018-04-25: Jens Nielsen
* tftp server: correctly handle retransmissions
2018-04-18: Simon Goldschmidt
sockets: fix race conditions when closing full-duplex sockets
2018-03-09: Simon Goldschmidt
* 6lowpan: fix to work against contiki; added ZigBee encapsulation netif for tests
2018-02-04: Simon Goldschmidt
* sockets: fix inconsistencies on close (inconsistent error codes, double FIN)
2018-01-05: Dirk Ziegelmeier
* Fix bug #52748: the bug in timeouts.c by reimplementing timer logic to use
absolute instead of relative timeout values
2017-12-31: Dirk Ziegelmeier
* Fix bug #52704: DHCP and bad OFFER: Stop timeout only if offer is accepted
2017-11-08: Joel Cunningham
* netif: ensure link and admin states are up in issue reports (bug #52353)
@ -120,8 +392,50 @@ HISTORY
* sockets.c: task #14420 (Remove sys_sem_signal from inside SYS_ARCH_PROTECT
crit section) done for LWIP_TCPIP_CORE_LOCKING==1
2017-02-24: Simon Goldschmidt
* sockets.c: fixed close race conditions in lwip_select (for LWIP_NETCONN_FULLDUPLEX)
2017-02-24: Simon Goldschmidt
* sockets.c: fixed that select ignored invalid/not open sockets in the fd_sets (bug #50392)
2017-01-11: David van Moolenbroek
* Lots of IPv6 related fixes and improvements
(STABLE-2.0.3)
++ Bugfixes:
2017-09-11: Simon Goldschmidt
* tcp_in.c: fix bug #51937 (leaking tcp_pcbs on passive close with unacked data)
2017-08-02: Abroz Bizjak/Simon Goldschmidt
* multiple fixes in IPv4 reassembly (leading to corrupted datagrams received)
2017-03-30: Simon Goldschmidt
* dhcp.c: return ERR_VAL instead of asserting on offset-out-of-pbuf
2017-03-23: Dirk Ziegelmeier
* dhcp.h: fix bug #50618 (dhcp_remove_struct() macro does not work)
(STABLE-2.0.2)
++ New features:
2017-02-10: Dirk Ziegelmeier
* Implement task #14367: Hooks need a better place to be defined:
We now have a #define for a header file name that is #included in every .c
file that provides hooks.
2017-02-10: Simon Goldschmidt
* tcp_close does not fail on memory error (instead, FIN is sent from tcp_tmr)
++ Bugfixes:
2017-03-08
* tcp: do not keep sending SYNs when getting ACKs
2017-03-08: Joel Cunningham
* tcp: initialize ssthresh to TCP_SND_BUF (bug #50476)
* tcp: Initialize ssthresh to TCP_SND_BUF (bug #50476)
2017-03-01: Simon Goldschmidt
* httpd: LWIP_HTTPD_POST_MANUAL_WND: fixed double-free when httpd_post_data_recved
@ -130,23 +444,57 @@ HISTORY
2017-02-28: David van Moolenbroek/Simon Goldschmidt
* tcp: fixed bug #50418: LWIP_EVENT_API: fix invalid calbacks for SYN_RCVD pcb
2017-02-24: Simon Goldschmidt
* sockets.c: fixed close race conditions in lwip_select (for LWIP_NETCONN_FULLDUPLEX)
2017-02-24: Simon Goldschmidt
* sockets.c: fixed that select ignored invalid/not open sockets in the fd_sets (bug #50392)
2017-02-17: Simon Goldschmidt
* dns: Improved DNS_LOCAL_HOSTLIST interface (bug #50325)
2017-02-16: Simon Goldschmidt
* LWIP_NETCONN_FULLDUPLEX: fixed shutdown during write (bug #50274)
2017-02-13: Simon Goldschmidt/Dirk Ziegelmeier
* For tiny targtes, LWIP_RAND is optional (fix compile time checks)
2017-02-10: Simon Goldschmidt
* tcp: Fixed bug #47485 (tcp_close() should not fail on memory error) by retrying
to send FIN from tcp_fasttmr
2017-02-09: Simon Goldschmidt
* sockets: Fixed bug #44032 (LWIP_NETCONN_FULLDUPLEX: select might work on
invalid/reused socket) by not allowing to reallocate a socket that has
"select_waiting != 0"
2017-02-09: Simon Goldschmidt
* httpd: Fixed bug #50059 (httpd LWIP_HTTPD_SUPPORT_11_KEEPALIVE vs.
LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED)
2017-02-08: Dirk Ziegelmeier
* Rename "IPv6 mapped IPv4 addresses" to their correct name from RFC4191:
"IPv4-mapped IPv6 address"
2017-02-08: Luc Revardel
* mld6.c: Fix bug #50220 (mld6_leavegroup does not send ICMP6_TYPE_MLD, even
if last reporter)
2017-02-08: David van Moolenbroek
* ip6.c: Patch #9250: fix source substitution in ip6_output_if()
2017-02-08: Simon Goldschmidt
* tcp_out.c: Fixed bug #50090 (last_unsent->oversize_left can become wrong value
in tcp_write error path)
2017-02-02: Dirk Ziegelmeier
* Fix bug #50206: UDP Netconn bind to IP6_ADDR_ANY fails
2017-01-18: Dirk Ziegelmeier
* Fix zero-copy RX, see bug bug #50064. PBUF_REFs were not supported as ARP requests.
2017-01-11: David van Moolenbroek
* Lots of IPv6 related fixes and improvements
2017-01-15: Axel Lin, Dirk Ziegelmeier
* minor bug fixes in mqtt
2017-01-11: Knut Andre Tidemann
* sockets/netconn: fix broken default ICMPv6 handling of checksums
(STABLE-2.0.1)
++ New features:
2016-12-31: Simon Goldschmidt
@ -186,7 +534,7 @@ HISTORY
2016-12-05: Dirk Ziegelmeier
* fixed compiling with IPv4 disabled (IPv6 only case)
2016-11-28: Simon Goldschmidt
* api_lib.c: fixed bug #49725 (send-timeout: netconn_write() can return
ERR_OK without all bytes being written)
@ -207,7 +555,7 @@ HISTORY
2016-11-14: Joel Cunningham
* tcp_out.c: fixed bug #49533 (start persist timer when unsent seg can't fit
in window)
in window)
2016-11-16: Roberto Barbieri Carrera
* autoip.c: fixed bug #49610 (sometimes AutoIP fails to reuse the same address)
@ -215,7 +563,7 @@ HISTORY
2016-11-11: Dirk Ziegelmeier
* sockets.c: fixed bug #49578 (dropping multicast membership does not work
with LWIP_SOCKET_OFFSET)
(STABLE-2.0.0)
++ New features:
@ -482,7 +830,7 @@ HISTORY
implementation which is under a BSD-ish license.
- Also switched to PolarSSL MD4,MD5,SHA1 implementations, which are meant to be
used in embedded devices with reduced memory footprint.
- Removed PPP configuration file parsing support.
- Removed PPP configuration file parsing support.
- Added macro definition EAP_SUPPORT to make EAP support optional.
- Added macro definition CHAP_SUPPORT to make CHAP support optional.
- Added macro definition MSCHAP_SUPPORT to make MSCHAP support optional.
@ -1014,7 +1362,7 @@ HISTORY
2012-03-25: Simon Goldschmidt (idea by Mason)
* posix/*: added posix-compatibility include files posix/netdb.h and posix/sys/socket.h
which are a simple wrapper to the correct lwIP include files.
2012-01-16: Simon Goldschmidt
* opt.h, icmp.c: Added option CHECKSUM_GEN_ICMP
@ -1096,10 +1444,10 @@ HISTORY
2012-03-22: Simon Goldschmidt
* ip4.c: fixed bug #35927: missing refragmentaion in ip_forward
2012-03-20: Simon Goldschmidt (patch by Mason)
* netdb.c: fixed bug #35907: lwip_gethostbyname_r returns an invalid h_addr_list
2012-03-12: Simon Goldschmidt (patch by Bostjan Meglic)
* ppp.c: fixed bug #35809: PPP GetMask(): Compiler warning on big endian,
possible bug on little endian system
@ -1554,7 +1902,7 @@ HISTORY
2011-03-27: Simon Goldschmidt
* sockets.c: Fixed bug #32906: lwip_connect+lwip_send did not work for udp and
raw pcbs with LWIP_TCPIP_CORE_LOCKING==1.
2011-03-27: Simon Goldschmidt
* tcp_out.c: Fixed bug #32820 (Outgoing TCP connections created before route
is present never times out) by starting retransmission timer before checking
@ -1607,7 +1955,7 @@ HISTORY
2010-11-23: Simon Goldschmidt
* tcp_in.c: Fixed bug #30577: tcp_input: don't discard ACK-only packets after
refusing 'refused_data' again.
2010-11-22: Simon Goldschmidt
* sockets.c: Fixed bug #31590: getsockopt(... SO_ERROR ...) gives EINPROGRESS
after a successful nonblocking connection.
@ -1652,21 +2000,21 @@ HISTORY
2010-08-01: Simon Goldschmidt (patch by Greg Renda)
* ppp.c: Applied patch #7264 (PPP protocols are rejected incorrectly on big
endian architectures)
2010-07-28: Simon Goldschmidt
* api_lib.c, api_msg.c, sockets.c, mib2.c: Fixed compilation with TCP or UDP
disabled.
2010-07-27: Simon Goldschmidt
* tcp.c: Fixed bug #30565 (tcp_connect() check bound list): that check did no
harm but never did anything
2010-07-21: Simon Goldschmidt
* ip.c: Fixed invalid fix for bug #30402 (CHECKSUM_GEN_IP_INLINE does not
add IP options)
2010-07-16: Kieran Mansley
* msg_in.c: Fixed SNMP ASN constant defines to not use ! operator
* msg_in.c: Fixed SNMP ASN constant defines to not use ! operator
2010-07-10: Simon Goldschmidt
* ip.c: Fixed bug #30402: CHECKSUM_GEN_IP_INLINE does not add IP options
@ -1770,7 +2118,7 @@ HISTORY
2010-03-05: Simon Goldschmidt
* api_msg.c: Correctly set TCP_WRITE_FLAG_MORE when netconn_write is split
into multiple calls to tcp_write.
into multiple calls to tcp_write.
2010-02-21: Simon Goldschmidt
* opt.h, mem.h, dns.c: task #10140: Remove DNS_USES_STATIC_BUF (keep
@ -2230,7 +2578,7 @@ HISTORY
sent to mbox
2009-06-25 Kieran Mansley
* api_msg.c api.h: BUG26722: initialise netconn write variables
* api_msg.c api.h: BUG26722: initialise netconn write variables
in netconn_alloc
2009-06-25 Kieran Mansley
@ -2238,7 +2586,7 @@ HISTORY
2009-06-25 Kieran Mansley
* tcp.c, tcp_in.c, tcp_out.c, tcp.h: BUG26301 and BUG26267: correct
simultaneous close behaviour, and make snd_nxt have the same meaning
simultaneous close behaviour, and make snd_nxt have the same meaning
as in the RFCs.
2009-05-12 Simon Goldschmidt
@ -2374,7 +2722,7 @@ HISTORY
* tcp.c, tcp_in.c, tcp.h: add tcp_abandon() to cope with dropping
connections where no reset required (bug #25622)
* tcp_out.c: set TCP_ACK flag on keepalive and zero window probes
* tcp_out.c: set TCP_ACK flag on keepalive and zero window probes
(bug #20779)
2009-02-18 Simon Goldschmidt (Jonathan Larmour and Bill Auerbach)
@ -2410,7 +2758,7 @@ HISTORY
out of pool pbufs.
2008-12-19 Simon Goldschmidt
* many files: patch #6699: fixed some warnings on platform where sizeof(int) == 2
* many files: patch #6699: fixed some warnings on platform where sizeof(int) == 2
2008-12-10 Tamas Somogyi, Frédéric Bernon
* sockets.c: fixed bug #25051: lwip_recvfrom problem with udp: fromaddr and
@ -2495,7 +2843,7 @@ HISTORY
made from lwipopts.h. Fix comment on how to override LWIP_CHKSUM.
2008-01-22 Frédéric Bernon
* tcp.c, tcp_in.c, tcp.h, opt.h: Rename LWIP_CALCULATE_EFF_SEND_MSS in
* tcp.c, tcp_in.c, tcp.h, opt.h: Rename LWIP_CALCULATE_EFF_SEND_MSS in
TCP_CALCULATE_EFF_SEND_MSS to have coherent TCP options names.
2008-01-14 Frédéric Bernon
@ -2505,7 +2853,7 @@ HISTORY
2008-01-14 Frédéric Bernon, Marc Chaland
* ip.c: Integrate patch #6369" ip_input : checking before realloc".
2008-01-12 Frédéric Bernon
* tcpip.h, tcpip.c, api.h, api_lib.c, api_msg.c, sockets.c: replace the field
netconn::sem per netconn::op_completed like suggested for the task #7490
@ -2531,8 +2879,8 @@ HISTORY
Introduce changes for task #7490 "Add return value to sys_mbox_post" with some
modifications in the sys_mbox api: sys_mbox_new take a "size" parameters which
indicate the number of pointers query by the mailbox. There is three defines
in opt.h to indicate sizes for tcpip::mbox, netconn::recvmbox, and for the
netconn::acceptmbox. Port maintainers, you can decide to just add this new
in opt.h to indicate sizes for tcpip::mbox, netconn::recvmbox, and for the
netconn::acceptmbox. Port maintainers, you can decide to just add this new
parameter in your implementation, but to ignore it to keep the previous behavior.
The new sys_mbox_trypost function return a value to know if the mailbox is
full or if the message is posted. Take a look to sys_arch.txt for more details.
@ -2656,7 +3004,7 @@ HISTORY
Note that previous "copy" parameter for "write" APIs is now called "apiflags".
2007-10-24 Frédéric Bernon
* api.h, api_lib.c, api_msg.c: Add macro API_EVENT in the same spirit than
* api.h, api_lib.c, api_msg.c: Add macro API_EVENT in the same spirit than
TCP_EVENT_xxx macros to get a code more readable. It could also help to remove
some code (like we have talk in "patch #5919 : Create compile switch to remove
select code"), but it could be done later.
@ -2676,7 +3024,7 @@ HISTORY
all netifs (or ports) can use it.
2007-10-05 Frédéric Bernon
* netifapi.h, netifapi.c: add function netifapi_netif_set_default. Change the
* netifapi.h, netifapi.c: add function netifapi_netif_set_default. Change the
common function to reduce a little bit the footprint (for all functions using
only the "netif" parameter).
@ -2700,7 +3048,7 @@ HISTORY
or snmp_add_sysuptime(), and to define the SNMP_GET_SYSUPTIME(sysuptime) macro.
This one is undefined by default in mib2.c. SNMP_GET_SYSUPTIME is called inside
snmp_get_sysuptime(u32_t *value), and enable to change "sysuptime" value only
when it's queried (any direct call to "sysuptime" is changed by a call to
when it's queried (any direct call to "sysuptime" is changed by a call to
snmp_get_sysuptime).
2007-09-09 Frédéric Bernon, Bill Florac
@ -2781,7 +3129,7 @@ HISTORY
2007-08-26 Marc Boucher
* api_msg.c: do_close_internal(): Reset the callbacks and arg (conn) to NULL
since they can under certain circumstances be called with an invalid conn
pointer after the connection has been closed (and conn has been freed).
pointer after the connection has been closed (and conn has been freed).
2007-08-25 Frédéric Bernon (Artem Migaev's Patch)
* netif.h, netif.c: Integrate "patch #6163 : Function to check if link layer is up".
@ -2793,11 +3141,11 @@ HISTORY
2007-08-22 Frédéric Bernon
* tcpip.h, tcpip.c, ethernetif.c, opt.h: remove options ETHARP_TCPIP_INPUT &
ETHARP_TCPIP_ETHINPUT, now, only "ethinput" code is supported, even if the
ETHARP_TCPIP_ETHINPUT, now, only "ethinput" code is supported, even if the
name is tcpip_input (we keep the name of 1.2.0 function).
2007-08-17 Jared Grubb
* memp_std.h, memp.h, memp.c, mem.c, stats.c: (Task #7136) Centralize mempool
* memp_std.h, memp.h, memp.c, mem.c, stats.c: (Task #7136) Centralize mempool
settings into new memp_std.h and optional user file lwippools.h. This adds
more dynamic mempools, and allows the user to create an arbitrary number of
mempools for mem_malloc.
@ -3004,32 +3352,32 @@ HISTORY
snmp_set_sysname.
2007-03-28 Frédéric Bernon
* netif.h, netif.c: A new NETIF_FLAG_ETHARP flag is defined in netif.h, to allow to
* netif.h, netif.c: A new NETIF_FLAG_ETHARP flag is defined in netif.h, to allow to
initialize a network interface's flag with. It tell this interface is an ethernet
device, and we can use ARP with it to do a "gratuitous ARP" (RFC 3220 "IP Mobility
Support for IPv4" section 4.6) when interface is "up" with netif_set_up().
2007-03-26 Frédéric Bernon, Jonathan Larmour
* opt.h, tcpip.c: New configuration option LWIP_ARP allow to disable ARP init at build
time if you only use PPP or SLIP. The default is enable. Note we don't have to call
time if you only use PPP or SLIP. The default is enable. Note we don't have to call
etharp_init in your port's initilization sequence if you use tcpip.c, because this call
is done in tcpip_init function.
2007-03-22 Frédéric Bernon
* stats.h, stats.c, msg_in.c: Stats counters can be change to u32_t if necessary with the
new option LWIP_STATS_LARGE. If you need this option, define LWIP_STATS_LARGE to 1 in
your lwipopts.h. More, unused counters are not defined in the stats structs, and not
your lwipopts.h. More, unused counters are not defined in the stats structs, and not
display by stats_display(). Note that some options (SYS_STATS and RAW_STATS) are defined
but never used. Fix msg_in.c with the correct #if test for a stat display.
2007-03-21 Kieran Mansley
* netif.c, netif.h: Apply patch#4197 with some changes (originator: rireland@hmgsl.com).
* netif.c, netif.h: Apply patch#4197 with some changes (originator: rireland@hmgsl.com).
Provides callback on netif up/down state change.
2007-03-11 Frédéric Bernon, Mace Gael, Steve Reynolds
* sockets.h, sockets.c, api.h, api_lib.c, api_msg.h, api_msg.c, igmp.h, igmp.c,
ip.c, netif.h, tcpip.c, opt.h:
New configuration option LWIP_IGMP to enable IGMP processing. Based on only one
New configuration option LWIP_IGMP to enable IGMP processing. Based on only one
filter per all network interfaces. Declare a new function in netif to enable to
control the MAC filter (to reduce lwIP traffic processing).
@ -3052,7 +3400,7 @@ HISTORY
* snmp_msg.h, msg_in.c: SNMP UDP ports can be configured at compile time.
2007-03-06 Frédéric Bernon
* api.h, api_lib.c, sockets.h, sockets.c, tcpip.c, sys.h, sys.c, err.h:
* api.h, api_lib.c, sockets.h, sockets.c, tcpip.c, sys.h, sys.c, err.h:
Implement SO_RCVTIMEO on UDP sockets/netconn.
2007-02-28 Kieran Mansley (based on patch from Simon Goldschmidt)
@ -3094,7 +3442,7 @@ HISTORY
and/or warnings on some systems where mem_size_t and size_t differ.
* pbuf.c, ppp.c: Fix warnings on some systems with mem_malloc.
2008-03-04 Kieran Mansley (contributions by others)
2008-03-04 Kieran Mansley (contributions by others)
* Numerous small compiler error/warning fixes from contributions to
mailing list after 1.3.0 release candidate made.
@ -3211,7 +3559,7 @@ HISTORY
type change. Any compiler should cause an error without any changes in
yours netconn_peer calls (so, it can't be a "silent change"). It also
reduce a little bit the footprint for socket layer (lwip_getpeername &
lwip_getsockname use now a common lwip_getaddrname function since
lwip_getsockname use now a common lwip_getaddrname function since
netconn_peer & netconn_addr have the same parameters).
2007-09-20 Simon Goldschmidt
@ -3231,13 +3579,13 @@ HISTORY
if they are not defined in cc.h, in the same spirit than "lwip/opt.h" for lwipopts.h.
2007-08-30 Frédéric Bernon
* igmp.h, igmp.c: Some changes to remove some redundant code, add some traces,
* igmp.h, igmp.c: Some changes to remove some redundant code, add some traces,
and fix some coding style.
2007-08-28 Frédéric Bernon
* tcpip.c: Fix TCPIP_MSG_INPKT processing: now, tcpip_input can be used for any
kind of packets. These packets are considered like Ethernet packets (payload
pointing to ethhdr) if the netif got the NETIF_FLAG_ETHARP flag. Else, packets
kind of packets. These packets are considered like Ethernet packets (payload
pointing to ethhdr) if the netif got the NETIF_FLAG_ETHARP flag. Else, packets
are considered like IP packets (payload pointing to iphdr).
2007-08-27 Frédéric Bernon
@ -3335,7 +3683,7 @@ HISTORY
2007-06-28 Frédéric Bernon
* netifapi.h, netifapi.c, tcpip.h, tcpip.c: Update code to handle the option
LWIP_TCPIP_CORE_LOCKING, and do some changes to be coherent with last modifications
in api_lib/api_msg (use pointers and not type with table, etc...)
in api_lib/api_msg (use pointers and not type with table, etc...)
2007-06-26 Simon Goldschmidt
* udp.h: Fixed bug #20259: struct udp_hdr was lacking the packin defines.
@ -3437,7 +3785,7 @@ HISTORY
2007-05-16 Frédéric Bernon
* tcpip.c, igmp.h, igmp.c: Fixed bug "#19800 : IGMP: igmp_tick() will not work
with NO_SYS=1". Note that igmp_init is always in tcpip_thread (and not in
with NO_SYS=1". Note that igmp_init is always in tcpip_thread (and not in
tcpip_init) because we have to be sure that network interfaces are already
added (mac filter is updated only in igmp_init for the moment).
@ -3584,7 +3932,7 @@ HISTORY
2007-03-20 Frédéric Bernon
* tcpip.c: Initialize tcpip's mbox, and verify if initialized in tcpip_input,
tcpip_ethinput, tcpip_callback, tcpip_apimsg, to fix a init problem with
tcpip_ethinput, tcpip_callback, tcpip_apimsg, to fix a init problem with
network interfaces. Also fix a compiler warning.
2007-03-20 Kieran Mansley
@ -3676,13 +4024,13 @@ HISTORY
* rawapi.txt: Fix documentation mismatch with etharp.h about etharp_tmr's call
interval.
2007-02-28 Kieran Mansley
2007-02-28 Kieran Mansley
* pbuf.c: Fix BUG#17645 - ensure pbuf payload pointer is not moved
outside the region of the pbuf by pbuf_header()
2007-02-28 Kieran Mansley
2007-02-28 Kieran Mansley
* sockets.c: Fix BUG#19161 - ensure milliseconds timeout is non-zero
when supplied timeout is also non-zero
when supplied timeout is also non-zero
(STABLE-1.2.0)
@ -3766,7 +4114,7 @@ HISTORY
in accept() by Kevin Lawson.
2006-05-26 Christiaan Simons
* api_lib.c: Removed conn->sem creation and destruction
* api_lib.c: Removed conn->sem creation and destruction
from netconn_write() and added sys_sem_new to netconn_new_*.
(STABLE-1_1_1)
@ -3836,7 +4184,7 @@ HISTORY
* dhcp.c: Decline messages were not multicast but unicast.
* etharp.c: ETHARP_CREATE is renamed to ETHARP_TRY_HARD.
Do not try hard to insert arbitrary packet's source address,
etharp_ip_input() now calls etharp_update() without ETHARP_TRY_HARD.
etharp_ip_input() now calls etharp_update() without ETHARP_TRY_HARD.
etharp_query() now always DOES call ETHARP_TRY_HARD so that users
querying an address will see it appear in the cache (DHCP could
suffer from this when a server invalidly gave an in-use address.)

View File

@ -1,19 +1,37 @@
cmake_minimum_required(VERSION 3.7)
cmake_minimum_required(VERSION 3.10)
set (CMAKE_CONFIGURATION_TYPES "Debug;Release")
project(lwIP)
# Example lwIP application
set(LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR})
include(src/Filelists.cmake)
# Package generation
set (LWIP_DEFINITIONS LWIP_DEBUG=1)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
add_subdirectory(${LWIP_DIR}/contrib/ports/win32/example_app)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
add_subdirectory(${LWIP_DIR}/contrib/ports/unix/example_app)
else()
message(WARNING "Host ${CMAKE_SYSTEM_NAME} is not supported to build example_app")
endif()
# Source package generation
set(CPACK_SOURCE_GENERATOR "ZIP")
set(CPACK_SOURCE_PACKAGE_DESCRIPTION_SUMMARY "lwIP lightweight IP stack")
set(CPACK_PACKAGE_VERSION_MAJOR "${LWIP_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${LWIP_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${LWIP_VERSION_REVISION}")
set(CPACK_SOURCE_IGNORE_FILES "/build/;${CPACK_SOURCE_IGNORE_FILES};.git")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "lwip-${LWIP_VERSION_MAJOR}.${LWIP_VERSION_MINOR}.${LWIP_VERSION_REVISION}")
include(CPack)
# Target for package generation
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
add_dependencies(dist lwipdocs)
# Generate docs before creating source package
include(src/Filelists.cmake)
if (NOT TARGET dist)
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
if (TARGET lwipdocs)
add_dependencies(dist lwipdocs)
endif()
endif()

54
COPYING
View File

@ -1,33 +1,25 @@
/*
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.

11
FEATURES Normal file
View File

@ -0,0 +1,11 @@
lwIP is a small independent implementation of the TCP/IP protocol suite targeted at embedded systems.
The focus of the lwIP TCP/IP implementation is to reduce resource usage while still having a full scale TCP. This makes lwIP suitable for use in embedded systems with tens of kilobytes of free RAM and room for around 40 kilobytes of code ROM.
Main features include:
- Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE, 6LowPAN (via IEEE 802.15.4, BLE or ZEP; since v2.1.0)
- DHCP client, stateless DHCPv6 (since v2.1.0), DNS client (incl. mDNS hostname resolver), AutoIP/APIPA (Zeroconf), ACD (Address Conflict Detection), SNMP agent (v1, v2c, v3 (since v2.1.0), private MIB support & MIB compiler)
- APIs: specialized APIs for enhanced performance & zero copy, optional Berkeley-alike socket API
- Extended features: IP forwarding over multiple network interfaces
- Extended TCP features: congestion control, RTT estimation and fast recovery/fast retransmit, sending SACKs (since v2.1.0), "altcp": nearly transparent TLS for any tcp pcb (since v2.1.0)
- Addon applications: HTTP server (HTTPS via altcp), HTTP(S) client (since v2.1.0), SNTP client, SMTP client (SMTPS via altcp), ping, NetBIOS nameserver, mDNS responder, MQTT client (TLS support since v2.1.0), TFTP server, iPerf2 counterpart

1
FILES
View File

@ -1,3 +1,4 @@
contrib/ - lwIP examples, ports, and small apps (formerly http://git.savannah.gnu.org/cgit/lwip/lwip-contrib.git/)
src/ - The source code for the lwIP TCP/IP stack.
doc/ - The documentation for lwIP.
test/ - Some code to test whether the sources do what they should.

55
README
View File

@ -1,15 +1,15 @@
INTRODUCTION
lwIP is a small independent implementation of the TCP/IP protocol
suite that has been developed by Adam Dunkels at the Computer and
Networks Architectures (CNA) lab at the Swedish Institute of Computer
Science (SICS).
lwIP is a small independent implementation of the TCP/IP protocol suite.
The focus of the lwIP TCP/IP implementation is to reduce the RAM usage
while still having a full scale TCP. This making lwIP suitable for use
in embedded systems with tens of kilobytes of free RAM and room for
around 40 kilobytes of code ROM.
lwIP was originally developed by Adam Dunkels at the Computer and Networks
Architectures (CNA) lab at the Swedish Institute of Computer Science (SICS)
and is now developed and maintained by a worldwide network of developers.
FEATURES
@ -17,27 +17,34 @@ FEATURES
multiple network interfaces
* ICMP (Internet Control Message Protocol) for network maintenance and debugging
* IGMP (Internet Group Management Protocol) for multicast traffic management
* MLD (Multicast listener discovery for IPv6). Aims to be compliant with
* MLD (Multicast listener discovery for IPv6). Aims to be compliant with
RFC 2710. No support for MLDv2
* ND (Neighbor discovery and stateless address autoconfiguration for IPv6).
Aims to be compliant with RFC 4861 (Neighbor discovery) and RFC 4862
(Address autoconfiguration)
* DHCP, AutoIP/APIPA (Zeroconf), ACD (Address Conflict Detection)
and (stateless) DHCPv6
* UDP (User Datagram Protocol) including experimental UDP-lite extensions
* TCP (Transmission Control Protocol) with congestion control, RTT estimation
and fast recovery/fast retransmit
fast recovery/fast retransmit and sending SACKs
* raw/native API for enhanced performance
* Optional Berkeley-like socket API
* DNS (Domain names resolver)
* TLS: optional layered TCP ("altcp") for nearly transparent TLS for any
TCP-based protocol (ported to mbedTLS) (see changelog for more info)
* PPPoS and PPPoE (Point-to-point protocol over Serial/Ethernet)
* DNS (Domain name resolver incl. mDNS)
* 6LoWPAN (via IEEE 802.15.4, BLE or ZEP)
APPLICATIONS
* HTTP server with SSI and CGI
* SNMPv2c agent with MIB compiler (Simple Network Management Protocol)
* HTTP server with SSI and CGI (HTTPS via altcp)
* SNMPv2c agent with MIB compiler (Simple Network Management Protocol), v3 via altcp
* SNTP (Simple network time protocol)
* NetBIOS name service responder
* MDNS (Multicast DNS) responder
* iPerf server implementation
* MQTT client (TLS support via altcp)
LICENSE
@ -57,37 +64,39 @@ help improve lwIP by use of Savannah's interface, Git and the
mailing list. A core team of developers will commit changes to the
Git source tree.
The lwIP TCP/IP stack is maintained in the 'lwip' Git module and
contributions (such as platform ports) are in the 'contrib' Git module.
The lwIP TCP/IP stack is maintained in the 'src' directory and
contributions (such as platform ports and applications) are in
the 'contrib' directory.
See doc/savannah.txt for details on Git server access for users and
developers.
The current Git trees are web-browsable:
http://git.savannah.gnu.org/cgit/lwip.git
http://git.savannah.gnu.org/cgit/lwip/lwip-contrib.git
The current Git tree is web-browsable:
https://git.savannah.gnu.org/cgit/lwip.git
Submit patches and bugs via the lwIP project page:
http://savannah.nongnu.org/projects/lwip/
https://savannah.nongnu.org/projects/lwip/
Continuous integration builds (GCC, clang):
https://travis-ci.org/yarrick/lwip-merged
https://github.com/lwip-tcpip/lwip/actions
DOCUMENTATION
Self documentation of the source code is regularly extracted from the current
Git sources and is available from this web page:
http://www.nongnu.org/lwip/
There is now a constantly growing wiki about lwIP at
http://lwip.wikia.com/wiki/LwIP_Wiki
https://www.nongnu.org/lwip/
Also, there are mailing lists you can subscribe at
http://savannah.nongnu.org/mail/?group=lwip
https://savannah.nongnu.org/mail/?group=lwip
plus searchable archives:
http://lists.nongnu.org/archive/html/lwip-users/
http://lists.nongnu.org/archive/html/lwip-devel/
https://lists.nongnu.org/archive/html/lwip-users/
https://lists.nongnu.org/archive/html/lwip-devel/
There is a wiki about lwIP at
https://lwip.wikia.com/wiki/LwIP_Wiki
You might get questions answered there, but unfortunately, it is not as
well maintained as it should be.
lwIP was originally written by Adam Dunkels:
http://dunkels.com/adam/

View File

@ -7,46 +7,52 @@ with newer versions.
(git master)
* [Enter new changes just after this line - do not remove this line]
* The eth_addr_cmp and ip_addr_cmp set of functions have been renamed to eth_addr_eq, ip_addr_eq
and so on, since they return non-zero on equality. Macros for the old names exist.
* The sio_write function used by PPP now takes the data argument as const.
* The prev field in the snmp_varbind struct has been removed.
(2.2.0)
++ Repository changes:
* The contrib repository has been added into the main repository in the subdirectory 'contrib'
(the old contrib repository remains online for reference but is not used any more)
(2.1.0)
++ Application changes:
* tcpip_trycallback() was renamed to tcpip_callbackmsg_trycallback() to avoid confusion
with tcpip_try_callback()
* Use the new altcp API for seamless TLS integration into existing TCP applications (see changelog)
* TCP only kills existing connections with a LOWER priority than the one currently being opened.
Previous implementations also kill existing connections of the SAME priority.
* ip4_route_src: parameter order is reversed: ip4_route_src(dest, src) -> ip4_route_src(src, dest)
to make parameter order consistent with other ip*_route*() functions.
Same also applies to LWIP_HOOK_IP4_ROUTE_SRC() parameter order.
* pbuf API: pbuf->type (an u8_t holding the enum 'pbuf_type') has changed to only hold a
description of the pbuf (e.g. data following pbuf struct, data volatile, allocation
source heap/pool/etc.). As a consequence, applications can't test pbuf->type any more.
Use pbuf_match_type(pbuf, type) instead.
* socket API: according to the standard, SO_ERROR now only returns asynchronous errors.
All other/normal/synchronous errors are (and always were) available via 'errno'.
LWIP_SOCKET_SET_ERRNO has been removed - 'errno' is always set - and required!
* httpd LWIP_HTTPD_CGI_SSI: httpd_cgi_handler() has an additional parameter "struct fs_file *"
++ Port changes:
* tcpip_trycallback() was renamed to tcpip_callbackmsg_trycallback() to avoid confusion
with tcpip_try_callback()
* compatibility headers: moved from 'src/include/posix' to 'src/include/compat/posix',
'src/include/compat/stdc' etc.
* The IPv6 implementation now supports address scopes. All addresses that have a scope according
to the default policy (link-local unicast addresses, interface-local and link-local multicast
addresses) should now have a zone set on them before being passed to the core API, although
lwIP will currently attempt to select a zone on the caller's behalf when necessary.
Applications that directly assign IPv6 addresses to interfaces (which is NOT recommended)
must now ensure that link-local addresses carry the netif's zone. See the new ip6_zone.h header
file for more information and relevant macros. For now it is still possible to turn off scopes
support through the new LWIP_IPV6_SCOPES option. When upgrading an implementation that uses the
core API directly, it is highly recommended to enable LWIP_IPV6_SCOPES_DEBUG at least for
a while, to ensure e.g. proper address initialization.
* The IPv6 implementation now supports address scopes. (See LWIP_IPV6_SCOPES documentation
and ip6_zone.h for more documentation)
* LWIP_HOOK_DHCP_APPEND_OPTIONS() has changed, see description in opt.h (options_out_len is not
available in struct dhcp any more)
* httpd LWIP_HTTPD_CGI_SSI: httpd_cgi_handler() has an additional parameter "struct fs_file *"
* Added debug helper asserts to ensure threading/locking requirements are met (define
LWIP_MARK_TCPIP_THREAD() and LWIP_ASSERT_CORE_LOCKED()).
* Added sys_mbox_trypost_fromisr() and tcpip_callbackmsg_trycallback_fromisr()
These can be used to post preallocated messages from an ISR to the tcpip thread
(e.g. when using FreeRTOS)
(2.0.2)

View File

@ -1,22 +0,0 @@
# lwIP astyle formatting options
# NOT FINISHED - DON'T USE
# braces and indent
style=otbs
indent=spaces=2
attach-extern-c
#attach-closing-while
# indentation
indent-switches
#max-continuation-indent=40
# padding
pad-oper
pad-comma
pad-header
align-pointer=name
# formatting
break-one-line-headers
keep-one-line-blocks
# don't use "other options" (e.g. formatted) in this file
# send them as additional command line options

View File

@ -0,0 +1,26 @@
# Copyright 2017 Kaspar Schleiser <kaspar@schleiser.de>
# Copyright 2014 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
# Copyright 2014 Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
# Copyright 2020 Jonathan Demeyer <jona.dem@gmail.com>
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
changed_files() {
: ${FILEREGEX:='\.([CcHh])$'}
: ${EXCLUDE:=''}
: ${DIFFFILTER:='ACMR'}
DIFFFILTER="--diff-filter=${DIFFFILTER}"
# select either all or only touched-in-branch files, filter through FILEREGEX
if [ -z "${BASE_BRANCH}" ]; then
FILES="$(git ls-tree -r --full-tree --name-only HEAD | grep -E ${FILEREGEX})"
else
FILES="$(git diff ${DIFFFILTER} --name-only ${BASE_BRANCH} | grep -E ${FILEREGEX})"
fi
# filter out negatives
echo "${FILES}" | grep -v -E ${EXCLUDE}
}

59
codespell_check.sh Executable file
View File

@ -0,0 +1,59 @@
#!/usr/bin/env bash
# Copyright 2019 Alexandre Abadie <alexandre.abadie@inria.fr>
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
CODESPELL_CMD="codespell"
if tput colors &> /dev/null && [ "$(tput colors)" -ge 8 ]; then
CERROR=$'\033[1;31m'
CRESET=$'\033[0m'
else
CERROR=
CRESET=
fi
: "${LWIPBASE:=$(cd $(dirname $0)/; pwd)}"
cd $LWIPBASE
: "${LWIPTOOLS:=${LWIPBASE}}"
. "${LWIPTOOLS}"/codespell_changed_files.sh
FILEREGEX='\.([CcHh]|sh|py|md|txt)$'
EXCLUDE='^(./contrib/apps/LwipMibCompiler/Mibs)'
FILES=$(FILEREGEX=${FILEREGEX} EXCLUDE=${EXCLUDE} changed_files)
if [ -z "${FILES}" ]; then
exit 0
fi
${CODESPELL_CMD} --version &> /dev/null || {
printf "%s%s: cannot execute \"%s\"!%s\n" "${CERROR}" "$0" "${CODESPELL_CMD}" "${CRESET}"
exit 1
}
CODESPELL_OPTS="-q 2" # Disable "WARNING: Binary file"
CODESPELL_OPTS+=" --check-hidden"
# Disable false positives "nd => and, 2nd", "ans => and", "tolen => token",
# "ofo => of", "WAN => WANT", "mut => must, mutt, moot"
CODESPELL_OPTS+=" --ignore-words-list=nd,ans,tolen,ofo,wan,mut,clen,useg,clos "
CODESPELL_OPTS+=" --ignore-words-list=devine,clinet,linz,garantie,explicite,numer "
CODESPELL_OPTS+=" --ignore-words-list=skool "
# propagate all options to codespell -> pass "-w" to this script to write changes
CODESPELL_OPTS+="$@"
# Filter-out all false positive raising "disabled due to" messages.
ERRORS=$(${CODESPELL_CMD} ${CODESPELL_OPTS} ${FILES} | grep -ve "disabled due to")
if [ -n "${ERRORS}" ]
then
printf "%sThere are typos in the following files:%s\n\n" "${CERROR}" "${CRESET}"
printf "%s\n" "${ERRORS}"
# TODO: return 1 when all typos are fixed
exit 0
else
exit 0
fi

106
contrib/Coverity/coverity.c Normal file
View File

@ -0,0 +1,106 @@
typedef unsigned char err_t;
typedef unsigned int u32_t;
typedef unsigned short u16_t;
typedef unsigned char u8_t;
typedef void sys_sem_t;
typedef void sys_mutex_t;
typedef size_t mem_size_t;
typedef size_t memp_t;
struct pbuf;
struct netif;
void* mem_malloc(mem_size_t size)
{
__coverity_alloc__(size);
}
void mem_free(void* mem)
{
__coverity_free__(mem);
}
void* memp_malloc(memp_t type)
{
__coverity_alloc_nosize__();
}
void memp_free(memp_t type, void* mem)
{
__coverity_free__(mem);
}
void sys_mutex_lock(sys_mutex_t* mutex)
{
__coverity_exclusive_lock_acquire__(mutex);
}
void sys_mutex_unlock(sys_mutex_t* mutex)
{
__coverity_exclusive_lock_release__(mutex);
}
u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
{
__coverity_recursive_lock_acquire__(sem);
}
void sys_sem_signal(sys_sem_t *sem)
{
__coverity_recursive_lock_release__(sem);
}
err_t ethernet_input(struct pbuf *p, struct netif *inp)
{
__coverity_tainted_string_sink_content__(p);
}
err_t tcpip_input(struct pbuf *p, struct netif *inp)
{
__coverity_tainted_string_sink_content__(p);
}
err_t ip_input(struct pbuf *p, struct netif *inp)
{
__coverity_tainted_string_sink_content__(p);
}
err_t ip4_input(struct pbuf *p, struct netif *inp)
{
__coverity_tainted_string_sink_content__(p);
}
err_t ip6_input(struct pbuf *p, struct netif *inp)
{
__coverity_tainted_string_sink_content__(p);
}
err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len)
{
__coverity_tainted_string_argument__(buf);
__coverity_tainted_data_argument__(buf);
}
err_t pbuf_take_at(struct pbuf *buf, const void *dataptr, u16_t len, u16_t offset)
{
__coverity_tainted_string_argument__(buf);
__coverity_tainted_data_argument__(buf);
}
err_t pbuf_copy(struct pbuf *p_to, struct pbuf *p_from)
{
__coverity_tainted_data_transitive__(p_to, p_from);
}
u16_t pbuf_copy_partial(struct pbuf *p, void *dataptr, u16_t len, u16_t offset)
{
__coverity_tainted_string_argument__(dataptr);
__coverity_tainted_data_argument__(dataptr);
}
u8_t pbuf_get_at(struct pbuf* p, u16_t offset)
{
__coverity_tainted_data_return__();
}
void abort(void)
{
__coverity_panic__();
}
int check_path(char* path, size_t size)
{
if (size) {
__coverity_tainted_data_sanitize__(path);
return 1;
} else {
return 0;
}
}

61
contrib/Filelists.cmake Normal file
View File

@ -0,0 +1,61 @@
# This file is indended to be included in end-user CMakeLists.txt
# include(/path/to/Filelists.cmake)
# It assumes the variable LWIP_CONTRIB_DIR is defined pointing to the
# root path of lwIP/contrib sources.
#
# This file is NOT designed (on purpose) to be used as cmake
# subdir via add_subdirectory()
# The intention is to provide greater flexibility to users to
# create their own targets using the *_SRCS variables.
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0")
include_guard(GLOBAL)
endif()
set(lwipcontribexamples_SRCS
${LWIP_CONTRIB_DIR}/examples/httpd/fs_example/fs_example.c
${LWIP_CONTRIB_DIR}/examples/httpd/https_example/https_example.c
${LWIP_CONTRIB_DIR}/examples/httpd/ssi_example/ssi_example.c
${LWIP_CONTRIB_DIR}/examples/lwiperf/lwiperf_example.c
${LWIP_CONTRIB_DIR}/examples/mdns/mdns_example.c
${LWIP_CONTRIB_DIR}/examples/mqtt/mqtt_example.c
${LWIP_CONTRIB_DIR}/examples/ppp/pppos_example.c
${LWIP_CONTRIB_DIR}/examples/snmp/snmp_private_mib/lwip_prvmib.c
${LWIP_CONTRIB_DIR}/examples/snmp/snmp_v3/snmpv3_dummy.c
${LWIP_CONTRIB_DIR}/examples/snmp/snmp_example.c
${LWIP_CONTRIB_DIR}/examples/sntp/sntp_example.c
${LWIP_CONTRIB_DIR}/examples/tftp/tftp_example.c
)
add_library(lwipcontribexamples EXCLUDE_FROM_ALL ${lwipcontribexamples_SRCS})
target_compile_options(lwipcontribexamples PRIVATE ${LWIP_COMPILER_FLAGS})
target_compile_definitions(lwipcontribexamples PRIVATE ${LWIP_DEFINITIONS} ${LWIP_MBEDTLS_DEFINITIONS})
target_include_directories(lwipcontribexamples PRIVATE ${LWIP_INCLUDE_DIRS} ${LWIP_MBEDTLS_INCLUDE_DIRS})
set(lwipcontribapps_SRCS
${LWIP_CONTRIB_DIR}/apps/httpserver/httpserver-netconn.c
${LWIP_CONTRIB_DIR}/apps/chargen/chargen.c
${LWIP_CONTRIB_DIR}/apps/udpecho/udpecho.c
${LWIP_CONTRIB_DIR}/apps/tcpecho/tcpecho.c
${LWIP_CONTRIB_DIR}/apps/shell/shell.c
${LWIP_CONTRIB_DIR}/apps/udpecho_raw/udpecho_raw.c
${LWIP_CONTRIB_DIR}/apps/tcpecho_raw/tcpecho_raw.c
${LWIP_CONTRIB_DIR}/apps/netio/netio.c
${LWIP_CONTRIB_DIR}/apps/ping/ping.c
${LWIP_CONTRIB_DIR}/apps/socket_examples/socket_examples.c
${LWIP_CONTRIB_DIR}/apps/rtp/rtp.c
)
add_library(lwipcontribapps EXCLUDE_FROM_ALL ${lwipcontribapps_SRCS})
target_compile_options(lwipcontribapps PRIVATE ${LWIP_COMPILER_FLAGS})
target_compile_definitions(lwipcontribapps PRIVATE ${LWIP_DEFINITIONS} ${LWIP_MBEDTLS_DEFINITIONS})
target_include_directories(lwipcontribapps PRIVATE ${LWIP_INCLUDE_DIRS} ${LWIP_MBEDTLS_INCLUDE_DIRS})
set(lwipcontribaddons_SRCS
${LWIP_CONTRIB_DIR}/addons/tcp_isn/tcp_isn.c
${LWIP_CONTRIB_DIR}/addons/ipv6_static_routing/ip6_route_table.c
# ${LWIP_CONTRIB_DIR}/addons/netconn/external_resolve/dnssd.c
# ${LWIP_CONTRIB_DIR}/addons/tcp_md5/tcp_md5.c
)
add_library(lwipcontribaddons EXCLUDE_FROM_ALL ${lwipcontribaddons_SRCS})
target_compile_options(lwipcontribaddons PRIVATE ${LWIP_COMPILER_FLAGS})
target_compile_definitions(lwipcontribaddons PRIVATE ${LWIP_DEFINITIONS} ${LWIP_MBEDTLS_DEFINITIONS})
target_include_directories(lwipcontribaddons PRIVATE ${LWIP_INCLUDE_DIRS} ${LWIP_MBEDTLS_INCLUDE_DIRS})

57
contrib/Filelists.mk Normal file
View File

@ -0,0 +1,57 @@
#
# Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
# SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
# OF SUCH DAMAGE.
#
# This file is part of the lwIP TCP/IP stack.
#
# Author: Adam Dunkels <adam@sics.se>
#
# CONTRIBAPPFILES: Contrib Applications.
CONTRIBAPPFILES=$(CONTRIBDIR)/apps/httpserver/httpserver-netconn.c \
$(CONTRIBDIR)/apps/chargen/chargen.c \
$(CONTRIBDIR)/apps/udpecho/udpecho.c \
$(CONTRIBDIR)/apps/tcpecho/tcpecho.c \
$(CONTRIBDIR)/apps/shell/shell.c \
$(CONTRIBDIR)/apps/udpecho_raw/udpecho_raw.c \
$(CONTRIBDIR)/apps/tcpecho_raw/tcpecho_raw.c \
$(CONTRIBDIR)/apps/netio/netio.c \
$(CONTRIBDIR)/apps/ping/ping.c \
$(CONTRIBDIR)/apps/socket_examples/socket_examples.c \
$(CONTRIBDIR)/apps/rtp/rtp.c \
$(CONTRIBDIR)/examples/httpd/fs_example/fs_example.c \
$(CONTRIBDIR)/examples/httpd/https_example/https_example.c \
$(CONTRIBDIR)/examples/httpd/ssi_example/ssi_example.c \
$(CONTRIBDIR)/examples/lwiperf/lwiperf_example.c \
$(CONTRIBDIR)/examples/mdns/mdns_example.c \
$(CONTRIBDIR)/examples/mqtt/mqtt_example.c \
$(CONTRIBDIR)/examples/ppp/pppos_example.c \
$(CONTRIBDIR)/examples/snmp/snmp_private_mib/lwip_prvmib.c \
$(CONTRIBDIR)/examples/snmp/snmp_v3/snmpv3_dummy.c \
$(CONTRIBDIR)/examples/snmp/snmp_example.c \
$(CONTRIBDIR)/examples/sntp/sntp_example.c \
$(CONTRIBDIR)/examples/tftp/tftp_example.c \
$(CONTRIBDIR)/addons/tcp_isn/tcp_isn.c \
$(CONTRIBDIR)/addons/ipv6_static_routing/ip6_route_table.c

View File

@ -0,0 +1,5 @@
A simple example of using LWIP_HOOK_DHCP_PARSE/APPEND_OPTION hooks to implement:
* DHCP_OPTION_MTU (option 26) to update the netif's MTU
* DHCP_OPTION_CLIENT_ID (option 61) to advertize client's HW id of LWIP_IANA_HWTYPE_ETHERNET type
Please follow the instructions in dhcp_extra_opts.h to add the hooks, definitions in lwipopts.h and enabling the extra options.

View File

@ -0,0 +1,91 @@
/*
* Copyright (c) Espressif Systems (Shanghai) CO LTD
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <string.h>
#include "lwip/prot/dhcp.h"
#include "lwip/dhcp.h"
#include "lwip/netif.h"
#include "lwip/prot/iana.h"
void dhcp_parse_extra_opts(struct dhcp *dhcp, uint8_t state, uint8_t option, uint8_t len, struct pbuf* p, uint16_t offset)
{
LWIP_UNUSED_ARG(dhcp);
LWIP_UNUSED_ARG(state);
LWIP_UNUSED_ARG(option);
LWIP_UNUSED_ARG(len);
LWIP_UNUSED_ARG(p);
LWIP_UNUSED_ARG(offset);
#if LWIP_DHCP_ENABLE_MTU_UPDATE
if ((option == DHCP_OPTION_MTU) &&
(state == DHCP_STATE_REBOOTING || state == DHCP_STATE_REBINDING ||
state == DHCP_STATE_RENEWING || state == DHCP_STATE_REQUESTING)) {
u32_t mtu = 0;
struct netif *netif;
LWIP_ERROR("dhcp_parse_extra_opts(): MTU option's len != 2", len == 2, return;);
LWIP_ERROR("dhcp_parse_extra_opts(): extracting MTU option failed",
pbuf_copy_partial(p, &mtu, 2, offset) == 2, return;);
mtu = lwip_htons((u16_t)mtu);
NETIF_FOREACH(netif) {
/* find the netif related to this dhcp */
if (dhcp == netif_dhcp_data(netif)) {
if (mtu < netif->mtu) {
netif->mtu = mtu;
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_parse_extra_opts(): Negotiated netif MTU is %d\n", netif->mtu));
}
return;
}
}
} /* DHCP_OPTION_MTU */
#endif /* LWIP_DHCP_ENABLE_MTU_UPDATE */
}
void dhcp_append_extra_opts(struct netif *netif, uint8_t state, struct dhcp_msg *msg_out, uint16_t *options_out_len)
{
LWIP_UNUSED_ARG(netif);
LWIP_UNUSED_ARG(state);
LWIP_UNUSED_ARG(msg_out);
LWIP_UNUSED_ARG(options_out_len);
#if LWIP_DHCP_ENABLE_CLIENT_ID
if (state == DHCP_STATE_RENEWING || state == DHCP_STATE_REBINDING ||
state == DHCP_STATE_REBOOTING || state == DHCP_STATE_OFF ||
state == DHCP_STATE_REQUESTING || state == DHCP_STATE_BACKING_OFF || state == DHCP_STATE_SELECTING) {
size_t i;
u8_t *options = msg_out->options + *options_out_len;
LWIP_ERROR("dhcp_append(client_id): options_out_len + 3 + netif->hwaddr_len <= DHCP_OPTIONS_LEN",
*options_out_len + 3U + netif->hwaddr_len <= DHCP_OPTIONS_LEN, return;);
*options_out_len = *options_out_len + netif->hwaddr_len + 3;
*options++ = DHCP_OPTION_CLIENT_ID;
*options++ = netif->hwaddr_len + 1; /* option size */
*options++ = LWIP_IANA_HWTYPE_ETHERNET;
for (i = 0; i < netif->hwaddr_len; i++) {
*options++ = netif->hwaddr[i];
}
}
#endif /* LWIP_DHCP_ENABLE_CLIENT_ID */
}

View File

@ -0,0 +1,61 @@
/*
* Copyright (c) Espressif Systems (Shanghai) CO LTD
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* To use these additional DHCP options, make sure this file is included in LWIP_HOOK_FILENAME
* and define these hooks:
*
* #define LWIP_HOOK_DHCP_PARSE_OPTION(netif, dhcp, state, msg, msg_type, option, len, pbuf, offset) \
* do { LWIP_UNUSED_ARG(msg); \
* dhcp_parse_extra_opts(dhcp, state, option, len, pbuf, offset); \
* } while(0)
*
* #define LWIP_HOOK_DHCP_APPEND_OPTIONS(netif, dhcp, state, msg, msg_type, options_len_ptr) \
* dhcp_append_extra_opts(netif, state, msg, options_len_ptr);
*
* To enable (disable) these option, please set one or both of the below macros to 1 (0)
* #define LWIP_DHCP_ENABLE_MTU_UPDATE 1
* #define LWIP_DHCP_ENABLE_CLIENT_ID 1
*/
#ifndef LWIP_HDR_CONTRIB_ADDONS_DHCP_OPTS_H
#define LWIP_HDR_CONTRIB_ADDONS_DHCP_OPTS_H
/* Add standard integers so the header could be included before lwip */
#include <stdint.h>
/* Forward declare lwip structs */
struct dhcp;
struct pbuf;
struct dhcp;
struct netif;
struct dhcp_msg;
/* Internal hook functions */
void dhcp_parse_extra_opts(struct dhcp *dhcp, uint8_t state, uint8_t option, uint8_t len, struct pbuf* p, uint16_t offset);
void dhcp_append_extra_opts(struct netif *netif, uint8_t state, struct dhcp_msg *msg_out, uint16_t *options_out_len);
#endif /* LWIP_HDR_CONTRIB_ADDONS_DHCP_OPTS_H */

View File

@ -0,0 +1,43 @@
A simple routing table implementation for addition, deletion and lookup of IPv6 routes. 
APIs are:
1) s8_t ip6_add_route_entry(struct ip6_prefix *ip6_prefix,
                            struct netif *netif,
                            ip6_addr_t *gateway,
                            s8_t *index);
2) err_t ip6_remove_route_entry(struct ip6_prefix *ip6_prefix);
3) s8_t ip6_find_route_entry(ip6_addr_t *ip6_dest_addr);
4) struct netif *ip6_static_route(ip6_addr_t *src, ip6_addr_t *dest);
5) ip6_addr_t *ip6_get_gateway(struct netif *netif, ip6_addr_t *dest);
6) struct ip6_route_entry *ip6_get_route_table(void);
For route lookup from the table, The LWIP_HOOK_IP6_ROUTE hook in ip6_route(..) of ip6.c
could be assigned to the ip6_static_route() API of this implementation to return the
appropriate netif.
-- The application can add routes using the API ip6_add_route_entry(..). 
   This API adds the ip6 prefix route into the static route table while
   keeping all entries sorted in decreasing order of prefix length.
   Subsequently, a linear search down the list can be performed to retrieve a
   matching route entry for a Longest Prefix Match.
   The prefix length is expected to be at an 8-bit boundary. While this is 
   a limitation, it would serve most practical purposes.
-- The application can remove routes using the API ip6_remove_route_entry(..).
-- The application can find a route entry for a specific address using the 
   ip6_find_route_entry() function which returns the index of the found entry. 
   This is used internally by the route lookup function ip6_static_route() API.
-- To fetch the gateway IPv6 address for a specific destination IPv6 
   address and target netif, the application can call ip6_get_gateway(..).
This API could be assigned to the LWIP_HOOK_ND6_GET_GW() if a gateway has
been added as part of the ip6_add_route_entry().
-- To fetch a pointer to the head of the table, the application can call 
   ip6_get_route_table().

View File

@ -0,0 +1,248 @@
/**
* @file
* IPv6 static route table.
*/
/*
* Copyright (c) 2015 Nest Labs, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* Author: Pradip De <pradipd@google.com>
*
*
* Please coordinate changes and requests with Pradip De
* <pradipd@google.com>
*/
#include "lwip/opt.h"
#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */
#include "ip6_route_table.h"
#include "lwip/def.h"
#include "lwip/mem.h"
#include "lwip/netif.h"
#include "lwip/ip6.h"
#include "lwip/ip6_addr.h"
#include "lwip/nd6.h"
#include "lwip/debug.h"
#include "lwip/stats.h"
#include "string.h"
static struct ip6_route_entry static_route_table[LWIP_IPV6_NUM_ROUTE_ENTRIES];
/**
* Add the ip6 prefix route and target netif into the static route table while
* keeping all entries sorted in decreasing order of prefix length.
* 1. Search from the last entry up to find the correct slot to insert while
* moving entries one position down to create room.
* 2. Insert into empty slot created.
*
* Subsequently, a linear search down the list can be performed to retrieve a
* matching route entry for a Longest Prefix Match.
*
* @param ip6_prefix the route prefix entry to add.
* @param netif pointer to target netif.
* @param gateway the gateway address to use to send through. Has to be link local.
* @param idx return value argument of index where route entry was added in table.
* @return ERR_OK if addition was successful.
* ERR_MEM if table is already full.
* ERR_ARG if passed argument is bad or route already exists in table.
*/
err_t
ip6_add_route_entry(const struct ip6_prefix *ip6_prefix, struct netif *netif, const ip6_addr_t *gateway, s8_t *idx)
{
s8_t i = -1;
err_t retval = ERR_OK;
if (!ip6_prefix_valid(ip6_prefix->prefix_len) || (netif == NULL)) {
retval = ERR_ARG;
goto exit;
}
/* Check if an entry already exists with matching prefix; If so, replace it. */
for (i = 0; i < LWIP_IPV6_NUM_ROUTE_ENTRIES; i++) {
if ((ip6_prefix->prefix_len == static_route_table[i].prefix.prefix_len) &&
memcmp(&ip6_prefix->addr, &static_route_table[i].prefix.addr,
ip6_prefix->prefix_len / 8) == 0) {
/* Prefix matches; replace the netif with the one being added. */
goto insert;
}
}
/* Check if the table is full */
if (static_route_table[LWIP_IPV6_NUM_ROUTE_ENTRIES - 1].netif != NULL) {
retval = ERR_MEM;
goto exit;
}
/* Shift all entries down the table until slot is found */
for (i = LWIP_IPV6_NUM_ROUTE_ENTRIES - 1;
i > 0 && (ip6_prefix->prefix_len > static_route_table[i - 1].prefix.prefix_len); i--) {
SMEMCPY(&static_route_table[i], &static_route_table[i - 1], sizeof(struct ip6_route_entry));
}
insert:
/* Insert into the slot selected */
SMEMCPY(&static_route_table[i].prefix, ip6_prefix, sizeof(struct ip6_prefix));
static_route_table[i].netif = netif;
/* Add gateway to route table */
static_route_table[i].gateway = gateway;
if (idx != NULL) {
*idx = i;
}
exit:
return retval;
}
/**
* Removes the route entry from the static route table.
*
* @param ip6_prefix the route prefix entry to delete.
*/
void
ip6_remove_route_entry(const struct ip6_prefix *ip6_prefix)
{
int i, pos = -1;
for (i = 0; i < LWIP_IPV6_NUM_ROUTE_ENTRIES; i++) {
/* compare prefix to find position to delete */
if (ip6_prefix->prefix_len == static_route_table[i].prefix.prefix_len &&
memcmp(&ip6_prefix->addr, &static_route_table[i].prefix.addr,
ip6_prefix->prefix_len / 8) == 0) {
pos = i;
break;
}
}
if (pos >= 0) {
/* Shift everything beyond pos one slot up */
for (i = pos; i < LWIP_IPV6_NUM_ROUTE_ENTRIES - 1; i++) {
SMEMCPY(&static_route_table[i], &static_route_table[i+1], sizeof(struct ip6_route_entry));
if (static_route_table[i].netif == NULL) {
break;
}
}
/* Zero the remaining entries */
for (; i < LWIP_IPV6_NUM_ROUTE_ENTRIES; i++) {
ip6_addr_set_zero((&static_route_table[i].prefix.addr));
static_route_table[i].netif = NULL;
}
}
}
/**
* Finds the appropriate route entry in the static route table corresponding to the given
* destination IPv6 address. Since the entries in the route table are kept sorted in decreasing
* order of prefix length, a linear search down the list is performed to retrieve a matching
* index.
*
* @param ip6_dest_addr the destination address to match
* @return the idx of the found route entry; -1 if not found.
*/
s8_t
ip6_find_route_entry(const ip6_addr_t *ip6_dest_addr)
{
s8_t i, idx = -1;
/* Search prefix in the sorted(decreasing order of prefix length) list */
for(i = 0; i < LWIP_IPV6_NUM_ROUTE_ENTRIES; i++) {
if (memcmp(ip6_dest_addr, &static_route_table[i].prefix.addr,
static_route_table[i].prefix.prefix_len / 8) == 0) {
idx = i;
break;
}
}
return idx;
}
/**
* Finds the appropriate network interface for a given IPv6 address from a routing table with
* static IPv6 routes.
*
* @param src the source IPv6 address, if known
* @param dest the destination IPv6 address for which to find the route
* @return the netif on which to send to reach dest
*/
struct netif *
ip6_static_route(const ip6_addr_t *src, const ip6_addr_t *dest)
{
int i;
LWIP_UNUSED_ARG(src);
/* Perform table lookup */
i = ip6_find_route_entry(dest);
if (i >= 0) {
return static_route_table[i].netif;
} else {
return NULL;
}
}
/**
* Finds the gateway IP6 address for a given destination IPv6 address and target netif
* from a routing table with static IPv6 routes.
*
* @param netif the netif used for sending
* @param dest the destination IPv6 address
* @return the ip6 address of the gateway to forward packet to
*/
const ip6_addr_t *
ip6_get_gateway(struct netif *netif, const ip6_addr_t *dest)
{
const ip6_addr_t *ret_gw = NULL;
const int i = ip6_find_route_entry(dest);
LWIP_UNUSED_ARG(netif);
if (i >= 0) {
if (static_route_table[i].gateway != NULL) {
ret_gw = static_route_table[i].gateway;
}
}
return ret_gw;
}
/**
* Returns the top of the route table.
* This should be used for debug printing only.
*
* @return the top of the route table.
*/
const struct ip6_route_entry *
ip6_get_route_table(void)
{
return static_route_table;
}
#endif /* LWIP_IPV6 */

View File

@ -0,0 +1,94 @@
/**
* @file
*
* IPv6 static route table.
*/
/*
* Copyright (c) 2015 Nest Labs, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* Author: Pradip De <pradipd@google.com>
*
*
* Please coordinate changes and requests with Pradip De
* <pradipd@google.com>
*/
#ifndef __LWIP_IP6_ROUTE_TABLE_H__
#define __LWIP_IP6_ROUTE_TABLE_H__
#include "lwip/opt.h"
#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */
#include "lwip/ip6_addr.h"
#include "lwip/err.h"
#ifdef __cplusplus
extern "C" {
#endif
struct netif;
/**
* LWIP_IPV6_NUM_ROUTES: Number of IPV6 routes that can be kept in the static route table.
*/
#ifndef LWIP_IPV6_NUM_ROUTE_ENTRIES
#define LWIP_IPV6_NUM_ROUTE_ENTRIES (8)
#endif
#define IP6_MAX_PREFIX_LEN (128)
#define IP6_PREFIX_ALLOWED_GRANULARITY (8)
/* Prefix length cannot be greater than 128 bits and needs to be at a byte boundary */
#define ip6_prefix_valid(prefix_len) (((prefix_len) <= IP6_MAX_PREFIX_LEN) && \
(((prefix_len) % IP6_PREFIX_ALLOWED_GRANULARITY) == 0))
struct ip6_prefix {
ip6_addr_t addr;
u8_t prefix_len; /* prefix length in bits at byte boundaries */
};
struct ip6_route_entry {
struct ip6_prefix prefix;
struct netif *netif;
const ip6_addr_t *gateway;
};
err_t ip6_add_route_entry(const struct ip6_prefix *ip6_prefix, struct netif *netif,
const ip6_addr_t *gateway, s8_t *idx);
void ip6_remove_route_entry(const struct ip6_prefix *ip6_prefix);
s8_t ip6_find_route_entry(const ip6_addr_t *ip6_dest_addr);
struct netif *ip6_static_route(const ip6_addr_t *src, const ip6_addr_t *dest);
const ip6_addr_t *ip6_get_gateway(struct netif *netif, const ip6_addr_t *dest);
const struct ip6_route_entry *ip6_get_route_table(void);
#ifdef __cplusplus
}
#endif
#endif /* LWIP_IPV6 */
#endif /* __LWIP_IP6_ROUTE_TABLE_H__ */

View File

@ -0,0 +1,164 @@
/**
* @file
* DNS-SD APIs used by LWIP_HOOK_NETCONN_EXTERNAL_RESOLVE
*
* This implementation assumes the DNS-SD API implementation (most likely provided by
* mDNSResponder) is implemented in the same process space as LwIP and can directly
* invoke the callback for DNSServiceGetAddrInfo. This is the typical deployment in
* an embedded environment where as a traditional OS requires pumping the callback results
* through an IPC mechanism (see DNSServiceRefSockFD/DNSServiceProcessResult)
*
* @defgroup dnssd DNS-SD
* @ingroup dns
*/
/*
* Copyright (c) 2017 Joel Cunningham, Garmin International, Inc. <joel.cunningham@garmin.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Joel Cunningham <joel.cunningham@me.com>
*
*/
#include "lwip/opt.h"
#include "lwip/err.h"
#include "lwip/inet.h"
#include "lwip/sockets.h"
#include "lwip/sys.h"
#include "dnssd.h"
/* External headers */
#include <string.h>
#include <dns_sd.h>
/* This timeout should allow for multiple queries.
mDNSResponder has the following query timeline:
Query 1: time = 0s
Query 2: time = 1s
Query 3: time = 4s
*/
#define GETADDR_TIMEOUT_MS 5000
#define LOCAL_DOMAIN ".local"
/* Only consume .local hosts */
#ifndef CONSUME_LOCAL_ONLY
#define CONSUME_LOCAL_ONLY 1
#endif
struct addr_clbk_msg {
sys_sem_t sem;
struct sockaddr_storage addr;
err_t err;
};
static void addr_info_callback(DNSServiceRef ref, DNSServiceFlags flags, u32_t interface_index,
DNSServiceErrorType error_code, char const* hostname,
const struct sockaddr* address, u32_t ttl, void* context);
int
lwip_dnssd_gethostbyname(const char *name, ip_addr_t *addr, u8_t addrtype, err_t *err)
{
DNSServiceErrorType result;
DNSServiceRef ref;
struct addr_clbk_msg msg;
char *p;
/* @todo: use with IPv6 */
LWIP_UNUSED_ARG(addrtype);
#if CONSUME_LOCAL_ONLY
/* check if this is a .local host. If it is, then we consume the query */
p = strstr(name, LOCAL_DOMAIN);
if (p == NULL) {
return 0; /* not consumed */
}
p += (sizeof(LOCAL_DOMAIN) - 1);
/* check to make sure .local isn't a substring (only allow .local\0 or .local.\0) */
if ((*p != '.' && *p != '\0') ||
(*p == '.' && *(p + 1) != '\0')) {
return 0; /* not consumed */
}
#endif /* CONSUME_LOCAL_ONLY */
msg.err = sys_sem_new(&msg.sem, 0);
if (msg.err != ERR_OK) {
goto query_done;
}
msg.err = ERR_TIMEOUT;
result = DNSServiceGetAddrInfo(&ref, 0, 0, kDNSServiceProtocol_IPv4, name, addr_info_callback, &msg);
if (result == kDNSServiceErr_NoError) {
sys_arch_sem_wait(&msg.sem, GETADDR_TIMEOUT_MS);
DNSServiceRefDeallocate(ref);
/* We got a response */
if (msg.err == ERR_OK) {
struct sockaddr_in* addr_in = (struct sockaddr_in *)&msg.addr;
if (addr_in->sin_family == AF_INET) {
inet_addr_to_ip4addr(ip_2_ip4(addr), &addr_in->sin_addr);
} else {
/* @todo add IPv6 support */
msg.err = ERR_VAL;
}
}
}
sys_sem_free(&msg.sem);
/* Query has been consumed and is finished */
query_done:
*err = msg.err;
return 1;
}
static void
addr_info_callback(DNSServiceRef ref, DNSServiceFlags flags, u32_t interface_index,
DNSServiceErrorType error_code, char const* hostname,
const struct sockaddr* address, u32_t ttl, void* context)
{
struct addr_clbk_msg* msg = (struct addr_clbk_msg*)context;
struct sockaddr_in* addr_in = (struct sockaddr_in *)address;
LWIP_UNUSED_ARG(ref);
LWIP_UNUSED_ARG(flags);
LWIP_UNUSED_ARG(interface_index);
LWIP_UNUSED_ARG(hostname);
LWIP_UNUSED_ARG(ttl);
LWIP_UNUSED_ARG(context);
if ((error_code == kDNSServiceErr_NoError) &&
(addr_in->sin_family == AF_INET)) {
MEMCPY(&msg->addr, addr_in, sizeof(*addr_in));
msg->err = ERR_OK;
}
else {
/* @todo add IPv6 support */
msg->err = ERR_VAL;
}
sys_sem_signal(&msg->sem);
} /* addr_info_callback() */

View File

@ -0,0 +1,50 @@
/**
* @file
* DNS-SD APIs used by LWIP_HOOK_NETCONN_EXTERNAL_RESOLVE
*
* @defgroup dnssd DNS-SD
* @ingroup dns
*/
/*
* Copyright (c) 2017 Joel Cunningham, Garmin International, Inc. <joel.cunningham@garmin.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Joel Cunningham <joel.cunningham@me.com>
*
*/
#include "lwip/opt.h"
#ifndef LWIP_HDR_DNSSD_H
#define LWIP_HDR_DNSSD_H
#include "lwip/err.h"
#include "lwip/ip_addr.h"
int lwip_dnssd_gethostbyname(const char *name, ip_addr_t *addr, u8_t addrtype, err_t *err);
#endif /* LWIP_HDR_DNSSD_H */

View File

@ -0,0 +1,182 @@
/**
* @file
*
* Reference implementation of the TCP ISN algorithm standardized in RFC 6528.
* Produce TCP Initial Sequence Numbers by combining an MD5-generated hash
* based on the new TCP connection's identity and a stable secret, with the
* current time at 4-microsecond granularity.
*
* Specifically, the implementation uses MD5 to compute a hash of the input
* buffer, which contains both the four-tuple of the new TCP connection (local
* and remote IP address and port), as well as a 16-byte secret to make the
* results unpredictable to external parties. The secret must be given at
* initialization time and should ideally remain the same across system
* reboots. To be sure: the spoofing-resistance of the resulting ISN depends
* mainly on the strength of the supplied secret!
*
* The implementation takes 32 bits from the computed hash, and adds to it the
* current time, in 4-microsecond units. The current time is computed from a
* boot time given at initialization, and the current uptime as provided by
* sys_now(). Thus, it assumes that sys_now() returns a time value that is
* relative to the boot time, i.e., that it starts at 0 at system boot, and
* only ever increases monotonically.
*
* For efficiency reasons, a single MD5 input buffer is used, and partially
* filled in at initialization time. Specifically, of this 64-byte buffer, the
* first 36 bytes are used for the four-way TCP tuple data, followed by the
* 16-byte secret, followed by 12-byte zero padding. The 64-byte size of the
* buffer should achieve the best performance for the actual MD5 computation.
*
* Basic usage:
*
* 1. in your lwipopts.h, add the following lines:
*
* #include <lwip/arch.h>
* struct ip_addr;
* u32_t lwip_hook_tcp_isn(const struct ip_addr *local_ip, u16_t local_port,
* const struct ip_addr *remote_ip, u16_t remote_port);
* "#define LWIP_HOOK_TCP_ISN lwip_hook_tcp_isn";
*
* 2. from your own code, call lwip_init_tcp_isn() at initialization time, with
* appropriate parameters.
*/
/*
* Copyright (c) 2016 The MINIX 3 Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* Author: David van Moolenbroek <david@minix3.org>
*/
#include "tcp_isn.h"
#include "lwip/ip_addr.h"
#include "lwip/sys.h"
#include <string.h>
#ifdef LWIP_HOOK_TCP_ISN
/* pull in md5 of ppp? */
#include "netif/ppp/ppp_opts.h"
#if !PPP_SUPPORT || (!LWIP_USE_EXTERNAL_POLARSSL && !LWIP_USE_EXTERNAL_MBEDTLS)
#undef LWIP_INCLUDED_POLARSSL_MD5
#define LWIP_INCLUDED_POLARSSL_MD5 1
#include "netif/ppp/polarssl/md5.h"
#endif
static u8_t input[64];
static u32_t base_time;
/**
* Initialize the TCP ISN module, with the boot time and a secret.
*
* @param boot_time Wall clock boot time of the system, in seconds.
* @param secret_16_bytes A 16-byte secret used to randomize the TCP ISNs.
*/
void
lwip_init_tcp_isn(u32_t boot_time, const u8_t *secret_16_bytes)
{
/* Initialize the input buffer with the secret and trailing zeroes. */
memset(input, 0, sizeof(input));
MEMCPY(&input[36], secret_16_bytes, 16);
/* Save the boot time in 4-us units. Overflow is no problem here. */
base_time = boot_time * 250000;
}
/**
* Hook to generate an Initial Sequence Number (ISN) for a new TCP connection.
*
* @param local_ip The local IP address.
* @param local_port The local port number, in host-byte order.
* @param remote_ip The remote IP address.
* @param remote_port The remote port number, in host-byte order.
* @return The ISN to use for the new TCP connection.
*/
u32_t
lwip_hook_tcp_isn(const ip_addr_t *local_ip, u16_t local_port,
const ip_addr_t *remote_ip, u16_t remote_port)
{
md5_context ctx;
u8_t output[16];
u32_t isn;
#if LWIP_IPV4 && LWIP_IPV6
if (IP_IS_V6(local_ip))
#endif /* LWIP_IPV4 && LWIP_IPV6 */
#if LWIP_IPV6
{
const ip6_addr_t *local_ip6, *remote_ip6;
local_ip6 = ip_2_ip6(local_ip);
remote_ip6 = ip_2_ip6(remote_ip);
SMEMCPY(&input[0], &local_ip6->addr, 16);
SMEMCPY(&input[16], &remote_ip6->addr, 16);
}
#endif /* LWIP_IPV6 */
#if LWIP_IPV4 && LWIP_IPV6
else
#endif /* LWIP_IPV4 && LWIP_IPV6 */
#if LWIP_IPV4
{
const ip4_addr_t *local_ip4, *remote_ip4;
local_ip4 = ip_2_ip4(local_ip);
remote_ip4 = ip_2_ip4(remote_ip);
/* Represent IPv4 addresses as IPv4-mapped IPv6 addresses, to ensure that
* the IPv4 and IPv6 address spaces are completely disjoint. */
memset(&input[0], 0, 10);
input[10] = 0xff;
input[11] = 0xff;
SMEMCPY(&input[12], &local_ip4->addr, 4);
memset(&input[16], 0, 10);
input[26] = 0xff;
input[27] = 0xff;
SMEMCPY(&input[28], &remote_ip4->addr, 4);
}
#endif /* LWIP_IPV4 */
input[32] = (u8_t)(local_port >> 8);
input[33] = (u8_t)(local_port & 0xff);
input[34] = (u8_t)(remote_port >> 8);
input[35] = (u8_t)(remote_port & 0xff);
/* The secret and padding are already filled in. */
/* Generate the hash, using MD5. */
md5_starts(&ctx);
md5_update(&ctx, input, sizeof(input));
md5_finish(&ctx, output);
/* Arbitrarily take the first 32 bits from the generated hash. */
MEMCPY(&isn, output, sizeof(isn));
/* Add the current time in 4-microsecond units. */
return isn + base_time + sys_now() * 250;
}
#endif /* LWIP_HOOK_TCP_ISN */

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2016 The MINIX 3 Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* Author: David van Moolenbroek <david@minix3.org>
*/
#ifndef LWIP_HDR_CONTRIB_ADDONS_TCP_ISN_H
#define LWIP_HDR_CONTRIB_ADDONS_TCP_ISN_H
#include "lwip/opt.h"
#include "lwip/ip_addr.h"
#ifdef __cplusplus
extern "C" {
#endif
void lwip_init_tcp_isn(u32_t boot_time, const u8_t *secret_16_bytes);
u32_t lwip_hook_tcp_isn(const ip_addr_t *local_ip, u16_t local_port,
const ip_addr_t *remote_ip, u16_t remote_port);
#ifdef __cplusplus
}
#endif
#endif /* LWIP_HDR_CONTRIB_ADDONS_TCP_ISN_H */

View File

@ -0,0 +1,27 @@
This folder provides an example implementation of how to add custom tcp header
options and custom socket options.
It does this by implementing the (seldom used) tcp md5 signature.
To enable it, add an LWIP_HOOK_FILENAME hook file, include tcp_md5.h in it and
define these hooks:
#define LWIP_HOOK_TCP_INPACKET_PCB(pcb, hdr, optlen, opt1len, opt2, p) tcp_md5_check_inpacket(pcb, hdr, optlen, opt1len, opt2, p)
#define LWIP_HOOK_TCP_OPT_LENGTH_SEGMENT(pcb, internal_len) tcp_md5_get_additional_option_length(pcb, internal_len)
#define LWIP_HOOK_TCP_ADD_TX_OPTIONS(p, hdr, pcb, opts) tcp_md5_add_tx_options(p, hdr, pcb, opts)
#define LWIP_HOOK_SOCKETS_SETSOCKOPT(s, sock, level, optname, optval, optlen, err) tcp_md5_setsockopt_hook(sock, level, optname, optval, optlen, err)
Then, in your sockets application, enable md5 signature on a socket like this:
struct tcp_md5sig md5;
struct sockaddr_storage addr_remote; /* Initialize this to remote address and port */
memcpy(&md5.tcpm_addr, &addr_remote, sizeof(addr_remote));
strcpy(md5.tcpm_key, key); /* this is the md5 key per connection */
md5.tcpm_keylen = strlen(key);
if ((ret = setsockopt(sockfd, IPPROTO_TCP, TCP_MD5SIG, &md5, sizeof(md5))) < 0) {
perror("setsockopt TCP_MD5SIG");
return;
}
After that, your connection (client) or all incoming connections (server) require
tcp md5 signatures.

View File

@ -0,0 +1,534 @@
/**
* @file: An implementation of TCP MD5 signatures by using various hooks in
* lwIP to implement custom tcp options and custom socket options.
*/
/*
* Copyright (c) 2018 Simon Goldschmidt
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* Author: Simon Goldschmidt <goldsimon@gmx.de>
*/
#include "tcp_md5.h"
#include "lwip/ip_addr.h"
#include "lwip/sys.h"
#include "lwip/prot/tcp.h"
#include "lwip/priv/tcp_priv.h"
#include "lwip/sockets.h"
#include "lwip/priv/sockets_priv.h"
#include "lwip/api.h"
#include <string.h>
/* pull in md5 of ppp? */
#include "netif/ppp/ppp_opts.h"
#if !PPP_SUPPORT || (!LWIP_USE_EXTERNAL_POLARSSL && !LWIP_USE_EXTERNAL_MBEDTLS)
#undef LWIP_INCLUDED_POLARSSL_MD5
#define LWIP_INCLUDED_POLARSSL_MD5 1
#include "netif/ppp/polarssl/md5.h"
#endif
#if !LWIP_TCP_PCB_NUM_EXT_ARGS
#error tcp_md5 needs LWIP_TCP_PCB_NUM_EXT_ARGS
#endif
#define LWIP_TCP_OPT_MD5 19 /* number of the md5 option */
#define LWIP_TCP_OPT_LEN_MD5 18 /* length of the md5 option */
#define LWIP_TCP_OPT_LEN_MD5_OUT 20 /* 18 + alignment */
#define LWIP_TCP_MD5_DIGEST_LEN 16
/* This keeps the md5 state internally */
struct tcp_md5_conn_info {
struct tcp_md5_conn_info *next;
ip_addr_t remote_addr;
u16_t remote_port;
u8_t key[TCP_MD5SIG_MAXKEYLEN];
u16_t key_len;
};
/* Callback function prototypes: */
static void tcp_md5_extarg_destroy(u8_t id, void *data);
static err_t tcp_md5_extarg_passive_open(u8_t id, struct tcp_pcb_listen *lpcb, struct tcp_pcb *cpcb);
/* Define our tcp ext arg callback structure: */
const struct tcp_ext_arg_callbacks tcp_md5_ext_arg_callbacks = {
tcp_md5_extarg_destroy,
tcp_md5_extarg_passive_open
};
static u8_t tcp_md5_extarg_id = LWIP_TCP_PCB_NUM_EXT_ARG_ID_INVALID;
static u8_t tcp_md5_opts_buf[40];
/** Initialize this module (allocates a tcp ext arg id) */
void
tcp_md5_init(void)
{
tcp_md5_extarg_id = tcp_ext_arg_alloc_id();
}
/* Create a conn-info structure that holds the md5 state per connection */
static struct tcp_md5_conn_info *
tcp_md5_conn_info_alloc(void)
{
return (struct tcp_md5_conn_info *)mem_malloc(sizeof(struct tcp_md5_conn_info));
}
/* Frees a conn-info structure that holds the md5 state per connection */
static void
tcp_md5_conn_info_free(struct tcp_md5_conn_info *info)
{
mem_free(info);
}
/* A pcb is about to be destroyed. Free its extdata */
static void
tcp_md5_extarg_destroy(u8_t id, void *data)
{
struct tcp_md5_conn_info *iter;
LWIP_ASSERT("tcp_md5_extarg_id != LWIP_TCP_PCB_NUM_EXT_ARG_ID_INVALID",
tcp_md5_extarg_id != LWIP_TCP_PCB_NUM_EXT_ARG_ID_INVALID);
LWIP_ASSERT("id == tcp_md5_extarg_id", id == tcp_md5_extarg_id);
LWIP_UNUSED_ARG(id);
iter = (struct tcp_md5_conn_info *)data;
while (iter != NULL) {
struct tcp_md5_conn_info *info = iter;
iter = iter->next;
tcp_md5_conn_info_free(info);
}
}
/* Try to find an md5 connection info for the specified remote connection */
static struct tcp_md5_conn_info *
tcp_md5_get_info(const struct tcp_pcb *pcb, const ip_addr_t *remote_ip, u16_t remote_port)
{
if (pcb != NULL) {
struct tcp_md5_conn_info *info = (struct tcp_md5_conn_info *)tcp_ext_arg_get(pcb, tcp_md5_extarg_id);
while (info != NULL) {
if (ip_addr_eq(&info->remote_addr, remote_ip)) {
if (info->remote_port == remote_port) {
return info;
}
}
info = info->next;
}
}
return NULL;
}
/* Passive open: copy md5 connection info from listen pcb to connection pcb
* or return error (connection will be closed)
*/
static err_t
tcp_md5_extarg_passive_open(u8_t id, struct tcp_pcb_listen *lpcb, struct tcp_pcb *cpcb)
{
struct tcp_md5_conn_info *iter;
LWIP_ASSERT("lpcb != NULL", lpcb != NULL);
LWIP_ASSERT("cpcb != NULL", cpcb != NULL);
LWIP_ASSERT("tcp_md5_extarg_id != LWIP_TCP_PCB_NUM_EXT_ARG_ID_INVALID",
tcp_md5_extarg_id != LWIP_TCP_PCB_NUM_EXT_ARG_ID_INVALID);
LWIP_ASSERT("id == tcp_md5_extarg_id", id == tcp_md5_extarg_id);
LWIP_UNUSED_ARG(id);
iter = (struct tcp_md5_conn_info *)tcp_ext_arg_get((struct tcp_pcb *)lpcb, id);
while (iter != NULL) {
if (iter->remote_port == cpcb->remote_port) {
if (ip_addr_eq(&iter->remote_addr, &cpcb->remote_ip)) {
struct tcp_md5_conn_info *info = tcp_md5_conn_info_alloc();
if (info != NULL) {
memcpy(info, iter, sizeof(struct tcp_md5_conn_info));
tcp_ext_arg_set(cpcb, id, info);
tcp_ext_arg_set_callbacks(cpcb, id, &tcp_md5_ext_arg_callbacks);
return ERR_OK;
} else {
return ERR_MEM;
}
}
}
iter = iter->next;
}
/* remote connection not found */
return ERR_VAL;
}
/* Parse tcp header options and return 1 if an md5 signature option was found */
static int
tcp_md5_parseopt(const u8_t *opts, u16_t optlen, u8_t *md5_digest_out)
{
u8_t data;
u16_t optidx;
/* Parse the TCP MSS option, if present. */
if (optlen != 0) {
for (optidx = 0; optidx < optlen; ) {
u8_t opt = opts[optidx++];
switch (opt) {
case LWIP_TCP_OPT_EOL:
/* End of options. */
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: EOL\n"));
return 0;
case LWIP_TCP_OPT_NOP:
/* NOP option. */
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: NOP\n"));
break;
case LWIP_TCP_OPT_MD5:
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: MD5\n"));
if (opts[optidx++] != LWIP_TCP_OPT_LEN_MD5 || (optidx - 2 + LWIP_TCP_OPT_LEN_MD5) > optlen) {
/* Bad length */
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: bad length\n"));
return 0;
}
/* An MD5 option with the right option length. */
memcpy(md5_digest_out, &opts[optidx], LWIP_TCP_MD5_DIGEST_LEN);
/* no need to process the options further */
return 1;
break;
default:
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: other\n"));
data = opts[optidx++];
if (data < 2) {
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: bad length\n"));
/* If the length field is zero, the options are malformed
and we don't process them further. */
return 0;
}
/* All other options have a length field, so that we easily
can skip past them. */
optidx += data - 2;
}
}
}
return 0;
}
/* Get tcp options into contiguous memory. May be required if input pbufs
* are chained.
*/
static const u8_t*
tcp_md5_options_singlebuf(struct tcp_hdr *hdr, u16_t optlen, u16_t opt1len, u8_t *opt2)
{
const u8_t *opts;
LWIP_ASSERT("hdr != NULL", hdr != NULL);
LWIP_ASSERT("optlen >= opt1len", optlen >= opt1len);
opts = (const u8_t *)hdr + TCP_HLEN;
if (optlen == opt1len) {
/* arleady in one piece */
return opts;
}
if (optlen > sizeof(tcp_md5_opts_buf)) {
/* options too long */
return NULL;
}
LWIP_ASSERT("opt2 != NULL", opt2 != NULL);
/* copy first part */
memcpy(tcp_md5_opts_buf, opts, opt1len);
/* copy second part */
memcpy(&tcp_md5_opts_buf[opt1len], opt2, optlen - opt1len);
return tcp_md5_opts_buf;
}
/* Create the md5 digest for a given segment */
static int
tcp_md5_create_digest(const ip_addr_t *ip_src, const ip_addr_t *ip_dst, const struct tcp_hdr *hdr,
const u8_t *key, size_t key_len, u8_t *digest_out, struct pbuf *p)
{
md5_context ctx;
u8_t tmp8;
u16_t tmp16;
const size_t addr_len = IP_ADDR_RAW_SIZE(*ip_src);
if (p != NULL) {
LWIP_ASSERT("pbuf must not point to tcp header here!", (const void *)hdr != p->payload);
}
/* Generate the hash, using MD5. */
md5_starts(&ctx);
/* 1. the TCP pseudo-header (in the order: source IP address,
destination IP address, zero-padded protocol number, and
segment length) */
md5_update(&ctx, (const unsigned char*)ip_src, addr_len);
md5_update(&ctx, (const unsigned char*)ip_dst, addr_len);
tmp8 = 0; /* zero-padded */
md5_update(&ctx, &tmp8, 1);
tmp8 = IP_PROTO_TCP;
md5_update(&ctx, &tmp8, 1);
tmp16 = lwip_htons(TCPH_HDRLEN_BYTES(hdr) + (p ? p->tot_len : 0));
md5_update(&ctx, (const unsigned char*)&tmp16, 2);
/* 2. the TCP header, excluding options, and assuming a checksum of
zero */
md5_update(&ctx, (const unsigned char*)hdr, sizeof(struct tcp_hdr));
/* 3. the TCP segment data (if any) */
if ((p != NULL) && (p->tot_len != 0)) {
struct pbuf *q;
for (q = p; q != NULL; q = q->next) {
md5_update(&ctx, (const unsigned char*)q->payload, q->len);
}
}
/* 4. an independently-specified key or password, known to both TCPs
and presumably connection-specific */
md5_update(&ctx, key, key_len);
md5_finish(&ctx, digest_out);
return 1;
}
/* Duplicate a tcp header and make sure the fields are in network byte order */
static void
tcp_md5_dup_tcphdr(struct tcp_hdr *tcphdr_copy, const struct tcp_hdr *tcphdr_in, int tcphdr_in_is_host_order)
{
memcpy(tcphdr_copy, tcphdr_in, sizeof(struct tcp_hdr));
tcphdr_copy->chksum = 0; /* checksum is zero for the pseudo header */
if (tcphdr_in_is_host_order) {
/* lwIP writes the TCP header values back to the buffer, we need to invert that here: */
tcphdr_copy->src = lwip_htons(tcphdr_copy->src);
tcphdr_copy->dest = lwip_htons(tcphdr_copy->dest);
tcphdr_copy->seqno = lwip_htonl(tcphdr_copy->seqno);
tcphdr_copy->ackno = lwip_htonl(tcphdr_copy->ackno);
tcphdr_copy->wnd = lwip_htons(tcphdr_copy->wnd);
tcphdr_copy->urgp = lwip_htons(tcphdr_copy->urgp);
}
}
/* Check if md5 is enabled on a given pcb */
static int
tcp_md5_is_enabled_on_pcb(const struct tcp_pcb *pcb)
{
if (tcp_md5_extarg_id != LWIP_TCP_PCB_NUM_EXT_ARG_ID_INVALID) {
struct tcp_md5_conn_info *info = (struct tcp_md5_conn_info *)tcp_ext_arg_get(pcb, tcp_md5_extarg_id);
if (info != NULL) {
return 1;
}
}
return 0;
}
/* Check if md5 is enabled on a given listen pcb */
static int
tcp_md5_is_enabled_on_lpcb(const struct tcp_pcb_listen *lpcb)
{
/* same as for connection pcbs */
return tcp_md5_is_enabled_on_pcb((const struct tcp_pcb *)lpcb);
}
/* Hook implementation for LWIP_HOOK_TCP_OPT_LENGTH_SEGMENT */
u8_t
tcp_md5_get_additional_option_length(const struct tcp_pcb *pcb, u8_t internal_option_length)
{
if ((pcb != NULL) && tcp_md5_is_enabled_on_pcb(pcb)) {
u8_t new_option_length = internal_option_length + LWIP_TCP_OPT_LEN_MD5_OUT;
LWIP_ASSERT("overflow", new_option_length > internal_option_length);
LWIP_ASSERT("options too long", new_option_length <= TCP_MAX_OPTION_BYTES);
return new_option_length;
}
return internal_option_length;
}
/* Hook implementation for LWIP_HOOK_TCP_INPACKET_PCB when called for listen pcbs */
static err_t
tcp_md5_check_listen(struct tcp_pcb_listen* lpcb, struct tcp_hdr *hdr, u16_t optlen, u16_t opt1len, u8_t *opt2)
{
LWIP_ASSERT("lpcb != NULL", lpcb != NULL);
if (tcp_md5_is_enabled_on_lpcb(lpcb)) {
const u8_t *opts;
u8_t digest_received[LWIP_TCP_MD5_DIGEST_LEN];
u8_t digest_calculated[LWIP_TCP_MD5_DIGEST_LEN];
const struct tcp_md5_conn_info *info = tcp_md5_get_info((struct tcp_pcb *)lpcb, ip_current_src_addr(), hdr->src);
if (info != NULL) {
opts = tcp_md5_options_singlebuf(hdr, optlen, opt1len, opt2);
if (opts != NULL) {
if (tcp_md5_parseopt(opts, optlen, digest_received)) {
struct tcp_hdr tcphdr_copy;
tcp_md5_dup_tcphdr(&tcphdr_copy, hdr, 1);
if (tcp_md5_create_digest(ip_current_src_addr(), ip_current_dest_addr(), &tcphdr_copy, info->key, info->key_len, digest_calculated, NULL)) {
/* everything set up, compare the digests */
if (!memcmp(digest_received, digest_calculated, LWIP_TCP_MD5_DIGEST_LEN)) {
/* equal */
return ERR_OK;
}
/* not equal */
}
}
}
}
/* md5 enabled on this pcb but no match or other error -> fail */
return ERR_VAL;
}
return ERR_OK;
}
/* Hook implementation for LWIP_HOOK_TCP_INPACKET_PCB */
err_t
tcp_md5_check_inpacket(struct tcp_pcb* pcb, struct tcp_hdr *hdr, u16_t optlen, u16_t opt1len, u8_t *opt2, struct pbuf *p)
{
LWIP_ASSERT("pcb != NULL", pcb != NULL);
if (pcb->state == LISTEN) {
return tcp_md5_check_listen((struct tcp_pcb_listen *)pcb, hdr, optlen, opt1len, opt2);
}
if (tcp_md5_is_enabled_on_pcb(pcb)) {
const struct tcp_md5_conn_info *info = tcp_md5_get_info(pcb, ip_current_src_addr(), hdr->src);
if (info != NULL) {
const u8_t *opts;
u8_t digest_received[LWIP_TCP_MD5_DIGEST_LEN];
u8_t digest_calculated[LWIP_TCP_MD5_DIGEST_LEN];
opts = tcp_md5_options_singlebuf(hdr, optlen, opt1len, opt2);
if (opts != NULL) {
if (tcp_md5_parseopt(opts, optlen, digest_received)) {
struct tcp_hdr hdr_copy;
tcp_md5_dup_tcphdr(&hdr_copy, hdr, 1);
if (tcp_md5_create_digest(&pcb->remote_ip, &pcb->local_ip, &hdr_copy, info->key, info->key_len, digest_calculated, p)) {
/* everything set up, compare the digests */
if (!memcmp(digest_received, digest_calculated, LWIP_TCP_MD5_DIGEST_LEN)) {
/* equal */
return ERR_OK;
}
/* not equal */
}
}
}
}
/* md5 enabled on this pcb but no match or other error -> fail */
return ERR_VAL;
}
return ERR_OK;
}
/* Hook implementation for LWIP_HOOK_TCP_ADD_TX_OPTIONS */
u32_t *
tcp_md5_add_tx_options(struct pbuf *p, struct tcp_hdr *hdr, const struct tcp_pcb *pcb, u32_t *opts)
{
LWIP_ASSERT("p != NULL", p != NULL);
LWIP_ASSERT("hdr != NULL", hdr != NULL);
LWIP_ASSERT("pcb != NULL", pcb != NULL);
LWIP_ASSERT("opts != NULL", opts != NULL);
if (tcp_md5_is_enabled_on_pcb(pcb)) {
u8_t digest_calculated[LWIP_TCP_MD5_DIGEST_LEN];
u32_t *opts_ret = opts + 5; /* we use 20 bytes: 2 bytes padding + 18 bytes for this option */
u8_t *ptr = (u8_t*)opts;
const struct tcp_md5_conn_info *info = tcp_md5_get_info(pcb, &pcb->remote_ip, pcb->remote_port);
if (info != NULL) {
struct tcp_hdr hdr_copy;
size_t hdrsize = TCPH_HDRLEN_BYTES(hdr);
tcp_md5_dup_tcphdr(&hdr_copy, hdr, 0);
/* p->payload points to the tcp header */
LWIP_ASSERT("p->payload == hdr", p->payload == hdr);
if (!pbuf_remove_header(p, hdrsize)) {
u8_t ret;
if (!tcp_md5_create_digest(&pcb->local_ip, &pcb->remote_ip, &hdr_copy, info->key, info->key_len, digest_calculated, p)) {
info = NULL;
}
ret = pbuf_add_header_force(p, hdrsize);
LWIP_ASSERT("tcp_md5_add_tx_options: pbuf_add_header_force failed", !ret);
LWIP_UNUSED_ARG(ret);
} else {
LWIP_ASSERT("error", 0);
}
}
if (info == NULL) {
/* create an invalid signature by zeroing the digest */
memset(&digest_calculated, 0, sizeof(digest_calculated));
}
*ptr++ = LWIP_TCP_OPT_NOP;
*ptr++ = LWIP_TCP_OPT_NOP;
*ptr++ = LWIP_TCP_OPT_MD5;
*ptr++ = LWIP_TCP_OPT_LEN_MD5;
memcpy(ptr, digest_calculated, LWIP_TCP_MD5_DIGEST_LEN);
ptr += LWIP_TCP_MD5_DIGEST_LEN;
LWIP_ASSERT("ptr == opts_ret", ptr == (u8_t *)opts_ret);
return opts_ret;
}
return opts;
}
/* Hook implementation for LWIP_HOOK_SOCKETS_SETSOCKOPT */
int
tcp_md5_setsockopt_hook(struct lwip_sock *sock, int level, int optname, const void *optval, socklen_t optlen, int *err)
{
LWIP_ASSERT("sock != NULL", sock != NULL);
LWIP_ASSERT("err != NULL", err != NULL);
if ((level == IPPROTO_TCP) && (optname == TCP_MD5SIG)) {
const struct tcp_md5sig *md5 = (const struct tcp_md5sig*)optval;
if ((optval == NULL) || (optlen < sizeof(struct tcp_md5sig))) {
*err = EINVAL;
} else {
if (sock->conn && (NETCONNTYPE_GROUP(netconn_type(sock->conn)) == NETCONN_TCP) && (sock->conn->pcb.tcp != NULL)) {
if (tcp_md5_extarg_id == LWIP_TCP_PCB_NUM_EXT_ARG_ID_INVALID) {
/* not initialized */
*err = EINVAL;
} else {
struct tcp_md5_conn_info *info = tcp_md5_conn_info_alloc();
if (info == NULL) {
*err = ENOMEM;
} else {
int addr_valid = 0;
/* OK, fill and link this request */
memcpy(info->key, md5->tcpm_key, TCP_MD5SIG_MAXKEYLEN);
info->key_len = md5->tcpm_keylen;
memset(&info->remote_addr, 0, sizeof(info->remote_addr));
if (md5->tcpm_addr.ss_family == AF_INET) {
#if LWIP_IPV4
const struct sockaddr_in *sin = (const struct sockaddr_in *)&md5->tcpm_addr;
memcpy(&info->remote_addr, &sin->sin_addr, sizeof(sin->sin_addr));
IP_SET_TYPE_VAL(info->remote_addr, IPADDR_TYPE_V4);
info->remote_port = lwip_htons(sin->sin_port);
addr_valid = 1;
#endif /* LWIP_IPV4 */
} else if (md5->tcpm_addr.ss_family == AF_INET6) {
#if LWIP_IPV6
const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)&md5->tcpm_addr;
memcpy(&info->remote_addr, &sin6->sin6_addr, sizeof(sin6->sin6_addr));
IP_SET_TYPE_VAL(info->remote_addr, IPADDR_TYPE_V6);
info->remote_port = lwip_htons(sin6->sin6_port);
addr_valid = 1;
#endif /* LWIP_IPV6 */
}
if (addr_valid) {
/* store it */
tcp_ext_arg_set_callbacks(sock->conn->pcb.tcp, tcp_md5_extarg_id, &tcp_md5_ext_arg_callbacks);
info->next = (struct tcp_md5_conn_info *)tcp_ext_arg_get(sock->conn->pcb.tcp, tcp_md5_extarg_id);
tcp_ext_arg_set(sock->conn->pcb.tcp, tcp_md5_extarg_id, info);
} else {
*err = EINVAL;
tcp_md5_conn_info_free(info);
}
}
}
} else {
/* not a tcp netconn */
*err = EINVAL;
}
}
return 1;
}
return 0;
}

View File

@ -0,0 +1,84 @@
/*
* Copyright (c) 2018 Simon Goldschmidt
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* Author: Simon Goldschmidt <goldsimon@gmx.de>
*
* To use the hooks in this file, make sure this file is included in LWIP_HOOK_FILENAME
* and define these hooks:
*
* #define LWIP_HOOK_TCP_INPACKET_PCB(pcb, hdr, optlen, opt1len, opt2, p) tcp_md5_check_inpacket(pcb, hdr, optlen, opt1len, opt2, p)
* #define LWIP_HOOK_TCP_OPT_LENGTH_SEGMENT(pcb, internal_len) tcp_md5_get_additional_option_length(pcb, internal_len)
* #define LWIP_HOOK_TCP_ADD_TX_OPTIONS(p, hdr, pcb, opts) tcp_md5_add_tx_options(p, hdr, pcb, opts)
*
* #define LWIP_HOOK_SOCKETS_SETSOCKOPT(s, sock, level, optname, optval, optlen, err) tcp_md5_setsockopt_hook(sock, level, optname, optval, optlen, err)
*/
#ifndef LWIP_HDR_CONTRIB_ADDONS_TCP_MD5_H
#define LWIP_HDR_CONTRIB_ADDONS_TCP_MD5_H
#include "lwip/opt.h"
#include "lwip/ip_addr.h"
#include "lwip/err.h"
#include "lwip/priv/sockets_priv.h"
#include "lwip/priv/tcp_priv.h"
#ifdef __cplusplus
extern "C" {
#endif
/* setsockopt definitions and structs: */
/* This is the optname (for level = IPPROTO_TCP) */
#ifndef TCP_MD5SIG
#define TCP_MD5SIG 14
#endif
#define TCP_MD5SIG_MAXKEYLEN 80
/* This is the optval type */
struct tcp_md5sig {
struct sockaddr_storage tcpm_addr;
u16_t __tcpm_pad1;
u16_t tcpm_keylen;
u32_t __tcpm_pad2;
u8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN];
};
/* socket setsockopt hook: */
int tcp_md5_setsockopt_hook(struct lwip_sock *sock, int level, int optname, const void *optval, u32_t optlen, int *err);
/* Internal hook functions */
void tcp_md5_init(void);
err_t tcp_md5_check_inpacket(struct tcp_pcb* pcb, struct tcp_hdr *hdr, u16_t optlen, u16_t opt1len, u8_t *opt2, struct pbuf *p);
u8_t tcp_md5_get_additional_option_length(const struct tcp_pcb *pcb, u8_t internal_option_length);
u32_t *tcp_md5_add_tx_options(struct pbuf *p, struct tcp_hdr *hdr, const struct tcp_pcb *pcb, u32_t *opts);
#ifdef __cplusplus
}
#endif
#endif /* LWIP_HDR_CONTRIB_ADDONS_TCP_MD5_H */

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7DA7C0AB-0982-4BF5-9324-F59A7A08D65B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CCodeGeneration</RootNamespace>
<AssemblyName>CCodeGeneration</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="CFile.cs" />
<Compile Include="Code.cs" />
<Compile Include="CodeContainerBase.cs" />
<Compile Include="CodeElement.cs" />
<Compile Include="Comment.cs" />
<Compile Include="EmptyLine.cs" />
<Compile Include="Function.cs" />
<Compile Include="CGenerator.cs" />
<Compile Include="IfThenElse.cs" />
<Compile Include="PlainText.cs" />
<Compile Include="Switch.cs" />
<Compile Include="PP_If.cs" />
<Compile Include="PP_Ifdef.cs" />
<Compile Include="PP_Include.cs" />
<Compile Include="FunctionDeclaration.cs" />
<Compile Include="PP_Macro.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="VariableDeclaration.cs" />
<Compile Include="VariablePrototype.cs" />
<Compile Include="VariableType.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,54 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
namespace CCodeGeneration
{
public class CFile: CodeContainerBase
{
public CFile()
{
base.IncreaseLevel = false;
}
public void Save(CGenerator generator)
{
if (generator == null)
{
throw new ArgumentNullException("generator");
}
this.GenerateCode(0, generator);
}
}
}

View File

@ -0,0 +1,119 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using System.IO;
namespace CCodeGeneration
{
public class CGenerator
{
public TextWriter OutputStream { get; private set; }
public string File { get; private set; }
public uint IndentCount { get; private set; }
public string IndentChar { get; private set; }
public string NewLine { get; private set; }
public CGenerator(System.IO.TextWriter outputStream, string file, uint indentCount, string indentChar, string newLine)
{
this.OutputStream = outputStream;
this.File = file;
this.IndentCount = indentCount;
this.IndentChar = indentChar;
this.NewLine = newLine;
}
public string FileName
{
get
{
if (!String.IsNullOrWhiteSpace(this.File))
{
return Path.GetFileName(this.File);
}
return null;
}
}
public void WriteSequence(string value, uint repetitions)
{
while (repetitions > 0)
{
this.OutputStream.Write(value);
repetitions--;
}
}
public void IndentLine(int level)
{
while (level > 0)
{
WriteSequence(this.IndentChar, this.IndentCount);
level--;
}
}
public void WriteNewLine()
{
this.OutputStream.Write(this.NewLine);
}
public void WriteMultilineString(string value, int level = 0)
{
if (String.IsNullOrEmpty(value))
{
return;
}
// only \n and \r\n are recognized as linebreaks
string[] lines = value.Split(new char[] { '\n' }, StringSplitOptions.None);
for (int l = 0; l < (lines.Length - 1); l++)
{
if (lines[l].EndsWith("\r"))
{
this.OutputStream.Write(lines[l].Substring(0, lines[l].Length-1));
}
else
{
this.OutputStream.Write(lines[l]);
}
this.WriteNewLine();
this.IndentLine(level);
}
this.OutputStream.Write(lines[lines.Length - 1]);
}
}
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
namespace CCodeGeneration
{
public class Code: CodeElement
{
public string Code_ { get; set; }
public Code()
{
}
public Code(string code)
{
this.Code_ = code;
}
public override void GenerateCode(int level, CGenerator generator)
{
generator.IndentLine(level);
generator.WriteMultilineString(this.Code_, level);
generator.WriteNewLine();
}
}
}

View File

@ -0,0 +1,139 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System.Collections.Generic;
using System;
namespace CCodeGeneration
{
public class CodeContainerBase: CodeElement
{
private readonly List<CodeElement> declarations = new List<CodeElement>();
private readonly List<CodeElement> innerElements = new List<CodeElement>();
private bool increaseLevel = true;
public List<CodeElement> Declarations
{
get { return this.declarations; }
}
public List<CodeElement> InnerElements
{
get { return this.innerElements; }
}
protected bool IncreaseLevel
{
get { return this.increaseLevel; }
set { this.increaseLevel = value; }
}
public void AddElements(IList<CodeElement> elements, params CodeElement[] spacerElements)
{
if (elements != null)
{
if ((spacerElements == null) || (spacerElements.Length == 0))
{
this.innerElements.AddRange(elements);
}
else
{
bool spacerAdded = false;
foreach (CodeElement element in elements)
{
this.innerElements.Add(element);
this.innerElements.AddRange(spacerElements);
spacerAdded = true;
}
if (spacerAdded)
{
// remove last spacer again
this.innerElements.RemoveRange(this.innerElements.Count - spacerElements.Length, spacerElements.Length);
}
}
}
}
public CodeElement AddElement(CodeElement element)
{
if (element != null)
{
this.innerElements.Add(element);
}
return element;
}
public Code AddCode(string code)
{
return this.AddElement(new Code(code)) as Code;
}
public Code AddCodeFormat(string codeFormat, params object[] args)
{
return this.AddElement(new Code(String.Format(codeFormat, args))) as Code;
}
public CodeElement AddDeclaration(CodeElement declaration)
{
if (declaration != null)
{
this.declarations.Add(declaration);
}
return declaration;
}
public override void GenerateCode(int level, CGenerator generator)
{
if (this.increaseLevel)
level++;
if (this.declarations.Count > 0)
{
foreach (CodeElement element in this.declarations)
{
element.GenerateCode(level, generator);
}
EmptyLine.SingleLine.GenerateCode(level, generator);
}
foreach (CodeElement element in this.innerElements)
{
element.GenerateCode(level, generator);
}
}
}
}

View File

@ -0,0 +1,41 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
namespace CCodeGeneration
{
public class CodeElement
{
public virtual void GenerateCode(int level, CGenerator generator)
{
}
}
}

View File

@ -0,0 +1,75 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
namespace CCodeGeneration
{
public class Comment: CodeElement
{
public const string CommentStart = "/*";
public const string CommentEnd = "*/";
public string Comment_ { get; set; }
public bool SingleLine { get; set; }
public Comment()
{
}
public Comment(string comment, bool singleLine = false)
{
this.Comment_ = comment;
this.SingleLine = singleLine;
}
public override void GenerateCode(int level, CGenerator generator)
{
generator.IndentLine(level);
generator.OutputStream.Write(CommentStart);
if (!this.SingleLine)
{
generator.WriteNewLine();
generator.IndentLine(level);
generator.WriteMultilineString(this.Comment_, level);
generator.WriteNewLine();
generator.IndentLine(level);
}
else
{
generator.OutputStream.Write(" " + Comment_ + " ");
}
generator.OutputStream.Write(CommentEnd);
generator.WriteNewLine();
}
}
}

View File

@ -0,0 +1,64 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
namespace CCodeGeneration
{
public class EmptyLine : CodeElement
{
public static readonly EmptyLine SingleLine = new EmptyLine();
public static readonly EmptyLine TwoLines = new EmptyLine(2);
public static readonly EmptyLine ThreeLines = new EmptyLine(3);
public uint Count { get; set; }
public EmptyLine()
{
this.Count = 1;
}
public EmptyLine(uint count)
{
this.Count = count;
}
public override void GenerateCode(int level, CGenerator generator)
{
uint c = this.Count;
while (c > 0)
{
generator.WriteNewLine();
c--;
}
}
}
}

View File

@ -0,0 +1,129 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using System.Collections.Generic;
namespace CCodeGeneration
{
public class Function: CodeContainerBase
{
public string Name { get; set; }
public bool IsStatic { get; set; }
private readonly List<VariableType> parameter = new List<VariableType>();
private VariableType returnType = VariableType.Void;
public Function()
{
}
public Function(string name, bool isStatic = false)
{
this.Name = name;
this.IsStatic = isStatic;
}
public List<VariableType> Parameter
{
get { return this.parameter; }
}
public VariableType ReturnType
{
get { return this.returnType; }
set
{
if (value == null)
{
throw new ArgumentNullException("ReturnValue");
}
this.returnType = value;
}
}
public static Function FromDeclaration(FunctionDeclaration decl)
{
Function result = new Function(decl.Name, decl.IsStatic);
result.ReturnType = decl.ReturnType.Clone() as VariableType;
foreach (VariableType param in decl.Parameter)
{
result.parameter.Add(param.Clone() as VariableType);
}
return result;
}
public override void GenerateCode(int level, CGenerator generator)
{
generator.IndentLine(level);
if (this.IsStatic)
{
generator.OutputStream.Write("static ");
}
this.returnType.GenerateCode(generator);
generator.OutputStream.Write(" " + this.Name + "(");
if (this.Parameter.Count > 0)
{
for (int i = 0; i < this.parameter.Count; i++)
{
this.parameter[i].GenerateCode(generator);
if (i < (this.parameter.Count - 1))
{
generator.OutputStream.Write(", ");
}
}
}
else
{
generator.OutputStream.Write("void");
}
generator.OutputStream.Write(")");
generator.WriteNewLine();
generator.IndentLine(level);
generator.OutputStream.Write("{");
generator.WriteNewLine();
base.GenerateCode(level, generator);
generator.IndentLine(level);
generator.OutputStream.Write("}");
generator.WriteNewLine();
}
}
}

View File

@ -0,0 +1,114 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using System.Collections.Generic;
namespace CCodeGeneration
{
public class FunctionDeclaration: CodeElement
{
public string Name { get; set; }
public bool IsStatic { get; set; }
public bool IsExtern { get; set; }
private readonly List<VariableType> parameter = new List<VariableType>();
private VariableType returnType = VariableType.Void;
public FunctionDeclaration()
{
}
public FunctionDeclaration(string name, bool isStatic = false, bool isExtern = false)
{
this.Name = name;
this.IsStatic = isStatic;
this.IsExtern = isExtern;
}
public List<VariableType> Parameter
{
get { return this.parameter; }
}
public VariableType ReturnType
{
get { return this.returnType; }
set
{
if (value == null)
{
throw new ArgumentNullException("ReturnValue");
}
this.returnType = value;
}
}
public override void GenerateCode(int level, CGenerator generator)
{
generator.IndentLine(level);
if (this.IsExtern)
{
generator.OutputStream.Write("extern ");
}
if (this.IsStatic)
{
generator.OutputStream.Write("static ");
}
this.returnType.GenerateCode(generator);
generator.OutputStream.Write(" " + this.Name + "(");
if (this.Parameter.Count > 0)
{
for (int i = 0; i < this.parameter.Count; i++)
{
this.parameter[i].GenerateCode(generator);
if (i < (this.parameter.Count - 1))
{
generator.OutputStream.Write(", ");
}
}
}
else
{
generator.OutputStream.Write("void");
}
generator.OutputStream.Write(");");
generator.WriteNewLine();
}
}
}

View File

@ -0,0 +1,137 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using System.Collections.Generic;
namespace CCodeGeneration
{
public class ElseIf : CodeContainerBase
{
public string Condition { get; set; }
public ElseIf()
{
}
public ElseIf(string condition)
{
this.Condition = condition;
}
public override void GenerateCode(int level, CGenerator generator)
{
if (!String.IsNullOrWhiteSpace(this.Condition))
{
generator.IndentLine(level);
generator.OutputStream.Write(String.Format("else if ({0})", this.Condition));
generator.WriteNewLine();
generator.IndentLine(level);
generator.OutputStream.Write("{");
generator.WriteNewLine();
base.GenerateCode(level, generator);
generator.IndentLine(level);
generator.OutputStream.Write("}");
generator.WriteNewLine();
}
}
}
public class IfThenElse: CodeContainerBase
{
public string Condition { get; set; }
private List<ElseIf> elseIf = new List<ElseIf>();
private CodeContainerBase else_ = new CodeContainerBase();
public IfThenElse()
{
}
public IfThenElse(string condition)
{
this.Condition = condition;
}
public List<ElseIf> ElseIf
{
get { return this.elseIf; }
}
public CodeContainerBase Else
{
get { return this.else_; }
}
public override void GenerateCode(int level, CGenerator generator)
{
if (!String.IsNullOrWhiteSpace(this.Condition))
{
generator.IndentLine(level);
generator.OutputStream.Write(String.Format("if ({0})", this.Condition));
generator.WriteNewLine();
generator.IndentLine(level);
generator.OutputStream.Write("{");
generator.WriteNewLine();
base.GenerateCode(level, generator);
generator.IndentLine(level);
generator.OutputStream.Write("}");
generator.WriteNewLine();
foreach (ElseIf elif in this.elseIf)
{
elif.GenerateCode(level, generator);
}
if (this.else_.InnerElements.Count > 0)
{
generator.IndentLine(level);
generator.OutputStream.Write("else");
generator.WriteNewLine();
generator.IndentLine(level);
generator.OutputStream.Write("{");
generator.WriteNewLine();
this.else_.GenerateCode(level, generator);
generator.IndentLine(level);
generator.OutputStream.Write("}");
generator.WriteNewLine();
}
}
}
}
}

View File

@ -0,0 +1,67 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
namespace CCodeGeneration
{
public class PP_If: CodeContainerBase
{
public string Condition { get; set; }
public PP_If()
{
base.IncreaseLevel = false;
}
public PP_If(string condition)
: this()
{
this.Condition = condition;
}
public override void GenerateCode(int level, CGenerator generator)
{
if (!String.IsNullOrWhiteSpace(this.Condition))
{
generator.OutputStream.Write("#if " + this.Condition);
generator.WriteNewLine();
base.GenerateCode(level, generator);
generator.OutputStream.Write("#endif /* " + this.Condition + " */");
generator.WriteNewLine();
}
}
}
}

View File

@ -0,0 +1,76 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
namespace CCodeGeneration
{
public class PP_Ifdef: CodeContainerBase
{
public string Macro { get; set; }
public bool Inverted { get; set; }
public PP_Ifdef()
{
base.IncreaseLevel = false;
}
public PP_Ifdef(string macro, bool inverted = false)
: this()
{
this.Macro = macro;
this.Inverted = inverted;
}
public override void GenerateCode(int level, CGenerator generator)
{
if (!String.IsNullOrWhiteSpace(this.Macro))
{
if (this.Inverted)
{
generator.OutputStream.Write("#ifndef " + this.Macro);
}
else
{
generator.OutputStream.Write("#ifdef " + this.Macro);
}
generator.WriteNewLine();
base.GenerateCode(level, generator);
generator.OutputStream.Write("#endif /* " + this.Macro + " */");
generator.WriteNewLine();
}
}
}
}

View File

@ -0,0 +1,71 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
namespace CCodeGeneration
{
public class PP_Include : CodeElement
{
public string File { get; set; }
public bool IsLocal { get; set; }
public PP_Include()
{
this.IsLocal = true;
}
public PP_Include(string file, bool isLocal = true)
{
this.File = file;
this.IsLocal = isLocal;
}
public override void GenerateCode(int level, CGenerator generator)
{
if (!String.IsNullOrWhiteSpace(this.File))
{
// includes are never indented
if (this.IsLocal)
{
generator.OutputStream.Write("#include \"" + this.File + "\"");
}
else
{
generator.OutputStream.Write("#include <" + this.File + ">");
}
generator.WriteNewLine();
}
}
}
}

View File

@ -0,0 +1,59 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
namespace CCodeGeneration
{
public class PP_Macro: CodeElement
{
public string Name { get; set; }
public string Value { get; set; }
public PP_Macro()
{
}
public PP_Macro(string name, string value)
{
this.Name = name;
this.Value = value;
}
public override void GenerateCode(int level, CGenerator generator)
{
// macros are not indented at all
generator.OutputStream.Write("#define " + this.Name + " ");
generator.WriteMultilineString(this.Value);
generator.WriteNewLine();
}
}
}

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
namespace CCodeGeneration
{
public class PlainText : CodeElement
{
public string Value { get; set; }
public PlainText(string value)
{
this.Value = value;
}
public override void GenerateCode(int level, CGenerator generator)
{
generator.WriteMultilineString(this.Value);
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("CCodeGeneration")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CCodeGeneration")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("8f07a0fa-86f4-48a0-97c7-f94fc5c3f103")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,146 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using System.Collections.Generic;
namespace CCodeGeneration
{
public class SwitchCase : CodeContainerBase
{
public string Value { get; set; }
public SwitchCase()
{
}
public SwitchCase(string value)
{
this.Value = value;
}
public bool IsDefault
{
get { return (this.Value.ToLowerInvariant() == "default"); }
}
public static SwitchCase GenerateDefault()
{
return new SwitchCase("default");
}
public override void GenerateCode(int level, CGenerator generator)
{
if (!String.IsNullOrWhiteSpace(this.Value))
{
generator.IndentLine(level);
if (this.IsDefault)
{
generator.OutputStream.Write("default:");
}
else
{
generator.OutputStream.Write(String.Format("case {0}:", this.Value));
}
generator.WriteNewLine();
generator.IndentLine(level + 1);
generator.OutputStream.Write("{");
generator.WriteNewLine();
base.GenerateCode(level + 1, generator);
generator.IndentLine(level + 1);
generator.OutputStream.Write("}");
generator.WriteNewLine();
generator.IndentLine(level + 1);
generator.OutputStream.Write("break;");
generator.WriteNewLine();
}
}
}
public class Switch: CodeElement
{
public string SwitchVar { get; set; }
private List<SwitchCase> switches = new List<SwitchCase>();
public Switch()
{
}
public Switch(string switchVar)
{
this.SwitchVar = switchVar;
}
public List<SwitchCase> Switches
{
get { return this.switches; }
}
public override void GenerateCode(int level, CGenerator generator)
{
if (!String.IsNullOrWhiteSpace(this.SwitchVar))
{
generator.IndentLine(level);
generator.OutputStream.Write(String.Format("switch ({0})", this.SwitchVar));
generator.WriteNewLine();
generator.IndentLine(level);
generator.OutputStream.Write("{");
generator.WriteNewLine();
SwitchCase defaultCase = null; // generate 'default' always as last case
foreach (SwitchCase switchCase in this.switches)
{
if (switchCase.IsDefault)
{
defaultCase = switchCase;
}
else
{
switchCase.GenerateCode(level + 1, generator);
}
}
if (defaultCase != null)
{
defaultCase.GenerateCode(level + 1, generator);
}
generator.IndentLine(level);
generator.OutputStream.Write("}");
generator.WriteNewLine();
}
}
}
}

View File

@ -0,0 +1,82 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
namespace CCodeGeneration
{
public class VariableDeclaration : CodeElement
{
public VariableType Type { get; set; }
public string InitialValue { get; set; }
public bool IsStatic { get; set; }
public VariableDeclaration()
: base()
{
}
public VariableDeclaration(VariableType type, string initialValue = null, bool isStatic = false) :
base()
{
this.Type = type;
this.InitialValue = initialValue;
this.IsStatic = isStatic;
}
public override void GenerateCode(int level, CGenerator generator)
{
if (this.Type != null)
{
generator.IndentLine(level);
if (this.IsStatic)
{
generator.OutputStream.Write("static ");
}
// declare the variable
this.Type.GenerateCode(generator);
if (!String.IsNullOrWhiteSpace(this.InitialValue))
{
// add initialization value
generator.OutputStream.Write(" = ");
generator.WriteMultilineString(this.InitialValue, level);
}
generator.OutputStream.Write(";");
generator.WriteNewLine();
}
}
}
}

View File

@ -0,0 +1,73 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
namespace CCodeGeneration
{
public class VariablePrototype : CodeElement
{
public VariableType Type { get; set; }
public VariablePrototype()
: base()
{
}
public VariablePrototype(VariableType type) :
base()
{
Type = type;
}
public static VariablePrototype FromVariableDeclaration(VariableDeclaration declaration)
{
return new VariablePrototype(declaration.Type);
}
public override void GenerateCode(int level, CGenerator generator)
{
if (this.Type != null)
{
generator.IndentLine(level);
generator.OutputStream.Write("extern ");
// declare the variable
this.Type.GenerateCode(generator);
generator.OutputStream.Write(";");
generator.WriteNewLine();
}
}
}
}

View File

@ -0,0 +1,130 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using System.Text;
namespace CCodeGeneration
{
public enum ConstType
{
None,
Value,
Indirection,
Both
}
public class VariableType : ICloneable
{
public const string VoidString = "void";
public static readonly VariableType Void = new VariableType(null, "void");
public string Name { get; set; }
public string Type { get; set; }
public string Indirection { get; set; }
public ConstType Const { get; set; }
public string ArraySpecifier { get; set; }
public VariableType()
{
}
public VariableType(string name, string type, string indirection = null, ConstType const_ = ConstType.None, string arraySpecifier = null)
{
this.Name = name;
this.Type = type;
this.Indirection = indirection;
this.Const = const_;
this.ArraySpecifier = arraySpecifier;
}
public void GenerateCode(CGenerator generator)
{
if (!String.IsNullOrWhiteSpace(this.Type))
{
generator.OutputStream.Write(this.ToString().Trim());
}
}
public override string ToString()
{
if (!String.IsNullOrWhiteSpace(this.Type))
{
StringBuilder vt = new StringBuilder();
if ((this.Const == ConstType.Value) || (this.Const == ConstType.Both))
{
vt.Append("const ");
}
vt.Append(this.Type);
vt.Append(" ");
if (!String.IsNullOrWhiteSpace(this.Indirection))
{
vt.Append(this.Indirection);
}
if ((this.Const == ConstType.Indirection) || (this.Const == ConstType.Both))
{
vt.Append("const ");
}
if (!String.IsNullOrWhiteSpace(this.Name))
{
vt.Append(this.Name);
}
if (this.ArraySpecifier != null)
{
vt.Append("[");
vt.Append(this.ArraySpecifier);
vt.Append("]");
}
return vt.ToString().Trim();
}
return base.ToString();
}
#region ICloneable Member
public object Clone()
{
// we only have value types as members -> simply use .net base function
return this.MemberwiseClone();
}
#endregion
}
}

View File

@ -0,0 +1,47 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LwipMibCompiler", "LwipMibCompiler\LwipMibCompiler.csproj", "{C25D5640-D999-49BD-82E0-A1975296A91E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LwipSnmpCodeGeneration", "LwipSnmpCodeGeneration\LwipSnmpCodeGeneration.csproj", "{AABCAB90-1540-45D4-A159-14831A54E9A3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CCodeGeneration", "CCodeGeneration\CCodeGeneration.csproj", "{7DA7C0AB-0982-4BF5-9324-F59A7A08D65B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpSnmpLib.Mib", "SharpSnmpLib\SharpSnmpLib.Mib.csproj", "{CBE20411-5DB7-487D-825D-7694267BB6F5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MibViewer", "MibViewer\MibViewer.csproj", "{86CC0B65-7985-4017-A252-0A7A18DCAEF3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7DA7C0AB-0982-4BF5-9324-F59A7A08D65B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7DA7C0AB-0982-4BF5-9324-F59A7A08D65B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7DA7C0AB-0982-4BF5-9324-F59A7A08D65B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7DA7C0AB-0982-4BF5-9324-F59A7A08D65B}.Release|Any CPU.Build.0 = Release|Any CPU
{86CC0B65-7985-4017-A252-0A7A18DCAEF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{86CC0B65-7985-4017-A252-0A7A18DCAEF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{86CC0B65-7985-4017-A252-0A7A18DCAEF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{86CC0B65-7985-4017-A252-0A7A18DCAEF3}.Release|Any CPU.Build.0 = Release|Any CPU
{AABCAB90-1540-45D4-A159-14831A54E9A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AABCAB90-1540-45D4-A159-14831A54E9A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AABCAB90-1540-45D4-A159-14831A54E9A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AABCAB90-1540-45D4-A159-14831A54E9A3}.Release|Any CPU.Build.0 = Release|Any CPU
{C25D5640-D999-49BD-82E0-A1975296A91E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C25D5640-D999-49BD-82E0-A1975296A91E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C25D5640-D999-49BD-82E0-A1975296A91E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C25D5640-D999-49BD-82E0-A1975296A91E}.Release|Any CPU.Build.0 = Release|Any CPU
{CBE20411-5DB7-487D-825D-7694267BB6F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CBE20411-5DB7-487D-825D-7694267BB6F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CBE20411-5DB7-487D-825D-7694267BB6F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CBE20411-5DB7-487D-825D-7694267BB6F5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = LwipMibCompiler\LwipMibCompiler.csproj
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C25D5640-D999-49BD-82E0-A1975296A91E}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LwipMibCompiler</RootNamespace>
<AssemblyName>LwipMibCompiler</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
<WarningLevel>4</WarningLevel>
<Optimize>false</Optimize>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CCodeGeneration\CCodeGeneration.csproj">
<Project>{7DA7C0AB-0982-4BF5-9324-F59A7A08D65B}</Project>
<Name>CCodeGeneration</Name>
</ProjectReference>
<ProjectReference Include="..\LwipSnmpCodeGeneration\LwipSnmpCodeGeneration.csproj">
<Project>{AABCAB90-1540-45D4-A159-14831A54E9A3}</Project>
<Name>LwipSnmpCodeGeneration</Name>
</ProjectReference>
<ProjectReference Include="..\SharpSnmpLib\SharpSnmpLib.Mib.csproj">
<Project>{CBE20411-5DB7-487D-825D-7694267BB6F5}</Project>
<Name>SharpSnmpLib.Mib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,480 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
using CCodeGeneration;
using Lextm.SharpSnmpLib.Mib;
using Lextm.SharpSnmpLib.Mib.Elements.Entities;
using Lextm.SharpSnmpLib.Mib.Elements.Types;
using LwipSnmpCodeGeneration;
namespace LwipMibCompiler
{
class Program
{
private static readonly Regex _alphaNumericRegex = new Regex("[^a-zA-Z0-9]");
static void Main(string[] args)
{
Console.WriteLine("lwIP MIB Compiler");
Console.WriteLine("");
// check args
if ((args.Length < 2) || String.IsNullOrWhiteSpace(args[0]) || String.IsNullOrWhiteSpace(args[1]))
{
PrintUsage();
return;
}
string mibFile = args[0];
if (!File.Exists(mibFile))
{
Console.WriteLine(String.Format("Unable to find file '{0}'!", mibFile));
}
string destFile = args[1];
string destHeaderFile;
if (Directory.Exists(destFile))
{
// only directory passed -> create dest filename from mib filename
string mibFileName = Path.GetFileNameWithoutExtension(mibFile).ToLowerInvariant();
destFile = Path.Combine(destFile, mibFileName + ".c");
}
string destFileExt = Path.GetExtension(destFile);
if (!String.IsNullOrEmpty(destFileExt))
{
destHeaderFile = destFile.Substring(0, destFile.Length - destFileExt.Length);
}
else
{
destHeaderFile = destFile;
}
destHeaderFile += ".h";
for (int i=2; i<args.Length; i++)
{
if (!String.IsNullOrWhiteSpace(args[i]) && Directory.Exists(args[i]))
{
MibTypesResolver.RegisterResolver(new FileSystemMibResolver(args[i], true));
}
}
// read and resolve MIB
Console.WriteLine(" Reading MIB file...");
MibDocument md = new MibDocument(mibFile);
MibTypesResolver.ResolveTypes(md.Modules[0]);
MibTree mt = new MibTree(md.Modules[0] as MibModule);
if (mt.Root.Count == 0)
{
Console.WriteLine("No root element found inside MIB!");
return;
}
MibCFile generatedFile = new MibCFile();
MibHeaderFile generatedHeaderFile = new MibHeaderFile();
foreach (MibTreeNode mibTreeNode in mt.Root)
{
// create LWIP object tree from MIB structure
Console.WriteLine(" Creating lwIP object tree " + mibTreeNode.Entity.Name);
SnmpMib snmpMib = new SnmpMib();
snmpMib.Oid = mibTreeNode.Entity.Value;
snmpMib.BaseOid = MibTypesResolver.ResolveOid(mibTreeNode.Entity).GetOidValues();
snmpMib.Name = mibTreeNode.Entity.Name;
ProcessMibTreeNode(mibTreeNode, snmpMib);
// let the tree transform itself depending on node structure
snmpMib.Analyze();
if (snmpMib.ChildNodes.Count != 0)
{
// generate code from LWIP object tree
Console.WriteLine(" Generating code " + snmpMib.Name);
snmpMib.Generate(generatedFile, generatedHeaderFile);
}
}
string preservedCode = MibCFile.GetPreservedCode(destFile);
if (!string.IsNullOrEmpty(preservedCode))
{
generatedFile.PreservedCode.Add(new PlainText(preservedCode));
}
else
{
generatedFile.PreservedCode.AddRange(generatedFile.Implementation);
}
generatedFile.Implementation.Clear();
using (StreamWriter fileWriter = new StreamWriter(destHeaderFile))
{
CGenerator cGenerator = new CGenerator(fileWriter, destHeaderFile, 3, " ", Environment.NewLine);
generatedHeaderFile.Save(cGenerator);
}
using (StreamWriter fileWriter = new StreamWriter(destFile))
{
CGenerator cGenerator = new CGenerator(fileWriter, destFile, 3, " ", Environment.NewLine);
generatedFile.Save(cGenerator);
}
Console.WriteLine(" Done");
}
private static void PrintUsage()
{
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
string appName = Path.GetFileName(codeBase);
Console.WriteLine("Usage:");
Console.WriteLine(String.Format(" {0} <source MIB file> <dest C file> [<search path 1 for referred MIB's> <search path 2 for referred MIB's> ...]", appName));
Console.WriteLine("");
Console.WriteLine(" <source MIB file>");
Console.WriteLine(" Path and filename of MIB file to convert.");
Console.WriteLine("");
Console.WriteLine(" <dest C file>");
Console.WriteLine(" Destination path and file. If a path is passed only, filename is auto");
Console.WriteLine(" generated from MIB file name.");
Console.WriteLine("");
Console.WriteLine(" <search path X for referred MIB's>");
Console.WriteLine(" It's important to provide all referred MIB's in order to correctly ");
Console.WriteLine(" resolve all used types.");
Console.WriteLine("");
}
#region Generation of LWIP Object Tree
private static void ProcessMibTreeNode(MibTreeNode mibTreeNode, SnmpTreeNode assignedSnmpNode)
{
foreach (MibTreeNode mtn in mibTreeNode.ChildNodes)
{
// in theory container nodes may also be scalars or tables at the same time (for now only process real containers)
if (mtn.NodeType == MibTreeNodeType.Container)
{
SnmpTreeNode snmpTreeNode = GenerateSnmpTreeNode(mtn, assignedSnmpNode);
assignedSnmpNode.ChildNodes.Add(snmpTreeNode);
ProcessMibTreeNode(mtn, snmpTreeNode);
}
else if ((mtn.NodeType & MibTreeNodeType.Scalar) != 0)
{
SnmpScalarNode snmpScalarNode = GenerateSnmpScalarNode(mtn, assignedSnmpNode);
if (snmpScalarNode != null)
{
assignedSnmpNode.ChildNodes.Add(snmpScalarNode);
}
}
else if ((mtn.NodeType & MibTreeNodeType.Table) != 0)
{
SnmpTableNode snmpTableNode = GenerateSnmpTableNode(mtn, assignedSnmpNode);
if (snmpTableNode != null)
{
assignedSnmpNode.ChildNodes.Add(snmpTableNode);
}
}
}
}
private static SnmpTreeNode GenerateSnmpTreeNode(MibTreeNode mibTreeNode, SnmpTreeNode parentNode)
{
SnmpTreeNode result = new SnmpTreeNode(parentNode);
result.Name = _alphaNumericRegex.Replace (mibTreeNode.Entity.Name, "");
result.Oid = mibTreeNode.Entity.Value;
result.FullOid = MibTypesResolver.ResolveOid(mibTreeNode.Entity).GetOidString();
return result;
}
private static SnmpScalarNode GenerateSnmpScalarNode(MibTreeNode mibTreeNode, SnmpTreeNode parentNode, bool ignoreAccessibleFlag = false)
{
ObjectType ote = mibTreeNode.Entity as ObjectType;
if (ote != null)
{
return GenerateSnmpScalarNode(ote, parentNode, ignoreAccessibleFlag);
}
return null;
}
private static SnmpScalarNode GenerateSnmpScalarNode(ObjectType ote, SnmpTreeNode parentNode, bool ignoreAccessibleFlag = false)
{
SnmpScalarNode result;
ITypeAssignment mibType = ote.BaseType;
IntegerType it = (mibType as IntegerType);
if (it != null)
{
if (ote.ReferredType.Name == Symbol.TruthValue.ToString())
{
result = new SnmpScalarNodeTruthValue(parentNode);
}
else if ((it.Type == IntegerType.Types.Integer) || (it.Type == IntegerType.Types.Integer32))
{
result = new SnmpScalarNodeInt(parentNode);
}
else
{
Console.WriteLine(String.Format("Unsupported IntegerType '{0}'!", it.Type));
return null;
}
if (it.IsEnumeration)
{
result.Restrictions.AddRange(CreateRestrictions(it.Enumeration));
}
else
{
result.Restrictions.AddRange(CreateRestrictions(it.Ranges));
}
}
else
{
UnsignedType ut = (mibType as UnsignedType);
if (ut != null)
{
if ((ut.Type == UnsignedType.Types.Unsigned32) ||
(ut.Type == UnsignedType.Types.Gauge32))
{
result = new SnmpScalarNodeUint(SnmpDataType.Gauge, parentNode);
}
else if (ut.Type == UnsignedType.Types.Counter32)
{
result = new SnmpScalarNodeUint(SnmpDataType.Counter, parentNode);
}
else if (ut.Type == UnsignedType.Types.TimeTicks)
{
result = new SnmpScalarNodeUint(SnmpDataType.TimeTicks, parentNode);
}
else if (ut.Type == UnsignedType.Types.Counter64)
{
result = new SnmpScalarNodeCounter64(parentNode);
if ((ut.Ranges != null) && (ut.Ranges.Count > 0))
{
Console.WriteLine(String.Format("Generation of ranges is not supported for Counter64 type!"));
return null;
}
}
else
{
Console.WriteLine(String.Format("Unsupported UnsignedType '{0}'!", ut.Type));
return null;
}
result.Restrictions.AddRange(CreateRestrictions(ut.Ranges));
}
else if (mibType is IpAddressType)
{
result = new SnmpScalarNodeOctetString(SnmpDataType.IpAddress, parentNode);
result.Restrictions.AddRange(CreateRestrictions((mibType as OctetStringType).Size));
}
else if (mibType is OpaqueType)
{
result = new SnmpScalarNodeOctetString(SnmpDataType.Opaque, parentNode);
result.Restrictions.AddRange(CreateRestrictions((mibType as OctetStringType).Size));
}
else if (mibType is OctetStringType)
{
result = new SnmpScalarNodeOctetString(SnmpDataType.OctetString, parentNode);
result.Restrictions.AddRange(CreateRestrictions((mibType as OctetStringType).Size));
}
else if (mibType is ObjectIdentifierType)
{
result = new SnmpScalarNodeObjectIdentifier(parentNode);
}
else if (mibType is BitsType)
{
result = new SnmpScalarNodeBits(parentNode, (uint)((mibType as BitsType).Map.GetHighestValue() + 1));
result.Restrictions.AddRange(CreateRestrictions(mibType as BitsType));
}
else
{
TypeAssignment ta = mibType as TypeAssignment;
if (ta != null)
{
Console.WriteLine(String.Format("Unsupported BaseType: Module='{0}', Name='{1}', Type='{2}'!", ta.Module.Name, ta.Name, ta.Type));
}
else
{
Console.WriteLine(String.Format("Unsupported BaseType: Module='{0}', Name='{1}'!", mibType.Module, mibType.Name));
}
return null;
}
}
result.Name = _alphaNumericRegex.Replace(ote.Name, "");
result.Oid = ote.Value;
if (ote.Access == MaxAccess.readWrite)
{
result.AccessMode = SnmpAccessMode.ReadWrite;
}
else if (ote.Access == MaxAccess.readOnly)
{
result.AccessMode = SnmpAccessMode.ReadOnly;
}
else if (ote.Access == MaxAccess.readCreate)
{
result.AccessMode = SnmpAccessMode.ReadOnly;
}
else if (ignoreAccessibleFlag && (ote.Access == MaxAccess.notAccessible))
{
result.AccessMode = SnmpAccessMode.NotAccessible;
}
else
{
// not accessible or unsupported access type
return null;
}
return result;
}
private static IEnumerable<IRestriction> CreateRestrictions(ValueRanges ranges)
{
List<IRestriction> result = new List<IRestriction>();
if (ranges != null)
{
foreach (ValueRange range in ranges)
{
if (!range.End.HasValue)
{
result.Add(new IsEqualRestriction(range.Start));
}
else
{
result.Add(new IsInRangeRestriction(range.Start, range.End.Value));
}
}
}
return result;
}
private static IEnumerable<IRestriction> CreateRestrictions(ValueMap map)
{
if ((map != null) && (map.Count > 0))
{
return CreateRestrictions(map.GetContinousRanges());
}
return new List<IRestriction>();
}
private static IEnumerable<IRestriction> CreateRestrictions(BitsType bt)
{
List<IRestriction> result = new List<IRestriction>();
if ((bt != null) && (bt.Map != null))
{
result.Add(new BitMaskRestriction(bt.Map.GetBitMask()));
}
return result;
}
private static SnmpTableNode GenerateSnmpTableNode(MibTreeNode mibTreeNode, SnmpTreeNode parentNode)
{
SnmpTableNode result = new SnmpTableNode(parentNode);
result.Name = mibTreeNode.Entity.Name;
result.Oid = mibTreeNode.Entity.Value;
// expect exactly one row entry
if ((mibTreeNode.ChildNodes.Count != 1) || ((mibTreeNode.ChildNodes[0].NodeType & MibTreeNodeType.TableRow) == 0) || (mibTreeNode.ChildNodes[0].Entity.Value != 1))
{
Console.WriteLine("Found table with unsupported properties! Table needs exactly one (fixed) TableRow with OID=1 ! (" + mibTreeNode.Entity.Name + ")");
return null;
}
MibTreeNode rowNode = mibTreeNode.ChildNodes[0];
ObjectType rot = rowNode.Entity as ObjectType;
if (rot != null)
{
if (!String.IsNullOrWhiteSpace(rot.Augments))
{
result.AugmentedTableRow = rot.Augments;
// the indices from another table shall be used because this table is only an extension of it
rot = MibTypesResolver.ResolveDeclaration(rot.Module, rot.Augments) as ObjectType;
}
if (rot.Indices != null)
{
foreach (string index in rot.Indices)
{
ObjectType indexEntity = MibTypesResolver.ResolveDeclaration(rot.Module, index) as ObjectType;
if (indexEntity == null)
{
Console.WriteLine(String.Format("Could not resolve index '{0}' for table '{1}'! Table omitted!", index, result.Name));
return null;
}
result.IndexNodes.Add(GenerateSnmpScalarNode(indexEntity, parentNode, ignoreAccessibleFlag: true));
}
}
}
if (result.IndexNodes.Count == 0)
{
// a table cannot be used without index
Console.WriteLine("Found table without any index column ! (" + mibTreeNode.Entity.Name + ")");
return null;
}
// add child nodes
foreach (MibTreeNode cellNode in rowNode.ChildNodes)
{
SnmpScalarNode ssn = GenerateSnmpScalarNode(cellNode, parentNode);
if (ssn != null)
{
result.CellNodes.Add(ssn);
}
}
return result;
}
#endregion
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("ConsoleApplication28")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConsoleApplication28")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("0abf7541-6a96-43cd-9e24-462e074b2c96")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

View File

@ -0,0 +1,120 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
namespace LwipSnmpCodeGeneration
{
public interface IRestriction
{
string GetCheckCodeValid(string varNameToCheck);
string GetCheckCodeInvalid(string varNameToCheck);
}
public class BitMaskRestriction : IRestriction
{
UInt32 mask;
public BitMaskRestriction(UInt32 mask)
{
this.mask = mask;
}
public string GetCheckCodeValid(string varNameToCheck)
{
return String.Format("(({0} & {1}) == {0})", varNameToCheck, this.mask);
}
public string GetCheckCodeInvalid(string varNameToCheck)
{
return String.Format("(({0} & {1}) != {0})", varNameToCheck, this.mask);
}
}
public class IsEqualRestriction : IRestriction
{
private Int64 value;
public IsEqualRestriction(Int64 value)
{
this.value = value;
}
public long Value
{
get { return value; }
}
public string GetCheckCodeValid(string varNameToCheck)
{
return String.Format("({0} == {1})", varNameToCheck, this.value);
}
public string GetCheckCodeInvalid(string varNameToCheck)
{
return String.Format("({0} != {1})", varNameToCheck, this.value);
}
}
public class IsInRangeRestriction : IRestriction
{
private Int64 rangeStart;
private Int64 rangeEnd;
public IsInRangeRestriction(Int64 rangeStart, Int64 rangeEnd)
{
this.rangeStart = rangeStart;
this.rangeEnd = rangeEnd;
}
public long RangeStart
{
get { return this.rangeStart; }
}
public long RangeEnd
{
get { return this.rangeEnd; }
}
public string GetCheckCodeValid(string varNameToCheck)
{
return String.Format("(({0} >= {1}) && ({0} <= {2}))", varNameToCheck, this.rangeStart, this.rangeEnd);
}
public string GetCheckCodeInvalid(string varNameToCheck)
{
return String.Format("(({0} < {1}) || ({0} > {2}))", varNameToCheck, this.rangeStart, this.rangeEnd);
}
}
}

View File

@ -0,0 +1,199 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
namespace LwipSnmpCodeGeneration
{
public static class LwipOpts
{
public static bool GenerateEmptyFolders = false;
/// <summary>
/// If a tree node only has scalar nodes as child nodes, it is replaced by
/// a single scalar array node in order to save memory and have only one single get/test/set method for all scalars.
/// </summary>
public static bool GenerateScalarArrays = true;
/// <summary>
/// If a tree node has multiple scalars as subnodes as well as other treenodes it
/// defines a single get/test/set method for all scalar child node.
/// (without other treenodes as child it would have been converted to scalar array node).
/// </summary>
public static bool GenerateSingleAccessMethodsForTreeNodeScalars = GenerateScalarArrays;
}
public static class LwipDefs
{
public const string Null = "NULL";
public const string Vt_U8 = "u8_t";
public const string Vt_U16 = "u16_t";
public const string Vt_U32 = "u32_t";
public const string Vt_S8 = "s8_t";
public const string Vt_S16 = "s16_t";
public const string Vt_S32 = "s32_t";
public const string Vt_Snmp_err = "snmp_err_t";
public const string Incl_SnmpOpts = "lwip/apps/snmp_opts.h";
public const string Opt_SnmpEnabled = "LWIP_SNMP";
public const string Vt_StMib = "struct snmp_mib";
public const string Vt_StObjectId = "struct snmp_obj_id";
public const string Vt_StNode = "struct snmp_node";
public const string Vt_StNodeInstance = "struct snmp_node_instance";
public const string Vt_StTreeNode = "struct snmp_tree_node";
public const string Vt_StScalarNode = "struct snmp_scalar_node";
public const string Vt_StScalarArrayNode = "struct snmp_scalar_array_node";
public const string Vt_StScalarArrayNodeDef = "struct snmp_scalar_array_node_def";
public const string Vt_StTableNode = "struct snmp_table_node";
public const string Vt_StTableColumnDef = "struct snmp_table_col_def";
public const string Vt_StNextOidState = "struct snmp_next_oid_state";
public const string Def_NodeAccessReadOnly = "SNMP_NODE_INSTANCE_READ_ONLY";
public const string Def_NodeAccessReadWrite = "SNMP_NODE_INSTANCE_READ_WRITE";
public const string Def_NodeAccessWriteOnly = "SNMP_NODE_INSTANCE_WRITE_ONLY";
public const string Def_NodeAccessNotAccessible = "SNMP_NODE_INSTANCE_NOT_ACCESSIBLE";
public const string Def_ErrorCode_Ok = "SNMP_ERR_NOERROR";
public const string Def_ErrorCode_WrongValue = "SNMP_ERR_WRONGVALUE";
public const string Def_ErrorCode_NoSuchInstance = "SNMP_ERR_NOSUCHINSTANCE";
public const string FnctSuffix_GetValue = "_get_value";
public const string FnctSuffix_SetTest = "_set_test";
public const string FnctSuffix_SetValue = "_set_value";
public const string FnctSuffix_GetInstance = "_get_instance";
public const string FnctSuffix_GetNextInstance = "_get_next_instance";
public const string FnctName_SetTest_Ok = "snmp_set_test_ok";
public static string GetLwipDefForSnmpAccessMode(SnmpAccessMode am)
{
switch (am)
{
case SnmpAccessMode.ReadOnly: return Def_NodeAccessReadOnly;
case SnmpAccessMode.ReadWrite: return Def_NodeAccessReadWrite;
case SnmpAccessMode.NotAccessible: return Def_NodeAccessNotAccessible;
case SnmpAccessMode.WriteOnly: return Def_NodeAccessWriteOnly;
default: throw new NotSupportedException("Unknown SnmpAccessMode!");
}
}
public static string GetAsn1DefForSnmpDataType(SnmpDataType dt)
{
switch (dt)
{
// primitive
case SnmpDataType.Null:
return "SNMP_ASN1_TYPE_NULL";
case SnmpDataType.Bits:
case SnmpDataType.OctetString:
return "SNMP_ASN1_TYPE_OCTET_STRING";
case SnmpDataType.ObjectIdentifier:
return "SNMP_ASN1_TYPE_OBJECT_ID";
case SnmpDataType.Integer:
return "SNMP_ASN1_TYPE_INTEGER";
// application
case SnmpDataType.IpAddress:
return "SNMP_ASN1_TYPE_IPADDR";
case SnmpDataType.Counter:
return "SNMP_ASN1_TYPE_COUNTER";
case SnmpDataType.Gauge:
return "SNMP_ASN1_TYPE_GAUGE";
case SnmpDataType.TimeTicks:
return "SNMP_ASN1_TYPE_TIMETICKS";
case SnmpDataType.Opaque:
return "SNMP_ASN1_TYPE_OPAQUE";
case SnmpDataType.Counter64:
return "SNMP_ASN1_TYPE_COUNTER64";
default:
throw new NotSupportedException("Unknown SnmpDataType!");
}
}
public static string GetLengthForSnmpDataType(SnmpDataType dt)
{
switch (dt)
{
case SnmpDataType.Null:
return "0";
case SnmpDataType.Integer:
case SnmpDataType.Counter:
case SnmpDataType.IpAddress:
case SnmpDataType.Gauge:
case SnmpDataType.TimeTicks:
return "4";
case SnmpDataType.Counter64:
return "8";
case SnmpDataType.OctetString:
case SnmpDataType.ObjectIdentifier:
case SnmpDataType.Bits:
case SnmpDataType.Opaque:
return null;
default:
throw new NotSupportedException("Unknown SnmpDataType!");
}
}
}
public enum SnmpDataType
{
Null,
Integer, // INTEGER, Integer32
Counter, // Counter, Counter32
Gauge, // Gauge, Gauge32, Unsigned32
TimeTicks,
Counter64,
OctetString,
Opaque,
Bits,
ObjectIdentifier,
IpAddress,
}
public enum SnmpAccessMode
{
ReadOnly,
ReadWrite,
WriteOnly,
NotAccessible
}
}

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{AABCAB90-1540-45D4-A159-14831A54E9A3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LwipSnmpCodeGeneration</RootNamespace>
<AssemblyName>LwipSnmpCodeGeneration</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="IRestriction.cs" />
<Compile Include="SnmpScalarNodeCounter64.cs" />
<Compile Include="SnmpScalarNodeTruthValue.cs" />
<Compile Include="SnmpScalarAggregationNode.cs" />
<Compile Include="SnmpTableNode.cs" />
<Compile Include="SnmpScalarArrayNode.cs" />
<Compile Include="MibHeaderFile.cs" />
<Compile Include="SnmpScalarNodeBits.cs" />
<Compile Include="SnmpMib.cs" />
<Compile Include="SnmpScalarNodeInt.cs" />
<Compile Include="SnmpScalarNodeObjectIdentifier.cs" />
<Compile Include="SnmpScalarNodeOctetString.cs" />
<Compile Include="SnmpScalarNodeUint.cs" />
<Compile Include="SnmpTreeNode.cs" />
<Compile Include="LwipSnmp.cs" />
<Compile Include="MibCFile.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SnmpNode.cs" />
<Compile Include="SnmpScalarNode.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CCodeGeneration\CCodeGeneration.csproj">
<Project>{7DA7C0AB-0982-4BF5-9324-F59A7A08D65B}</Project>
<Name>CCodeGeneration</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,196 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System.Collections.Generic;
using CCodeGeneration;
using System;
using System.IO;
namespace LwipSnmpCodeGeneration
{
public class MibCFile
{
#region Fields
private const string PreservedSectionMarker = "LWIP MIB generator - preserved section begin";
private const string PreservedSectionHeader =
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" +
PreservedSectionMarker + "\n" +
"Code below is preserved on regeneration. Remove these comment lines to regenerate code.\n" +
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
private readonly List<CodeElement> includes = new List<CodeElement>();
private readonly List<CodeElement> defines = new List<CodeElement>();
private readonly List<CodeElement> declarations = new List<CodeElement>();
private readonly List<CodeElement> implementation = new List<CodeElement>();
private readonly List<CodeElement> preservedCode = new List<CodeElement>();
#endregion
public MibCFile()
{
}
#region Accessors
public List<CodeElement> Includes
{
get { return this.includes; }
}
public List<CodeElement> Defines
{
get { return this.defines; }
}
public List<CodeElement> Declarations
{
get { return this.declarations; }
}
public List<CodeElement> Implementation
{
get { return this.implementation; }
}
public List<CodeElement> PreservedCode
{
get { return this.preservedCode; }
}
#endregion
#region Methods
public void Save(CGenerator cGenerator)
{
CFile cFile = new CFile();
cFile.AddElement(new Comment("Generated by LwipMibCompiler"));
cFile.AddElement(EmptyLine.SingleLine);
cFile.AddElement(new PP_Include(LwipDefs.Incl_SnmpOpts));
CodeContainerBase e = cFile.AddElement(new PP_If(LwipDefs.Opt_SnmpEnabled)) as CodeContainerBase;
e.AddElement(EmptyLine.SingleLine);
// include header file
string file = cGenerator.FileName;
if (!String.IsNullOrWhiteSpace(file))
{
string ext = System.IO.Path.GetExtension(file);
string headerFile = !String.IsNullOrEmpty(ext) ? file.Substring(0, file.Length - ext.Length) : file;
headerFile += ".h";
e.AddElement(new PP_Include(headerFile));
}
// include common snmp files
e.AddElement(new PP_Include("lwip/apps/snmp.h"));
e.AddElement(new PP_Include("lwip/apps/snmp_core.h"));
e.AddElement(new PP_Include("lwip/apps/snmp_scalar.h"));
e.AddElement(new PP_Include("lwip/apps/snmp_table.h"));
if (this.includes.Count > 0)
{
e.AddElement(EmptyLine.SingleLine);
e.AddElements(this.includes);
}
if (this.defines.Count > 0)
{
e.AddElement(EmptyLine.SingleLine);
e.AddElements(this.defines);
}
if (this.declarations.Count > 0)
{
e.AddElement(EmptyLine.TwoLines);
e.AddElements(this.declarations);
}
if (this.implementation.Count > 0)
{
e.AddElement(EmptyLine.TwoLines);
e.AddElements(this.implementation);
}
if (this.preservedCode.Count > 0)
{
e.AddElement(EmptyLine.TwoLines);
e.AddElement(new Comment(PreservedSectionHeader));
e.AddElement(EmptyLine.SingleLine);
e.AddElements(this.preservedCode);
}
cFile.Save(cGenerator);
}
public static string GetPreservedCode(string file)
{
if (File.Exists(file))
{
using (StreamReader fileStream = new StreamReader(file))
{
while (!fileStream.EndOfStream)
{
string line = fileStream.ReadLine();
if (line == PreservedSectionMarker)
{
break;
}
}
if (!fileStream.EndOfStream)
{
// skip the rest of the comment + spacer line
fileStream.ReadLine(); // "Code below is preserved...
fileStream.ReadLine(); // "+++++++++++++++++++++++...
fileStream.ReadLine(); // */
fileStream.ReadLine(); //
string preservedCode = fileStream.ReadToEnd();
int lastEndif = preservedCode.LastIndexOf("#endif", StringComparison.Ordinal);
preservedCode = preservedCode.Remove(lastEndif);
return preservedCode;
}
}
}
return null;
}
#endregion
}
}

View File

@ -0,0 +1,129 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System.Collections.Generic;
using System.Text.RegularExpressions;
using CCodeGeneration;
namespace LwipSnmpCodeGeneration
{
public class MibHeaderFile
{
#region Fields
private readonly List<CodeElement> defines = new List<CodeElement>();
private readonly List<CodeElement> includes = new List<CodeElement>();
private readonly List<CodeElement> functionDeclarations = new List<CodeElement>();
private readonly List<CodeElement> variableDeclarations = new List<CodeElement>();
#endregion
public MibHeaderFile()
{
}
#region Accessors
public List<CodeElement> Defines
{
get { return this.defines; }
}
public List<CodeElement> Includes
{
get { return this.includes; }
}
public List<CodeElement> FunctionDeclarations
{
get { return this.functionDeclarations; }
}
public List<CodeElement> VariableDeclarations
{
get { return this.variableDeclarations; }
}
#endregion
#region Methods
public void Save(CGenerator cGenerator)
{
CFile cFile = new CFile();
cFile.AddElement(new Comment("Generated by LwipMibCompiler"));
cFile.AddElement(EmptyLine.SingleLine);
string headerDefine = cGenerator.FileName;
headerDefine = new Regex("[^a-zA-Z0-9]").Replace(headerDefine, "_");
headerDefine = headerDefine.ToUpperInvariant();
CodeContainerBase e = cFile.AddElement(new PP_Ifdef(headerDefine, inverted: true)) as CodeContainerBase;
e.AddElement(new PP_Macro(headerDefine, headerDefine));
e.AddElement(EmptyLine.SingleLine);
e.AddElement(new PP_Include(LwipDefs.Incl_SnmpOpts));
e = e.AddElement(new PP_If(LwipDefs.Opt_SnmpEnabled)) as CodeContainerBase;
e.AddElement(EmptyLine.SingleLine);
CodeContainerBase cplusplusopen = e.AddElement(new PP_Ifdef("__cplusplus")) as CodeContainerBase;
cplusplusopen.AddElement(new Code("extern \"C\" {"));
e.AddElement(EmptyLine.SingleLine);
if (this.includes.Count > 0)
{
e.AddElements(this.includes);
e.AddElement(EmptyLine.SingleLine);
}
if (this.defines.Count > 0)
{
e.AddElements(this.defines);
e.AddElement(EmptyLine.SingleLine);
}
e.AddElements(this.functionDeclarations, EmptyLine.SingleLine);
e.AddElements(this.variableDeclarations, EmptyLine.SingleLine);
e.AddElement(EmptyLine.SingleLine);
CodeContainerBase cplusplusclose = e.AddElement(new PP_Ifdef("__cplusplus")) as CodeContainerBase;
cplusplusclose.AddElement(new Code("}"));
e.AddElement(EmptyLine.SingleLine);
cFile.Save(cGenerator);
}
#endregion
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("LwipSnmpCodeGeneration")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LwipSnmpCodeGeneration")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("8cfbbb8b-dfbb-4dd5-80c9-e07845dd58c9")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,97 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using System.Text;
using CCodeGeneration;
namespace LwipSnmpCodeGeneration
{
public class SnmpMib : SnmpTreeNode
{
public uint[] BaseOid { get; set; }
public SnmpMib()
: base(null)
{
}
public SnmpMib(uint[] baseOid)
: base(null)
{
this.BaseOid = baseOid;
}
public override string FullNodeName
{
get { return this.Name.ToLowerInvariant() + "_root"; }
}
public override void GenerateCode(MibCFile mibFile)
{
base.GenerateCode(mibFile);
System.Diagnostics.Debug.Assert((this.BaseOid != null) && (this.BaseOid.Length > 0));
// create and add BaseOID declarations
StringBuilder boidInitialization = new StringBuilder("{");
foreach (uint t in this.BaseOid)
{
boidInitialization.Append(t);
boidInitialization.Append(",");
}
boidInitialization.Length -= 1;
boidInitialization.Append("}");
VariableDeclaration boidDecl = new VariableDeclaration(
new VariableType(this.Name.ToLowerInvariant() + "_base_oid", LwipDefs.Vt_U32, null, ConstType.Value, String.Empty),
boidInitialization.ToString(), true);
mibFile.Declarations.Add(boidDecl);
mibFile.Declarations.Add(GetExportDeclaration());
}
public override void GenerateHeaderCode(MibHeaderFile mibHeaderFile)
{
mibHeaderFile.Includes.Add(new PP_Include("lwip/apps/snmp_core.h"));
mibHeaderFile.VariableDeclarations.Add(VariablePrototype.FromVariableDeclaration(GetExportDeclaration()));
}
VariableDeclaration GetExportDeclaration()
{
return new VariableDeclaration(
new VariableType(this.Name.ToLowerInvariant(), LwipDefs.Vt_StMib, null, ConstType.Value),
String.Format("{{{0}_base_oid, LWIP_ARRAYSIZE({0}_base_oid), &{1}.node}}", this.Name.ToLowerInvariant(), this.FullNodeName));
}
}
}

View File

@ -0,0 +1,119 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using System.Text.RegularExpressions;
using CCodeGeneration;
namespace LwipSnmpCodeGeneration
{
public abstract class SnmpNode
{
public static readonly Regex NameValidationRegex = new Regex(@"^\w+$");
private string name;
private readonly SnmpTreeNode parentNode;
protected SnmpNode(SnmpTreeNode parentNode)
{
this.parentNode = parentNode;
}
public SnmpTreeNode ParentNode
{
get { return this.parentNode; }
}
public virtual uint Oid { get; set; }
public abstract string FullNodeName
{
get;
}
public virtual string Name
{
get { return this.name; }
set
{
if (value != this.name)
{
// check for valid name
if (!NameValidationRegex.IsMatch(value))
{
throw new ArgumentOutOfRangeException("Name");
}
this.name = value;
}
}
}
public virtual void Generate(MibCFile generatedFile, MibHeaderFile generatedHeaderFile)
{
int declCount = generatedFile.Declarations.Count;
int implCount = generatedFile.Implementation.Count;
this.GenerateHeaderCode(generatedHeaderFile);
this.GenerateCode(generatedFile);
if (generatedFile.Declarations.Count != declCount)
{
generatedFile.Declarations.Add(EmptyLine.SingleLine);
}
if (generatedFile.Implementation.Count != implCount)
{
generatedFile.Implementation.Add(EmptyLine.SingleLine);
}
}
public abstract void GenerateCode(MibCFile mibFile);
public virtual void GenerateHeaderCode(MibHeaderFile mibHeaderFile)
{
}
/// <summary>
/// Called after node structure creation is completed and before code is created.
/// Offers the possibility to perform operations depending on properties/subnodes.
/// If the node shall be transformed to another node(-type) than the own instance
/// may be replaced on parent node by the transformed instance.
/// Calling sequence is always from leafs up to root. So a tree node can assume
/// that the analyze method was already called on all child nodes.
/// E.g. a tree node only has scalar sub nodes -> it transforms itself to a scalar array node
/// </summary>
/// <returns>The transformed node or null if nothing shall be changed in parent structure.</returns>
public virtual void Analyze()
{
}
}
}

View File

@ -0,0 +1,293 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System.Collections.Generic;
using System.Globalization;
using CCodeGeneration;
namespace LwipSnmpCodeGeneration
{
public abstract class SnmpScalarAggregationNode: SnmpNode
{
private bool getMethodRequired = false;
private bool testMethodRequired = false;
private bool setMethodRequired = false;
protected SnmpScalarAggregationNode(SnmpTreeNode parentNode)
: base(parentNode)
{
}
protected virtual string GetMethodName
{
get { return this.FullNodeName + LwipDefs.FnctSuffix_GetValue; }
}
protected bool GetMethodRequired
{
get { return this.getMethodRequired; }
}
protected virtual string TestMethodName
{
get { return this.FullNodeName + LwipDefs.FnctSuffix_SetTest; }
}
protected bool TestMethodRequired
{
get { return this.testMethodRequired; }
}
protected virtual string SetMethodName
{
get { return this.FullNodeName + LwipDefs.FnctSuffix_SetValue; }
}
protected bool SetMethodRequired
{
get { return this.setMethodRequired; }
}
protected abstract IEnumerable<SnmpScalarNode> AggregatedScalarNodes
{
get;
}
public override void Analyze()
{
base.Analyze();
this.getMethodRequired = false;
this.testMethodRequired = false;
this.setMethodRequired = false;
foreach (SnmpScalarNode scalarNode in this.AggregatedScalarNodes)
{
if ((scalarNode.AccessMode == SnmpAccessMode.ReadOnly) || (scalarNode.AccessMode == SnmpAccessMode.ReadWrite))
{
this.getMethodRequired = true;
}
if ((scalarNode.AccessMode == SnmpAccessMode.WriteOnly) || (scalarNode.AccessMode == SnmpAccessMode.ReadWrite))
{
this.testMethodRequired = true;
this.setMethodRequired = true;
}
if (this.getMethodRequired && this.setMethodRequired)
{
break;
}
}
}
protected void GenerateAggregatedCode(MibCFile mibFile, VariableType instanceType, string switchSelector, bool generateDeclarations = true, bool generateImplementations = true)
{
if (this.getMethodRequired)
{
FunctionDeclaration getMethodDecl = new FunctionDeclaration(this.GetMethodName, isStatic: true);
getMethodDecl.Parameter.Add(instanceType);
getMethodDecl.Parameter.Add(new VariableType("value", VariableType.VoidString, "*"));
getMethodDecl.ReturnType = new VariableType(null, LwipDefs.Vt_S16);
if (generateDeclarations)
{
mibFile.Declarations.Add(getMethodDecl);
}
if (generateImplementations)
{
Function getMethod = Function.FromDeclaration(getMethodDecl);
GenerateGetMethodCode(getMethod, switchSelector);
mibFile.Implementation.Add(getMethod);
}
}
if (this.testMethodRequired)
{
FunctionDeclaration testMethodDecl = new FunctionDeclaration(this.TestMethodName, isStatic: true);
testMethodDecl.Parameter.Add(instanceType);
testMethodDecl.Parameter.Add(new VariableType("len", LwipDefs.Vt_U16));
testMethodDecl.Parameter.Add(new VariableType("value", VariableType.VoidString, "*"));
testMethodDecl.ReturnType = new VariableType(null, LwipDefs.Vt_Snmp_err);
if (generateDeclarations)
{
mibFile.Declarations.Add(testMethodDecl);
}
if (generateImplementations)
{
Function testMethod = Function.FromDeclaration(testMethodDecl);
GenerateTestMethodCode(testMethod, switchSelector);
mibFile.Implementation.Add(testMethod);
}
}
if (this.setMethodRequired)
{
FunctionDeclaration setMethodDecl = new FunctionDeclaration(this.SetMethodName, isStatic: true);
setMethodDecl.Parameter.Add(instanceType);
setMethodDecl.Parameter.Add(new VariableType("len", LwipDefs.Vt_U16));
setMethodDecl.Parameter.Add(new VariableType("value", VariableType.VoidString, "*"));
setMethodDecl.ReturnType = new VariableType(null, LwipDefs.Vt_Snmp_err);
if (generateDeclarations)
{
mibFile.Declarations.Add(setMethodDecl);
}
if (generateImplementations)
{
Function setMethod = Function.FromDeclaration(setMethodDecl);
GenerateSetMethodCode(setMethod, switchSelector);
mibFile.Implementation.Add(setMethod);
}
}
}
protected virtual void GenerateGetMethodCode(Function getMethod, string switchSelector)
{
VariableDeclaration returnValue = new VariableDeclaration((VariableType)getMethod.ReturnType.Clone());
returnValue.Type.Name = "value_len";
getMethod.Declarations.Add(returnValue);
Switch sw = new Switch(switchSelector);
bool valueVarUsed = false;
foreach (SnmpScalarNode scalarNode in this.AggregatedScalarNodes)
{
if ((scalarNode.AccessMode == SnmpAccessMode.ReadOnly) || (scalarNode.AccessMode == SnmpAccessMode.ReadWrite))
{
SwitchCase sc = new SwitchCase(scalarNode.Oid.ToString(CultureInfo.InvariantCulture));
sc.Declarations.Add(new Comment(scalarNode.Name, singleLine: true));
scalarNode.GenerateGetMethodCode(sc, getMethod.Parameter[1].Name, ref valueVarUsed, returnValue.Type.Name);
sw.Switches.Add(sc);
}
}
SwitchCase scd = SwitchCase.GenerateDefault();
scd.AddCodeFormat("LWIP_DEBUGF(SNMP_MIB_DEBUG,(\"{0}(): unknown id: %\"S32_F\"\\n\", {1}));", getMethod.Name, switchSelector);
scd.AddCodeFormat("{0} = 0;", returnValue.Type.Name);
sw.Switches.Add(scd);
if (!valueVarUsed)
{
getMethod.AddCodeFormat("LWIP_UNUSED_ARG({0});", getMethod.Parameter[1].Name);
}
getMethod.AddElement(sw);
getMethod.AddCodeFormat("return {0};", returnValue.Type.Name);
}
protected virtual void GenerateTestMethodCode(Function testMethod, string switchSelector)
{
VariableDeclaration returnValue = new VariableDeclaration((VariableType)testMethod.ReturnType.Clone(), LwipDefs.Def_ErrorCode_WrongValue);
returnValue.Type.Name = "err";
testMethod.Declarations.Add(returnValue);
Switch sw = new Switch(switchSelector);
bool valueVarUsed = false;
bool lenVarUsed = false;
foreach (SnmpScalarNode scalarNode in this.AggregatedScalarNodes)
{
if ((scalarNode.AccessMode == SnmpAccessMode.WriteOnly) || (scalarNode.AccessMode == SnmpAccessMode.ReadWrite))
{
SwitchCase sc = new SwitchCase(scalarNode.Oid.ToString(CultureInfo.InvariantCulture));
sc.Declarations.Add(new Comment(scalarNode.Name, singleLine: true));
scalarNode.GenerateTestMethodCode(sc, testMethod.Parameter[2].Name, ref valueVarUsed, testMethod.Parameter[1].Name, ref lenVarUsed, returnValue.Type.Name);
sw.Switches.Add(sc);
}
}
SwitchCase scd = SwitchCase.GenerateDefault();
scd.AddCodeFormat("LWIP_DEBUGF(SNMP_MIB_DEBUG,(\"{0}(): unknown id: %\"S32_F\"\\n\", {1}));", testMethod.Name, switchSelector);
sw.Switches.Add(scd);
if (!valueVarUsed)
{
testMethod.AddCodeFormat("LWIP_UNUSED_ARG({0});", testMethod.Parameter[2].Name);
}
if (!lenVarUsed)
{
testMethod.AddCodeFormat("LWIP_UNUSED_ARG({0});", testMethod.Parameter[1].Name);
}
testMethod.AddElement(sw);
testMethod.AddCodeFormat("return {0};", returnValue.Type.Name);
}
protected virtual void GenerateSetMethodCode(Function setMethod, string switchSelector)
{
VariableDeclaration returnValue = new VariableDeclaration((VariableType)setMethod.ReturnType.Clone(), LwipDefs.Def_ErrorCode_Ok);
returnValue.Type.Name = "err";
setMethod.Declarations.Add(returnValue);
Switch sw = new Switch(switchSelector);
bool valueVarUsed = false;
bool lenVarUsed = false;
foreach (SnmpScalarNode scalarNode in this.AggregatedScalarNodes)
{
if ((scalarNode.AccessMode == SnmpAccessMode.WriteOnly) || (scalarNode.AccessMode == SnmpAccessMode.ReadWrite))
{
SwitchCase sc = new SwitchCase(scalarNode.Oid.ToString(CultureInfo.InvariantCulture));
sc.Declarations.Add(new Comment(scalarNode.Name, singleLine: true));
scalarNode.GenerateSetMethodCode(sc, setMethod.Parameter[2].Name, ref valueVarUsed, setMethod.Parameter[1].Name, ref lenVarUsed, returnValue.Type.Name);
sw.Switches.Add(sc);
}
}
SwitchCase scd = SwitchCase.GenerateDefault();
scd.AddCodeFormat("LWIP_DEBUGF(SNMP_MIB_DEBUG,(\"{0}(): unknown id: %\"S32_F\"\\n\", {1}));", setMethod.Name, switchSelector);
sw.Switches.Add(scd);
if (!valueVarUsed)
{
setMethod.AddCodeFormat("LWIP_UNUSED_ARG({0});", setMethod.Parameter[2].Name);
}
if (!lenVarUsed)
{
setMethod.AddCodeFormat("LWIP_UNUSED_ARG({0});", setMethod.Parameter[1].Name);
}
setMethod.AddElement(sw);
setMethod.AddCodeFormat("return {0};", returnValue.Type.Name);
}
}
}

View File

@ -0,0 +1,105 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using CCodeGeneration;
namespace LwipSnmpCodeGeneration
{
public class SnmpScalarArrayNode : SnmpScalarAggregationNode
{
private readonly List<SnmpScalarNode> scalarNodes;
public SnmpScalarArrayNode(List<SnmpScalarNode> scalarNodes, SnmpTreeNode parentNode)
: base(parentNode)
{
this.scalarNodes = scalarNodes;
}
public override string FullNodeName
{
get { return this.Name.ToLowerInvariant() + "_scalars"; }
}
protected override IEnumerable<SnmpScalarNode> AggregatedScalarNodes
{
get { return this.scalarNodes; }
}
public override void GenerateCode(MibCFile mibFile)
{
VariableType instanceType = new VariableType("node", LwipDefs.Vt_StScalarArrayNodeDef, "*", ConstType.Value);
GenerateAggregatedCode(
mibFile,
instanceType,
instanceType.Name + "->oid");
// create and add node definitions
StringBuilder nodeDefs = new StringBuilder();
foreach (SnmpScalarNode scalarNode in this.scalarNodes)
{
nodeDefs.AppendFormat(" {{{0}, {1}, {2}}}, /* {3} */ \n",
scalarNode.Oid,
LwipDefs.GetAsn1DefForSnmpDataType(scalarNode.DataType),
LwipDefs.GetLwipDefForSnmpAccessMode(scalarNode.AccessMode),
scalarNode.Name);
}
if (nodeDefs.Length > 0)
nodeDefs.Length--;
VariableDeclaration nodeDefsDecl = new VariableDeclaration(
new VariableType(this.FullNodeName + "_nodes", LwipDefs.Vt_StScalarArrayNodeDef, null, ConstType.Value, String.Empty),
"{\n" + nodeDefs + "\n}" ,
isStatic: true);
mibFile.Declarations.Add(nodeDefsDecl);
// create and add node declaration
string nodeInitialization = String.Format("SNMP_SCALAR_CREATE_ARRAY_NODE({0}, {1}, {2}, {3}, {4})",
this.Oid,
nodeDefsDecl.Type.Name,
(this.GetMethodRequired) ? this.GetMethodName : LwipDefs.Null,
(this.TestMethodRequired) ? this.TestMethodName : LwipDefs.Null,
(this.SetMethodRequired) ? this.SetMethodName : LwipDefs.Null
);
mibFile.Declarations.Add(new VariableDeclaration(
new VariableType(this.FullNodeName, LwipDefs.Vt_StScalarArrayNode, null, ConstType.Value),
nodeInitialization,
isStatic: true));
}
}
}

View File

@ -0,0 +1,395 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using System.Collections.Generic;
using CCodeGeneration;
namespace LwipSnmpCodeGeneration
{
public class SnmpScalarNode: SnmpNode
{
protected const string LocalValueName = "v"; // name of (casted) local value variable
private SnmpDataType dataType;
private SnmpAccessMode accessMode;
private readonly List<IRestriction> restrictions = new List<IRestriction>();
private bool useExternalMethods = false;
private string externalGetMethod;
private string externalTestMethod;
private string externalSetMethod;
public SnmpScalarNode(SnmpTreeNode parentNode)
: base(parentNode)
{
}
public override string FullNodeName
{
get { return this.Name.ToLowerInvariant() + "_scalar"; }
}
public SnmpDataType DataType
{
get { return this.dataType; }
set { this.dataType = value; }
}
public List<IRestriction> Restrictions
{
get { return this.restrictions; }
}
public SnmpAccessMode AccessMode
{
get { return this.accessMode; }
set { this.accessMode = value; }
}
public virtual string FixedValueLength
{
get { return null; }
}
/// <summary>
/// If scalar is used as a table index its value becomes part of the OID. This value returns how many OID parts are required to represent this value.
/// </summary>
public virtual int OidRepresentationLen
{
get { return -1; }
}
public bool UseExternalMethods
{
get { return this.useExternalMethods; }
set { this.useExternalMethods = value; }
}
public string ExternalGetMethod
{
get { return this.externalGetMethod; }
set { this.externalGetMethod = value; }
}
public string ExternalTestMethod
{
get { return this.externalTestMethod; }
set { this.externalTestMethod = value; }
}
public string ExternalSetMethod
{
get { return this.externalSetMethod; }
set { this.externalSetMethod = value; }
}
public override void GenerateCode(MibCFile mibFile)
{
string getMethodName;
string testMethodName;
string setMethodName;
if (this.useExternalMethods)
{
getMethodName = this.externalGetMethod;
testMethodName = this.externalTestMethod;
setMethodName = this.externalSetMethod;
}
else
{
getMethodName = LwipDefs.Null;
testMethodName = LwipDefs.Null;
setMethodName = LwipDefs.Null;
if ((this.accessMode == SnmpAccessMode.ReadWrite) || (this.accessMode == SnmpAccessMode.ReadOnly))
{
FunctionDeclaration getMethodDecl = new FunctionDeclaration(this.Name + LwipDefs.FnctSuffix_GetValue, isStatic: true);
getMethodDecl.Parameter.Add(new VariableType("instance", LwipDefs.Vt_StNodeInstance, "*"));
getMethodDecl.Parameter.Add(new VariableType("value", VariableType.VoidString, "*"));
getMethodDecl.ReturnType = new VariableType(null, LwipDefs.Vt_S16);
mibFile.Declarations.Add(getMethodDecl);
Function getMethod = Function.FromDeclaration(getMethodDecl);
getMethodName = getMethod.Name;
VariableDeclaration returnValue = new VariableDeclaration((VariableType)getMethod.ReturnType.Clone());
returnValue.Type.Name = "value_len";
getMethod.Declarations.Add(returnValue);
getMethod.AddCodeFormat("LWIP_UNUSED_ARG({0});", getMethod.Parameter[0].Name);
bool valueVarUsed = false;
GenerateGetMethodCode(getMethod, getMethod.Parameter[1].Name, ref valueVarUsed, returnValue.Type.Name);
if (!valueVarUsed)
{
getMethod.AddCodeFormat("LWIP_UNUSED_ARG({0});", getMethod.Parameter[1].Name);
}
getMethod.AddCodeFormat("return {0};", returnValue.Type.Name);
mibFile.Implementation.Add(getMethod);
}
if ((this.accessMode == SnmpAccessMode.ReadWrite) || (this.accessMode == SnmpAccessMode.WriteOnly))
{
bool valueVarUsed;
bool lenVarUsed;
VariableDeclaration returnValue;
if (this.restrictions.Count > 0)
{
FunctionDeclaration testMethodDecl = new FunctionDeclaration(this.Name + LwipDefs.FnctSuffix_SetTest, isStatic: true);
testMethodDecl.Parameter.Add(new VariableType("instance", LwipDefs.Vt_StNodeInstance, "*"));
testMethodDecl.Parameter.Add(new VariableType("len", LwipDefs.Vt_U16));
testMethodDecl.Parameter.Add(new VariableType("value", VariableType.VoidString, "*"));
testMethodDecl.ReturnType = new VariableType(null, LwipDefs.Vt_Snmp_err);
mibFile.Declarations.Add(testMethodDecl);
Function testMethod = Function.FromDeclaration(testMethodDecl);
testMethodName = testMethod.Name;
returnValue = new VariableDeclaration((VariableType)testMethod.ReturnType.Clone(), LwipDefs.Def_ErrorCode_WrongValue);
returnValue.Type.Name = "err";
testMethod.Declarations.Add(returnValue);
testMethod.AddCodeFormat("LWIP_UNUSED_ARG({0});", testMethod.Parameter[0].Name);
valueVarUsed = false;
lenVarUsed = false;
GenerateTestMethodCode(testMethod, testMethod.Parameter[2].Name, ref valueVarUsed, testMethod.Parameter[1].Name, ref lenVarUsed, returnValue.Type.Name);
if (!valueVarUsed)
{
testMethod.AddCodeFormat("LWIP_UNUSED_ARG({0});", testMethod.Parameter[2].Name);
}
if (!lenVarUsed)
{
testMethod.AddCodeFormat("LWIP_UNUSED_ARG({0});", testMethod.Parameter[1].Name);
}
testMethod.AddCodeFormat("return {0};", returnValue.Type.Name);
mibFile.Implementation.Add(testMethod);
}
else
{
testMethodName = LwipDefs.FnctName_SetTest_Ok;
}
FunctionDeclaration setMethodDecl = null;
setMethodDecl = new FunctionDeclaration(this.Name + LwipDefs.FnctSuffix_SetValue, isStatic: true);
setMethodDecl.Parameter.Add(new VariableType("instance", LwipDefs.Vt_StNodeInstance, "*"));
setMethodDecl.Parameter.Add(new VariableType("len", LwipDefs.Vt_U16));
setMethodDecl.Parameter.Add(new VariableType("value", VariableType.VoidString, "*"));
setMethodDecl.ReturnType = new VariableType(null, LwipDefs.Vt_Snmp_err);
mibFile.Declarations.Add(setMethodDecl);
Function setMethod = Function.FromDeclaration(setMethodDecl);
setMethodName = setMethod.Name;
returnValue = new VariableDeclaration((VariableType)setMethod.ReturnType.Clone(), LwipDefs.Def_ErrorCode_Ok);
returnValue.Type.Name = "err";
setMethod.Declarations.Add(returnValue);
setMethod.AddCodeFormat("LWIP_UNUSED_ARG({0});", setMethod.Parameter[0].Name);
valueVarUsed = false;
lenVarUsed = false;
GenerateSetMethodCode(setMethod, setMethod.Parameter[2].Name, ref valueVarUsed, setMethod.Parameter[1].Name, ref lenVarUsed, returnValue.Type.Name);
if (!valueVarUsed)
{
setMethod.AddCodeFormat("LWIP_UNUSED_ARG({0});", setMethod.Parameter[2].Name);
}
if (!lenVarUsed)
{
setMethod.AddCodeFormat("LWIP_UNUSED_ARG({0});", setMethod.Parameter[1].Name);
}
setMethod.AddCodeFormat("return {0};", returnValue.Type.Name);
mibFile.Implementation.Add(setMethod);
}
}
// create and add node declaration
string nodeInitialization;
if (this.accessMode == SnmpAccessMode.ReadOnly)
{
nodeInitialization = String.Format("SNMP_SCALAR_CREATE_NODE_READONLY({0}, {1}, {2})",
this.Oid,
LwipDefs.GetAsn1DefForSnmpDataType(this.dataType),
getMethodName);
}
else
{
nodeInitialization = String.Format("SNMP_SCALAR_CREATE_NODE({0}, {1}, {2}, {3}, {4}, {5})",
this.Oid,
LwipDefs.GetLwipDefForSnmpAccessMode(this.accessMode),
LwipDefs.GetAsn1DefForSnmpDataType(this.dataType),
getMethodName,
testMethodName,
setMethodName);
}
mibFile.Declarations.Add(new VariableDeclaration(
new VariableType(this.FullNodeName, LwipDefs.Vt_StScalarNode, null, ConstType.Value),
nodeInitialization, isStatic: true));
}
public virtual void GenerateGetMethodCode(CodeContainerBase container, string valueVarName, ref bool valueVarUsed, string retLenVarName)
{
bool localValueVarUsed;
if (GenerateValueDeclaration(container, LocalValueName, valueVarName))
{
valueVarUsed = true;
localValueVarUsed = false;
}
else
{
localValueVarUsed = true; // do not generate UNUSED_ARG code
}
if (this.FixedValueLength == null)
{
// check that value with variable length fits into buffer
container.AddElement(new Comment(String.Format("TODO: take care that value with variable length fits into buffer: ({0} <= SNMP_MAX_VALUE_SIZE)", retLenVarName), singleLine: true));
}
GenerateGetMethodCodeCore(container, LocalValueName, ref localValueVarUsed, retLenVarName);
if (!localValueVarUsed)
{
container.AddCode(String.Format("LWIP_UNUSED_ARG({0});", LocalValueName));
}
}
protected virtual void GenerateGetMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string retLenVarName)
{
container.AddElement(new Comment(String.Format("TODO: put requested value to '*{0}' here", localValueVarName), singleLine: true));
container.AddCodeFormat("{0} = {1};",
retLenVarName,
(!String.IsNullOrWhiteSpace(this.FixedValueLength)) ? this.FixedValueLength : "0");
}
public virtual void GenerateTestMethodCode(CodeContainerBase container, string valueVarName, ref bool valueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
{
if (this.Restrictions.Count > 0)
{
bool localVarUsed;
if (GenerateValueDeclaration(container, LocalValueName, valueVarName))
{
valueVarUsed = true;
localVarUsed = false;
}
else
{
localVarUsed = true; // do not generate UNUSED_ARG code
}
if (!String.IsNullOrWhiteSpace(this.FixedValueLength))
{
// check for fixed value
container.AddCodeFormat("LWIP_ASSERT(\"Invalid length for datatype\", ({0} == {1}));", lenVarName, this.FixedValueLength);
lenVarUsed = true;
}
GenerateTestMethodCodeCore(container, LocalValueName, ref localVarUsed, lenVarName, ref lenVarUsed, retErrVarName);
if (!localVarUsed)
{
container.AddCode(String.Format("LWIP_UNUSED_ARG({0});", LocalValueName));
}
}
else
{
container.AddCodeFormat("{0} = {1};", retErrVarName, LwipDefs.Def_ErrorCode_Ok);
}
}
protected virtual void GenerateTestMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
{
container.AddElement(new Comment(String.Format("TODO: test new value here:\nif (*{0} == ) {1} = {2};", localValueVarName, retErrVarName, LwipDefs.Def_ErrorCode_Ok)));
}
public virtual void GenerateSetMethodCode(CodeContainerBase container, string valueVarName, ref bool valueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
{
bool localVarUsed;
if (GenerateValueDeclaration(container, LocalValueName, valueVarName))
{
valueVarUsed = true;
localVarUsed = false;
}
else
{
localVarUsed = true; // do not generate UNUSED_ARG code
}
GenerateSetMethodCodeCore(container, LocalValueName, ref localVarUsed, lenVarName, ref lenVarUsed, retErrVarName);
if (!localVarUsed)
{
container.AddCode(String.Format("LWIP_UNUSED_ARG({0});", LocalValueName));
}
}
protected virtual void GenerateSetMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
{
container.AddElement(new Comment(String.Format("TODO: store new value contained in '*{0}' here", localValueVarName), singleLine: true));
}
protected virtual bool GenerateValueDeclaration(CodeContainerBase container, string variableName, string sourceName)
{
container.AddDeclaration(new VariableDeclaration(
new VariableType(variableName, LwipDefs.Vt_U8, "*"),
"(" + new VariableType(null, LwipDefs.Vt_U8, "*") + ")" + sourceName));
return true;
}
public static SnmpScalarNode CreateFromDatatype(SnmpDataType dataType, SnmpTreeNode parentNode)
{
switch (dataType)
{
case SnmpDataType.Integer:
return new SnmpScalarNodeInt(parentNode);
case SnmpDataType.Gauge:
case SnmpDataType.Counter:
case SnmpDataType.TimeTicks:
return new SnmpScalarNodeUint(dataType, parentNode);
}
return new SnmpScalarNode(parentNode);
}
}
}

View File

@ -0,0 +1,121 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using System.Text;
using CCodeGeneration;
namespace LwipSnmpCodeGeneration
{
public class SnmpScalarNodeBits : SnmpScalarNode
{
private readonly uint bitCount;
public SnmpScalarNodeBits(SnmpTreeNode parentNode, uint bitCount)
: base(parentNode)
{
this.DataType = SnmpDataType.Bits;
this.bitCount = bitCount;
}
public override void GenerateGetMethodCode(CodeContainerBase container, string valueVarName, ref bool valueVarUsed, string retLenVarName)
{
container.AddCode(String.Format(
"{0} = snmp_encode_bits(({1} *){2}, SNMP_MAX_VALUE_SIZE, 0 /* TODO: pass real value here */, {3});",
retLenVarName,
LwipDefs.Vt_U8,
valueVarName,
this.bitCount));
valueVarUsed = true;
}
public override void GenerateTestMethodCode(CodeContainerBase container, string valueVarName, ref bool valueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
{
if (this.Restrictions.Count > 0)
{
const string bitVarName = "bits";
container.Declarations.Add(new VariableDeclaration(new VariableType(bitVarName, LwipDefs.Vt_U32)));
IfThenElse ite = new IfThenElse(String.Format(
"snmp_decode_bits(({0} *){1}, {2}, &{3}) == ERR_OK",
LwipDefs.Vt_U8,
valueVarName,
lenVarName,
bitVarName));
valueVarUsed = true;
lenVarUsed = true;
StringBuilder innerIfCond = new StringBuilder();
foreach (IRestriction restriction in this.Restrictions)
{
innerIfCond.Append(restriction.GetCheckCodeValid(bitVarName));
innerIfCond.Append(" || ");
}
innerIfCond.Length -= 4;
IfThenElse innerIte = new IfThenElse(innerIfCond.ToString());
innerIte.AddCode(String.Format("{0} = {1};", retErrVarName, LwipDefs.Def_ErrorCode_Ok));
ite.AddElement(innerIte);
container.AddElement(ite);
}
else
{
base.GenerateTestMethodCode(container, valueVarName, ref valueVarUsed, lenVarName, ref lenVarUsed, retErrVarName);
}
}
public override void GenerateSetMethodCode(CodeContainerBase container, string valueVarName, ref bool valueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
{
const string bitVarName = "bits";
container.Declarations.Add(new VariableDeclaration(new VariableType(bitVarName, LwipDefs.Vt_U32)));
IfThenElse ite = new IfThenElse(String.Format(
"snmp_decode_bits(({0} *){1}, {2}, &{3}) == ERR_OK",
LwipDefs.Vt_U8,
valueVarName,
lenVarName,
bitVarName));
valueVarUsed = true;
lenVarUsed = true;
ite.AddElement(new Comment(String.Format("TODO: store new value contained in '{0}' here", bitVarName), singleLine: true));
container.AddElement(ite);
}
}
}

View File

@ -0,0 +1,72 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using System.Text;
using CCodeGeneration;
namespace LwipSnmpCodeGeneration
{
public class SnmpScalarNodeCounter64 : SnmpScalarNode
{
public SnmpScalarNodeCounter64(SnmpTreeNode parentNode)
: base(parentNode)
{
this.DataType = SnmpDataType.Counter64;
}
protected override bool GenerateValueDeclaration(CodeContainerBase container, string variableName, string sourceName)
{
container.AddDeclaration(new VariableDeclaration(
new VariableType(variableName + "_high", LwipDefs.Vt_U32, "*"),
"(" + new VariableType(null, LwipDefs.Vt_U32, "*").ToString() + ")" + sourceName));
container.AddDeclaration(new VariableDeclaration(
new VariableType(variableName + "_low", LwipDefs.Vt_U32, "*"),
variableName + "_high + 1"));
container.AddCode(String.Format("LWIP_UNUSED_ARG({0}_high);", variableName));
container.AddCode(String.Format("LWIP_UNUSED_ARG({0}_low);", variableName));
return false;
}
public override string FixedValueLength
{
get { return String.Format("(2 * sizeof({0}))", LwipDefs.Vt_U32); }
}
public override int OidRepresentationLen
{
get { return 1; }
}
}
}

View File

@ -0,0 +1,86 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using System.Text;
using CCodeGeneration;
namespace LwipSnmpCodeGeneration
{
public class SnmpScalarNodeInt : SnmpScalarNode
{
public SnmpScalarNodeInt(SnmpTreeNode parentNode)
: base(parentNode)
{
this.DataType = SnmpDataType.Integer;
}
protected override void GenerateTestMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
{
System.Diagnostics.Trace.Assert(this.Restrictions.Count > 0);
StringBuilder ifCond = new StringBuilder();
foreach (IRestriction restriction in this.Restrictions)
{
ifCond.Append(restriction.GetCheckCodeValid("*" + localValueVarName));
ifCond.Append(" || ");
localValueVarUsed = true;
}
ifCond.Length -= 4;
IfThenElse ite = new IfThenElse(ifCond.ToString());
ite.AddCode(String.Format("{0} = {1};", retErrVarName, LwipDefs.Def_ErrorCode_Ok));
container.AddElement(ite);
}
protected override bool GenerateValueDeclaration(CodeContainerBase container, string variableName, string sourceName)
{
container.AddDeclaration(new VariableDeclaration(
new VariableType(variableName, LwipDefs.Vt_S32, "*"),
"(" + new VariableType(null, LwipDefs.Vt_S32, "*") + ")" + sourceName));
return true;
}
public override string FixedValueLength
{
get { return String.Format("sizeof({0})", LwipDefs.Vt_S32); }
}
public override int OidRepresentationLen
{
get { return 1; }
}
}
}

View File

@ -0,0 +1,90 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using CCodeGeneration;
namespace LwipSnmpCodeGeneration
{
public class SnmpScalarNodeObjectIdentifier: SnmpScalarNode
{
public SnmpScalarNodeObjectIdentifier(SnmpTreeNode parentNode)
: base(parentNode)
{
this.DataType = SnmpDataType.ObjectIdentifier;
}
protected override bool GenerateValueDeclaration(CodeContainerBase container, string variableName, string sourceName)
{
container.AddDeclaration(new VariableDeclaration(
new VariableType(variableName, LwipDefs.Vt_U32, "*"),
"(" + new VariableType(null, LwipDefs.Vt_U32, "*") + ")" + sourceName));
return true;
}
protected override void GenerateGetMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string retLenVarName)
{
container.AddElement(new Comment(String.Format("TODO: put requested value to '*{0}' here. '{0}' has to be interpreted as {1}[]", localValueVarName, LwipDefs.Vt_U32), singleLine: true));
container.AddElement(EmptyLine.SingleLine);
container.AddCode(String.Format("{0} = 0; // TODO: return real value length here (should be 'numOfElements * sizeof({1})')", retLenVarName, LwipDefs.Vt_U32));
}
protected override void GenerateTestMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
{
VariableDeclaration objIdLenVar = new VariableDeclaration(
new VariableType(localValueVarName + "_len", LwipDefs.Vt_U8),
String.Format("{0} / sizeof({1})", lenVarName, LwipDefs.Vt_U32));
lenVarUsed = true;
container.Declarations.Add(objIdLenVar);
base.GenerateTestMethodCodeCore(container, localValueVarName, ref localValueVarUsed, lenVarName, ref lenVarUsed, retErrVarName);
container.AddCode(String.Format("LWIP_UNUSED_ARG({0});", objIdLenVar.Type.Name));
}
protected override void GenerateSetMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
{
VariableDeclaration objIdLenVar = new VariableDeclaration(
new VariableType(localValueVarName + "_len", LwipDefs.Vt_U8),
String.Format("{0} / sizeof({1})", lenVarName, LwipDefs.Vt_U32));
lenVarUsed = true;
container.Declarations.Add(objIdLenVar);
base.GenerateSetMethodCodeCore(container, localValueVarName, ref localValueVarUsed, lenVarName, ref lenVarUsed, retErrVarName);
container.AddCode(String.Format("LWIP_UNUSED_ARG({0});", objIdLenVar.Type.Name));
}
}
}

View File

@ -0,0 +1,118 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using System.Text;
using CCodeGeneration;
namespace LwipSnmpCodeGeneration
{
public class SnmpScalarNodeOctetString : SnmpScalarNode
{
public SnmpScalarNodeOctetString(SnmpDataType dataType, SnmpTreeNode parentNode)
: base(parentNode)
{
System.Diagnostics.Debug.Assert(
(dataType == SnmpDataType.OctetString) ||
(dataType == SnmpDataType.Opaque) ||
(dataType == SnmpDataType.IpAddress));
this.DataType = dataType;
}
protected override void GenerateGetMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string retLenVarName)
{
if (this.Restrictions.Count > 0)
{
StringBuilder ifCond = new StringBuilder();
foreach (IRestriction restriction in this.Restrictions)
{
ifCond.Append(restriction.GetCheckCodeValid(retLenVarName));
ifCond.Append(" || ");
}
ifCond.Length -= 4;
container.AddElement(new Comment("TODO: take care of len restrictions defined in MIB: " + ifCond, singleLine: true));
}
base.GenerateGetMethodCodeCore(container, localValueVarName, ref localValueVarUsed, retLenVarName);
}
protected override void GenerateTestMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
{
System.Diagnostics.Trace.Assert(this.Restrictions.Count > 0);
// checks refer to length of octet string
StringBuilder ifCond = new StringBuilder();
foreach (IRestriction restriction in this.Restrictions)
{
ifCond.Append(restriction.GetCheckCodeValid(lenVarName));
ifCond.Append(" || ");
lenVarUsed = true;
}
ifCond.Length -= 4;
IfThenElse ite = new IfThenElse(ifCond.ToString());
ite.AddCode(String.Format("{0} = {1};", retErrVarName, LwipDefs.Def_ErrorCode_Ok));
container.AddElement(ite);
}
public override int OidRepresentationLen
{
get
{
// check restrictions if we are set to one fixed length
if ((this.Restrictions != null) && (this.Restrictions.Count > 0))
{
foreach (IRestriction restriction in this.Restrictions)
{
if (restriction is IsInRangeRestriction)
{
if ((restriction as IsInRangeRestriction).RangeStart == (restriction as IsInRangeRestriction).RangeEnd)
{
return (int)(restriction as IsInRangeRestriction).RangeStart;
}
}
else if (restriction is IsEqualRestriction)
{
return (int)(restriction as IsEqualRestriction).Value;
}
}
}
return -1; // variable length
}
}
}
}

View File

@ -0,0 +1,66 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using CCodeGeneration;
namespace LwipSnmpCodeGeneration
{
public class SnmpScalarNodeTruthValue : SnmpScalarNodeInt
{
public SnmpScalarNodeTruthValue(SnmpTreeNode parentNode)
: base(parentNode)
{
}
protected override void GenerateGetMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string retLenVarName)
{
container.AddCodeFormat("snmp_encode_truthvalue({0}, /* TODO: put requested bool value here */ 0);", localValueVarName);
localValueVarUsed = true;
container.AddCode(String.Format("{0} = {1};",
retLenVarName,
(!String.IsNullOrWhiteSpace(this.FixedValueLength)) ? this.FixedValueLength : "0"));
}
protected override void GenerateSetMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
{
VariableType truthVar = new VariableType("bool_value", LwipDefs.Vt_U8);
container.Declarations.Add(new VariableDeclaration(truthVar));
container.AddCodeFormat("snmp_decode_truthvalue({0}, &{1});", localValueVarName, truthVar.Name);
localValueVarUsed = true;
container.AddElement(new Comment(String.Format("TODO: store new value contained in '{0}' here", truthVar.Name), singleLine: true));
}
}
}

View File

@ -0,0 +1,91 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using System.Text;
using CCodeGeneration;
namespace LwipSnmpCodeGeneration
{
public class SnmpScalarNodeUint : SnmpScalarNode
{
public SnmpScalarNodeUint(SnmpDataType dataType, SnmpTreeNode parentNode)
: base(parentNode)
{
System.Diagnostics.Debug.Assert(
(dataType == SnmpDataType.Counter) ||
(dataType == SnmpDataType.Gauge) ||
(dataType == SnmpDataType.TimeTicks));
this.DataType = dataType;
}
protected override void GenerateTestMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
{
System.Diagnostics.Trace.Assert(this.Restrictions.Count > 0);
StringBuilder ifCond = new StringBuilder();
foreach (IRestriction restriction in this.Restrictions)
{
ifCond.Append(restriction.GetCheckCodeValid("*" + localValueVarName));
ifCond.Append(" || ");
localValueVarUsed = true;
}
ifCond.Length -= 4;
IfThenElse ite = new IfThenElse(ifCond.ToString());
ite.AddCode(String.Format("{0} = {1};", retErrVarName, LwipDefs.Def_ErrorCode_Ok));
container.AddElement(ite);
}
protected override bool GenerateValueDeclaration(CodeContainerBase container, string variableName, string sourceName)
{
container.AddDeclaration(new VariableDeclaration(
new VariableType(variableName, LwipDefs.Vt_U32, "*"),
"(" + new VariableType(null, LwipDefs.Vt_U32, "*") + ")" + sourceName));
return true;
}
public override string FixedValueLength
{
get { return String.Format("sizeof({0})", LwipDefs.Vt_U32); }
}
public override int OidRepresentationLen
{
get { return 1; }
}
}
}

View File

@ -0,0 +1,332 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using CCodeGeneration;
namespace LwipSnmpCodeGeneration
{
public class SnmpTableNode: SnmpScalarAggregationNode
{
private readonly List<SnmpScalarNode> cellNodes = new List<SnmpScalarNode>();
private readonly List<SnmpScalarNode> indexNodes = new List<SnmpScalarNode>();
private string augmentedTableRow = null;
public SnmpTableNode(SnmpTreeNode parentNode)
: base(parentNode)
{
}
public List<SnmpScalarNode> CellNodes
{
get { return cellNodes; }
}
public List<SnmpScalarNode> IndexNodes
{
get { return indexNodes; }
}
public string AugmentedTableRow
{
get { return this.augmentedTableRow; }
set { this.augmentedTableRow = value; }
}
public override string FullNodeName
{
get
{
string result = this.Name.ToLowerInvariant();
if (!result.Contains("table"))
{
result += "_table";
}
return result;
}
}
protected override IEnumerable<SnmpScalarNode> AggregatedScalarNodes
{
get { return this.cellNodes; }
}
public override void GenerateCode(MibCFile mibFile)
{
FunctionDeclaration getInstanceMethodDecl = new FunctionDeclaration(this.FullNodeName + LwipDefs.FnctSuffix_GetInstance, isStatic: true);
getInstanceMethodDecl.Parameter.Add(new VariableType("column", LwipDefs.Vt_U32, "*", ConstType.Value));
getInstanceMethodDecl.Parameter.Add(new VariableType("row_oid", LwipDefs.Vt_U32, "*", ConstType.Value));
getInstanceMethodDecl.Parameter.Add(new VariableType("row_oid_len", LwipDefs.Vt_U8, ""));
getInstanceMethodDecl.Parameter.Add(new VariableType("cell_instance", LwipDefs.Vt_StNodeInstance, "*"));
getInstanceMethodDecl.ReturnType = new VariableType(null, LwipDefs.Vt_Snmp_err);
mibFile.Declarations.Add(getInstanceMethodDecl);
Function getInstanceMethod = Function.FromDeclaration(getInstanceMethodDecl);
GenerateGetInstanceMethodCode(getInstanceMethod);
mibFile.Implementation.Add(getInstanceMethod);
FunctionDeclaration getNextInstanceMethodDecl = new FunctionDeclaration(this.FullNodeName + LwipDefs.FnctSuffix_GetNextInstance, isStatic: true);
getNextInstanceMethodDecl.Parameter.Add(new VariableType("column", LwipDefs.Vt_U32, "*", ConstType.Value));
getNextInstanceMethodDecl.Parameter.Add(new VariableType("row_oid", LwipDefs.Vt_StObjectId, "*"));
getNextInstanceMethodDecl.Parameter.Add(new VariableType("cell_instance", LwipDefs.Vt_StNodeInstance, "*"));
getNextInstanceMethodDecl.ReturnType = new VariableType(null, LwipDefs.Vt_Snmp_err);
mibFile.Declarations.Add(getNextInstanceMethodDecl);
Function getNextInstanceMethod = Function.FromDeclaration(getNextInstanceMethodDecl);
GenerateGetNextInstanceMethodCode(getNextInstanceMethod);
mibFile.Implementation.Add(getNextInstanceMethod);
VariableType instanceType = new VariableType("cell_instance", LwipDefs.Vt_StNodeInstance, "*");
GenerateAggregatedCode(
mibFile,
instanceType,
String.Format("SNMP_TABLE_GET_COLUMN_FROM_OID({0}->instance_oid.id)", instanceType.Name));
#region create and add column/table definitions
StringBuilder colDefs = new StringBuilder();
foreach (SnmpScalarNode colNode in this.cellNodes)
{
colDefs.AppendFormat(" {{{0}, {1}, {2}}}, /* {3} */ \n",
colNode.Oid,
LwipDefs.GetAsn1DefForSnmpDataType(colNode.DataType),
LwipDefs.GetLwipDefForSnmpAccessMode(colNode.AccessMode),
colNode.Name);
}
if (colDefs.Length > 0)
{
colDefs.Length--;
}
VariableDeclaration colDefsDecl = new VariableDeclaration(
new VariableType(this.FullNodeName + "_columns", LwipDefs.Vt_StTableColumnDef, null, ConstType.Value, String.Empty),
"{\n" + colDefs + "\n}",
isStatic: true);
mibFile.Declarations.Add(colDefsDecl);
string nodeInitialization = String.Format("SNMP_TABLE_CREATE({0}, {1}, {2}, {3}, {4}, {5}, {6})",
this.Oid,
colDefsDecl.Type.Name,
getInstanceMethodDecl.Name, getNextInstanceMethodDecl.Name,
(this.GetMethodRequired) ? this.GetMethodName : LwipDefs.Null,
(this.TestMethodRequired) ? this.TestMethodName : LwipDefs.Null,
(this.SetMethodRequired) ? this.SetMethodName : LwipDefs.Null
);
mibFile.Declarations.Add(new VariableDeclaration(
new VariableType(this.FullNodeName, LwipDefs.Vt_StTableNode, null, ConstType.Value),
nodeInitialization,
isStatic: true));
#endregion
}
protected virtual void GenerateGetInstanceMethodCode(Function getInstanceMethod)
{
VariableDeclaration returnValue = new VariableDeclaration((VariableType)getInstanceMethod.ReturnType.Clone(), LwipDefs.Def_ErrorCode_NoSuchInstance);
returnValue.Type.Name = "err";
getInstanceMethod.Declarations.Add(returnValue);
int instanceOidLength = 0;
StringBuilder indexColumns = new StringBuilder();
foreach (SnmpScalarNode indexNode in this.indexNodes)
{
if (instanceOidLength >= 0)
{
if (indexNode.OidRepresentationLen >= 0)
{
instanceOidLength += indexNode.OidRepresentationLen;
}
else
{
// at least one index column has a variable length -> we cannot perform a static check
instanceOidLength = -1;
}
}
indexColumns.AppendFormat(
" {0} ({1}, OID length = {2})\n",
indexNode.Name,
indexNode.DataType,
(indexNode.OidRepresentationLen >= 0) ? indexNode.OidRepresentationLen.ToString() : "variable");
}
if (indexColumns.Length > 0)
{
indexColumns.Length--;
getInstanceMethod.Declarations.Insert(0, new Comment(String.Format(
"The instance OID of this table consists of following (index) column(s):\n{0}",
indexColumns)));
}
string augmentsHint = "";
if (!String.IsNullOrWhiteSpace(this.augmentedTableRow))
{
augmentsHint = String.Format(
"This table augments table '{0}'! Index columns therefore belong to table '{0}'!\n" +
"You may simply call the '*{1}' method of this table.\n\n",
(this.augmentedTableRow.ToLowerInvariant().EndsWith("entry")) ? this.augmentedTableRow.Substring(0, this.augmentedTableRow.Length-5) : this.augmentedTableRow,
LwipDefs.FnctSuffix_GetInstance);
}
CodeContainerBase ccb = getInstanceMethod;
if (instanceOidLength > 0)
{
IfThenElse ite = new IfThenElse(String.Format("{0} == {1}", getInstanceMethod.Parameter[2].Name, instanceOidLength));
getInstanceMethod.AddElement(ite);
ccb = ite;
}
ccb.AddCodeFormat("LWIP_UNUSED_ARG({0});", getInstanceMethod.Parameter[0].Name);
ccb.AddCodeFormat("LWIP_UNUSED_ARG({0});", getInstanceMethod.Parameter[1].Name);
if (instanceOidLength <= 0)
{
ccb.AddCodeFormat("LWIP_UNUSED_ARG({0});", getInstanceMethod.Parameter[2].Name);
}
ccb.AddCodeFormat("LWIP_UNUSED_ARG({0});", getInstanceMethod.Parameter[3].Name);
ccb.AddElement(new Comment(String.Format(
"TODO: check if '{0}'/'{1}' params contain a valid instance oid for a row\n" +
"If so, set '{2} = {3};'\n\n" +
"snmp_oid_* methods may be used for easier processing of oid\n\n" +
"{4}" +
"In order to avoid decoding OID a second time in subsequent get_value/set_test/set_value methods,\n" +
"you may store an arbitrary value (like a pointer to target value object) in '{5}->reference'/'{5}->reference_len'.\n" +
"But be aware that not always a subsequent method is called -> Do NOT allocate memory here and try to release it in subsequent methods!\n\n" +
"You also may replace function pointers in '{5}' param for get/test/set methods which contain the default values from table definition,\n" +
"in order to provide special methods, for the currently processed cell. Changed pointers are only valid for current request.",
getInstanceMethod.Parameter[1].Name,
getInstanceMethod.Parameter[2].Name,
returnValue.Type.Name,
LwipDefs.Def_ErrorCode_Ok,
augmentsHint,
getInstanceMethod.Parameter[3].Name
)));
getInstanceMethod.AddCodeFormat("return {0};", returnValue.Type.Name);
}
protected virtual void GenerateGetNextInstanceMethodCode(Function getNextInstanceMethod)
{
getNextInstanceMethod.AddCodeFormat("LWIP_UNUSED_ARG({0});", getNextInstanceMethod.Parameter[0].Name);
getNextInstanceMethod.AddCodeFormat("LWIP_UNUSED_ARG({0});", getNextInstanceMethod.Parameter[1].Name);
getNextInstanceMethod.AddCodeFormat("LWIP_UNUSED_ARG({0});", getNextInstanceMethod.Parameter[2].Name);
VariableDeclaration returnValue = new VariableDeclaration((VariableType)getNextInstanceMethod.ReturnType.Clone(), LwipDefs.Def_ErrorCode_NoSuchInstance);
returnValue.Type.Name = "err";
getNextInstanceMethod.Declarations.Add(returnValue);
StringBuilder indexColumns = new StringBuilder();
foreach (SnmpScalarNode indexNode in this.indexNodes)
{
indexColumns.AppendFormat(
" {0} ({1}, OID length = {2})\n",
indexNode.Name,
indexNode.DataType,
(indexNode.OidRepresentationLen >= 0) ? indexNode.OidRepresentationLen.ToString() : "variable");
}
if (indexColumns.Length > 0)
{
indexColumns.Length--;
getNextInstanceMethod.Declarations.Insert(0, new Comment(String.Format(
"The instance OID of this table consists of following (index) column(s):\n{0}",
indexColumns)));
}
string augmentsHint = "";
if (!String.IsNullOrWhiteSpace(this.augmentedTableRow))
{
augmentsHint = String.Format(
"This table augments table '{0}'! Index columns therefore belong to table '{0}'!\n" +
"You may simply call the '*{1}' method of this table.\n\n",
(this.augmentedTableRow.ToLowerInvariant().EndsWith("entry")) ? this.augmentedTableRow.Substring(0, this.augmentedTableRow.Length-5) : this.augmentedTableRow,
LwipDefs.FnctSuffix_GetNextInstance);
}
getNextInstanceMethod.AddElement(new Comment(String.Format(
"TODO: analyze '{0}->id'/'{0}->len' and return the subsequent row instance\n" +
"Be aware that '{0}->id'/'{0}->len' must not point to a valid instance or have correct instance length.\n" +
"If '{0}->len' is 0, return the first instance. If '{0}->len' is longer than expected, cut superfluous OID parts.\n" +
"If a valid next instance is found, store it in '{0}->id'/'{0}->len' and set '{1} = {2};'\n\n" +
"snmp_oid_* methods may be used for easier processing of oid\n\n" +
"{3}" +
"In order to avoid decoding OID a second time in subsequent get_value/set_test/set_value methods,\n" +
"you may store an arbitrary value (like a pointer to target value object) in '{4}->reference'/'{4}->reference_len'.\n" +
"But be aware that not always a subsequent method is called -> Do NOT allocate memory here and try to release it in subsequent methods!\n\n" +
"You also may replace function pointers in '{4}' param for get/test/set methods which contain the default values from table definition,\n" +
"in order to provide special methods, for the currently processed cell. Changed pointers are only valid for current request.",
getNextInstanceMethod.Parameter[1].Name,
returnValue.Type.Name,
LwipDefs.Def_ErrorCode_Ok,
augmentsHint,
getNextInstanceMethod.Parameter[2].Name
)));
getNextInstanceMethod.AddElement(new Comment(String.Format(
"For easier processing and getting the next instance, you may use the 'snmp_next_oid_*' enumerator.\n" +
"Simply pass all known instance OID's to it and it returns the next valid one:\n\n" +
"{0} state;\n" +
"{1} result_buf;\n" +
"snmp_next_oid_init(&state, {2}->id, {2}->len, result_buf.id, SNMP_MAX_OBJ_ID_LEN);\n" +
"while ({{not all instances passed}}) {{\n" +
" {1} test_oid;\n" +
" {{fill test_oid to create instance oid for next instance}}\n" +
" snmp_next_oid_check(&state, test_oid.id, test_oid.len, {{target_data_ptr}});\n" +
"}}\n" +
"if(state.status == SNMP_NEXT_OID_STATUS_SUCCESS) {{\n" +
" snmp_oid_assign(row_oid, state.next_oid, state.next_oid_len);\n" +
" {3}->reference.ptr = state.reference; //==target_data_ptr, for usage in subsequent get/test/set\n" +
" {4} = {5};\n" +
"}}"
,
LwipDefs.Vt_StNextOidState,
LwipDefs.Vt_StObjectId,
getNextInstanceMethod.Parameter[1].Name,
getNextInstanceMethod.Parameter[2].Name,
returnValue.Type.Name,
LwipDefs.Def_ErrorCode_Ok
)));
getNextInstanceMethod.AddCodeFormat("return {0};", returnValue.Type.Name);
}
}
}

View File

@ -0,0 +1,242 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using CCodeGeneration;
namespace LwipSnmpCodeGeneration
{
public class SnmpTreeNode: SnmpScalarAggregationNode
{
private readonly List<SnmpNode> childNodes = new List<SnmpNode>();
private readonly List<SnmpScalarNode> childScalarNodes = new List<SnmpScalarNode>();
private string fullOid = "";
public SnmpTreeNode(SnmpTreeNode parentNode)
: base(parentNode)
{
}
public override string FullNodeName
{
get { return this.Name.ToLowerInvariant() + "_treenode"; }
}
public string FullOid
{
get { return this.fullOid; }
set { this.fullOid = value; }
}
public List<SnmpNode> ChildNodes
{
get { return this.childNodes; }
}
protected override IEnumerable<SnmpScalarNode> AggregatedScalarNodes
{
get { return this.childScalarNodes; }
}
private void GenerateAggregatedCode(MibCFile mibFile, bool generateDeclarations, bool generateImplementations)
{
VariableType instanceType = new VariableType("instance", LwipDefs.Vt_StNodeInstance, "*");
base.GenerateAggregatedCode(
mibFile,
instanceType,
String.Format("{0}->node->oid", instanceType.Name),
generateDeclarations,
generateImplementations);
}
private void GenerateAggregateMethodDeclarations(MibCFile mibFile)
{
if (LwipOpts.GenerateSingleAccessMethodsForTreeNodeScalars && (this.childScalarNodes.Count > 1))
{
GenerateAggregatedCode(mibFile, true, false);
}
}
public override void GenerateCode(MibCFile mibFile)
{
string nodeInitialization;
if (LwipOpts.GenerateSingleAccessMethodsForTreeNodeScalars && (this.childScalarNodes.Count > 1))
{
GenerateAggregatedCode(mibFile, false, true);
}
// create and add node declaration
if (this.childNodes.Count > 0)
{
StringBuilder subnodeArrayInitialization = new StringBuilder();
for (int i=0; i<this.childNodes.Count; i++)
{
subnodeArrayInitialization.Append(" &");
subnodeArrayInitialization.Append(this.childNodes[i].FullNodeName);
subnodeArrayInitialization.Append(".node");
if (!(this.childNodes[i] is SnmpTreeNode))
{
subnodeArrayInitialization.Append(".node");
}
if (i < (this.childNodes.Count - 1))
{
subnodeArrayInitialization.Append(",\n");
}
}
VariableDeclaration subnodeArray = new VariableDeclaration(
new VariableType(this.Name.ToLowerInvariant() + "_subnodes", LwipDefs.Vt_StNode, "*", ConstType.Both, String.Empty),
"{\n" + subnodeArrayInitialization + "\n}",
isStatic: true);
mibFile.Declarations.Add(subnodeArray);
nodeInitialization = String.Format("SNMP_CREATE_TREE_NODE({0}, {1})", this.Oid, subnodeArray.Type.Name);
}
else
{
nodeInitialization = String.Format("SNMP_CREATE_EMPTY_TREE_NODE({0})", this.Oid);
}
mibFile.Declarations.Add(new VariableDeclaration(
new VariableType(this.FullNodeName, LwipDefs.Vt_StTreeNode, null, ConstType.Value),
nodeInitialization,
isStatic: true));
}
public override void Analyze()
{
this.childScalarNodes.Clear();
// delegate analyze (don't use enumerator because the child node may change our child collection by e.g. removing or replacing itself)
for (int i=this.ChildNodes.Count-1; i>=0; i--)
{
this.ChildNodes[i].Analyze();
}
// collect scalar nodes
foreach (SnmpNode childNode in this.childNodes)
{
SnmpScalarNode scalarNode = childNode as SnmpScalarNode;
if (scalarNode != null)
{
this.childScalarNodes.Add(scalarNode);
}
}
base.Analyze();
// check if we can merge this node to a scalar array node (all childs need to be scalars)
if (this.childNodes.Count > 0)
{
if (LwipOpts.GenerateScalarArrays && (this.childScalarNodes.Count == this.childNodes.Count) && (this.ParentNode != null))
{
SnmpScalarArrayNode scalarArrayNode = new SnmpScalarArrayNode(this.childScalarNodes, this.ParentNode);
scalarArrayNode.Oid = this.Oid;
scalarArrayNode.Name = this.Name;
scalarArrayNode.Analyze();
for (int i=0; i<this.ParentNode.ChildNodes.Count; i++)
{
if (this.ParentNode.ChildNodes[i] == this)
{
this.ParentNode.ChildNodes.RemoveAt(i);
this.ParentNode.ChildNodes.Insert(i, scalarArrayNode);
break;
}
}
}
else if (LwipOpts.GenerateSingleAccessMethodsForTreeNodeScalars && (this.childScalarNodes.Count > 1))
{
foreach (SnmpScalarNode scalarNode in this.childScalarNodes)
{
scalarNode.UseExternalMethods = true;
scalarNode.ExternalGetMethod = this.GetMethodName;
scalarNode.ExternalTestMethod = this.TestMethodName;
scalarNode.ExternalSetMethod = this.SetMethodName;
}
}
}
else // if (this.childNodes.Count == 0)
{
if (!LwipOpts.GenerateEmptyFolders && (this.ParentNode != null))
{
// do not generate this empty folder because it only waste (static) memory
for (int i=0; i<this.ParentNode.ChildNodes.Count; i++)
{
if (this.ParentNode.ChildNodes[i] == this)
{
this.ParentNode.ChildNodes.RemoveAt(i);
break;
}
}
}
}
}
public override void Generate(MibCFile generatedFile, MibHeaderFile generatedHeaderFile)
{
// generate code of child nodes
foreach (SnmpNode childNode in this.childNodes)
{
if (childNode is SnmpTreeNode)
{
childNode.Generate(generatedFile, generatedHeaderFile);
}
}
Comment dividerComment = new Comment(
String.Format("--- {0} {1} -----------------------------------------------------", this.Name, this.fullOid),
singleLine: true);
generatedFile.Declarations.Add(dividerComment);
generatedFile.Implementation.Add(dividerComment);
this.GenerateAggregateMethodDeclarations(generatedFile);
foreach (SnmpNode childNode in this.childNodes)
{
if (!(childNode is SnmpTreeNode))
{
childNode.Generate(generatedFile, generatedHeaderFile);
}
}
base.Generate(generatedFile, generatedHeaderFile);
}
}
}

View File

@ -0,0 +1,166 @@
namespace LwipMibViewer
{
partial class FormMain
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Windows Form-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain));
this.treeMib = new System.Windows.Forms.TreeView();
this.imagelistTreeNodeImages = new System.Windows.Forms.ImageList(this.components);
this.splitContainerMain = new System.Windows.Forms.SplitContainer();
this.listviewNodeDetails = new System.Windows.Forms.ListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.toolStripMain = new System.Windows.Forms.ToolStrip();
this.toolbuttonOpenMib = new System.Windows.Forms.ToolStripButton();
this.dialogOpenMib = new System.Windows.Forms.OpenFileDialog();
((System.ComponentModel.ISupportInitialize)(this.splitContainerMain)).BeginInit();
this.splitContainerMain.Panel1.SuspendLayout();
this.splitContainerMain.Panel2.SuspendLayout();
this.splitContainerMain.SuspendLayout();
this.toolStripMain.SuspendLayout();
this.SuspendLayout();
//
// treeMib
//
this.treeMib.Dock = System.Windows.Forms.DockStyle.Fill;
this.treeMib.ImageIndex = 0;
this.treeMib.ImageList = this.imagelistTreeNodeImages;
this.treeMib.Location = new System.Drawing.Point(0, 0);
this.treeMib.Name = "treeMib";
this.treeMib.SelectedImageIndex = 0;
this.treeMib.Size = new System.Drawing.Size(1028, 418);
this.treeMib.TabIndex = 0;
this.treeMib.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeMib_AfterSelect);
//
// imagelistTreeNodeImages
//
this.imagelistTreeNodeImages.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imagelistTreeNodeImages.ImageStream")));
this.imagelistTreeNodeImages.TransparentColor = System.Drawing.Color.Transparent;
this.imagelistTreeNodeImages.Images.SetKeyName(0, "ntimgContainer");
this.imagelistTreeNodeImages.Images.SetKeyName(1, "ntimgTable");
this.imagelistTreeNodeImages.Images.SetKeyName(2, "ntimgRow");
this.imagelistTreeNodeImages.Images.SetKeyName(3, "ntimgColumn");
this.imagelistTreeNodeImages.Images.SetKeyName(4, "ntimgScalar");
this.imagelistTreeNodeImages.Images.SetKeyName(5, "ntimgUnknown");
//
// splitContainerMain
//
this.splitContainerMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainerMain.Location = new System.Drawing.Point(0, 25);
this.splitContainerMain.Name = "splitContainerMain";
this.splitContainerMain.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainerMain.Panel1
//
this.splitContainerMain.Panel1.Controls.Add(this.treeMib);
//
// splitContainerMain.Panel2
//
this.splitContainerMain.Panel2.Controls.Add(this.listviewNodeDetails);
this.splitContainerMain.Size = new System.Drawing.Size(1028, 625);
this.splitContainerMain.SplitterDistance = 418;
this.splitContainerMain.TabIndex = 1;
//
// listviewNodeDetails
//
this.listviewNodeDetails.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2});
this.listviewNodeDetails.Dock = System.Windows.Forms.DockStyle.Fill;
this.listviewNodeDetails.FullRowSelect = true;
this.listviewNodeDetails.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.listviewNodeDetails.Location = new System.Drawing.Point(0, 0);
this.listviewNodeDetails.Name = "listviewNodeDetails";
this.listviewNodeDetails.Size = new System.Drawing.Size(1028, 203);
this.listviewNodeDetails.TabIndex = 0;
this.listviewNodeDetails.UseCompatibleStateImageBehavior = false;
this.listviewNodeDetails.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "";
this.columnHeader1.Width = 150;
//
// columnHeader2
//
this.columnHeader2.Text = "";
this.columnHeader2.Width = 777;
//
// toolStripMain
//
this.toolStripMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolbuttonOpenMib});
this.toolStripMain.Location = new System.Drawing.Point(0, 0);
this.toolStripMain.Name = "toolStripMain";
this.toolStripMain.Size = new System.Drawing.Size(1028, 25);
this.toolStripMain.TabIndex = 2;
//
// toolbuttonOpenMib
//
this.toolbuttonOpenMib.Image = ((System.Drawing.Image)(resources.GetObject("toolbuttonOpenMib.Image")));
this.toolbuttonOpenMib.Name = "toolbuttonOpenMib";
this.toolbuttonOpenMib.Size = new System.Drawing.Size(65, 22);
this.toolbuttonOpenMib.Text = "Open...";
this.toolbuttonOpenMib.Click += new System.EventHandler(this.toolbuttonOpenMib_Click);
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1028, 650);
this.Controls.Add(this.splitContainerMain);
this.Controls.Add(this.toolStripMain);
this.Name = "FormMain";
this.Text = "MIB Viewer";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.splitContainerMain.Panel1.ResumeLayout(false);
this.splitContainerMain.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainerMain)).EndInit();
this.splitContainerMain.ResumeLayout(false);
this.toolStripMain.ResumeLayout(false);
this.toolStripMain.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TreeView treeMib;
private System.Windows.Forms.SplitContainer splitContainerMain;
private System.Windows.Forms.ListView listviewNodeDetails;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ImageList imagelistTreeNodeImages;
private System.Windows.Forms.ToolStrip toolStripMain;
private System.Windows.Forms.ToolStripButton toolbuttonOpenMib;
private System.Windows.Forms.OpenFileDialog dialogOpenMib;
}
}

View File

@ -0,0 +1,217 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System.Windows.Forms;
using Lextm.SharpSnmpLib.Mib;
using Lextm.SharpSnmpLib.Mib.Elements;
using Lextm.SharpSnmpLib.Mib.Elements.Types;
using Lextm.SharpSnmpLib.Mib.Elements.Entities;
using System.IO;
namespace LwipMibViewer
{
public partial class FormMain : Form
{
readonly ListViewGroup listviewgroupAbstract;
readonly ListViewGroup listviewgroupElement;
readonly ListViewGroup listviewgroupBaseType;
readonly ListViewGroup listviewgroupTypeChain;
public FormMain()
{
this.Font = SystemInformation.MenuFont;
InitializeComponent();
this.listviewgroupAbstract = new ListViewGroup("Abstract", System.Windows.Forms.HorizontalAlignment.Left);
this.listviewgroupElement = new ListViewGroup("Element Properties", System.Windows.Forms.HorizontalAlignment.Left);
this.listviewgroupBaseType = new ListViewGroup("Element Base Type", System.Windows.Forms.HorizontalAlignment.Left);
this.listviewgroupTypeChain = new ListViewGroup("Element Type Chain", System.Windows.Forms.HorizontalAlignment.Left);
this.listviewNodeDetails.Groups.AddRange(new System.Windows.Forms.ListViewGroup[] {
listviewgroupAbstract,
listviewgroupElement,
listviewgroupBaseType,
listviewgroupTypeChain});
try
{
DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(Application.ExecutablePath));
if (dirInfo != null)
{
dirInfo = dirInfo.Parent;
if (dirInfo != null)
{
dirInfo = dirInfo.Parent;
if (dirInfo != null)
{
dirInfo = new DirectoryInfo(Path.Combine(dirInfo.FullName, "Mibs"));
if (dirInfo.Exists)
{
MibTypesResolver.RegisterResolver(new FileSystemMibResolver(dirInfo.FullName, true));
}
}
}
}
}
catch
{ }
}
#region GUI Event Handler
private void toolbuttonOpenMib_Click(object sender, System.EventArgs e)
{
if (this.dialogOpenMib.ShowDialog() == DialogResult.OK)
{
OpenMib(this.dialogOpenMib.FileName);
}
}
private void treeMib_AfterSelect(object sender, TreeViewEventArgs e)
{
listviewNodeDetails.Items.Clear();
if (e.Node != null)
{
MibTreeNode mtn = e.Node.Tag as MibTreeNode;
if (mtn != null)
{
listviewNodeDetails.Items.Add(new ListViewItem(new string[] { "Abstract", mtn.NodeType.ToString() }, this.listviewgroupAbstract));
listviewNodeDetails.Items.Add(new ListViewItem(new string[] { "Module", (mtn.Entity.Module != null) ? mtn.Entity.Module.Name : "" }, this.listviewgroupElement));
listviewNodeDetails.Items.Add(new ListViewItem(new string[] { "Type", mtn.Entity.GetType().Name }, this.listviewgroupElement));
listviewNodeDetails.Items.Add(new ListViewItem(new string[] { "Name", mtn.Entity.Name }, this.listviewgroupElement));
listviewNodeDetails.Items.Add(new ListViewItem(new string[] { "Description", mtn.Entity.Description }, this.listviewgroupElement));
listviewNodeDetails.Items.Add(new ListViewItem(new string[] { "OID", mtn.Entity.Value.ToString() }, this.listviewgroupElement));
listviewNodeDetails.Items.Add(new ListViewItem(new string[] { "Full OID", MibTypesResolver.ResolveOid(mtn.Entity).GetOidString() }, this.listviewgroupElement));
if (mtn.Entity is ObjectType)
{
listviewNodeDetails.Items.Add(new ListViewItem(new string[] { "Access", (mtn.Entity as ObjectType).Access.ToString() }, this.listviewgroupElement));
}
ITypeReferrer tr = mtn.Entity as ITypeReferrer;
if (tr != null)
{
ShowTypeDetails(listviewNodeDetails, this.listviewgroupBaseType, tr.BaseType);
ShowTypeChain(listviewNodeDetails, tr.ReferredType);
}
}
}
}
#endregion
#region Methods
private void OpenMib(string file)
{
try
{
MibDocument md = new MibDocument(file);
MibTypesResolver.ResolveTypes(md.Modules[0]);
this.treeMib.Nodes.Clear();
this.listviewNodeDetails.Items.Clear();
MibTree mt = new MibTree(md.Modules[0] as MibModule);
foreach (MibTreeNode mibTreeNode in mt.Root)
{
AddNode(mibTreeNode, this.treeMib.Nodes);
foreach (TreeNode node in this.treeMib.Nodes)
{
node.Expand();
}
}
}
catch
{
}
}
private void AddNode(MibTreeNode mibNode, TreeNodeCollection parentNodes)
{
int imgIndex = 5; //unknown
if ((mibNode.NodeType & MibTreeNodeType.Table) != 0)
{
imgIndex = 1;
}
else if ((mibNode.NodeType & MibTreeNodeType.TableRow) != 0)
{
imgIndex = 2;
}
else if ((mibNode.NodeType & MibTreeNodeType.TableCell) != 0)
{
imgIndex = 3;
}
else if ((mibNode.NodeType & MibTreeNodeType.Scalar) != 0)
{
imgIndex = 4;
}
else if ((mibNode.NodeType & MibTreeNodeType.Container) != 0)
{
imgIndex = 0;
}
TreeNode newNode = new TreeNode(mibNode.Entity.Name, imgIndex, imgIndex);
newNode.Tag = mibNode;
parentNodes.Add(newNode);
foreach (MibTreeNode child in mibNode.ChildNodes)
{
AddNode(child, newNode.Nodes);
}
}
private void ShowTypeChain(ListView lv, ITypeAssignment type)
{
ShowTypeDetails(lv, this.listviewgroupTypeChain, type);
ITypeReferrer tr = type as ITypeReferrer;
if ((tr != null) && (tr.ReferredType != null))
{
lv.Items.Add(new ListViewItem(new string[] { " >>>", "" }, this.listviewgroupTypeChain));
ShowTypeChain(listviewNodeDetails, tr.ReferredType);
}
}
private void ShowTypeDetails(ListView lv, ListViewGroup lvg, ITypeAssignment type)
{
lv.Items.Add(new ListViewItem(new string[] { "Module", (type.Module != null) ? type.Module.Name : "" }, lvg));
lv.Items.Add(new ListViewItem(new string[] { "Type", type.GetType().Name }, lvg));
lv.Items.Add(new ListViewItem(new string[] { "Name", type.Name }, lvg));
}
#endregion
}
}

View File

@ -0,0 +1,298 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="imagelistTreeNodeImages.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<data name="imagelistTreeNodeImages.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABo
IQAAAk1TRnQBSQFMAgEBBgEAARABAAEQAQABEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA
AwABIAMAAQEBAAEgBgABIBIAAwQBBQMWAR4DIgEyAzEBTwJGAUQBhwMvAUsDHgErAxsBJgMYASIDFQEd
AxIBGAMNARIDCgENAwcBCQMEAQUDAQECAwQBBQMWAR4DIgEyAzEBTgJGAUQBhwMvAUsDHgErAxsBJgMb
ASYDIQExAyEBMAMdASoDGwEmAxgBIQMLAQ8DAQECgAADAgEDAwwBEAMrAUMCRgFEAYIC/wHwAf8CRgFE
AYIDKgFAAw8BFAMNAREDCwEPAwkBDAMHAQoDBQEHAwQBBQMCAQMDAAEBAwIBAwMLAQ8DKwFDAkYBRAGC
Av8B8AH/AkYBRAGCAyoBQAMOARMDEgEZAT0COwFpAVwBRQFCAawBZwE+AToBxAFaAUUBQwGqATwBOwE6
AWYDEAEWAwABAYQAAx4BKwJEAUIBewL/AfAB/wLpAdoD/wHxAf8CRAFCAXsDHgErJAADHgErAkQBQgF7
Av8B8AH/AukB2gP/AfEB/wJEAUIBewMeASsBLgItAUcBdwFHATwByQG7AVQBPQHxA+4B/wG7AVMBPAHx
AXcBRgE8AckBLgItAUeEAAMdASoCRAFCAXcC/wHwAf8B6wHdAbEB/wH3AcEBNwH/Ae0B3wGzA/8B8gH/
AkQBQgF3Ax0BKhwAAx0BKgJEAUIBdwL/AfAB/wLpAdoB/wLqAdwB/wLrAd4D/wHyAf8CRAFCAXcBZAFJ
AUIBrwG2AVkBQQHxAc0BVAEyAf8BvQF5AWIB/wHFAVABLgH/AbEBUQE1AfEBXAFIAUQBn4QAAkMBQQF2
Av8B8AH/AukB2gH/AecBqwEhAf8B5wGrASEB/wHnAasBIQH/AeoB2wGwA/8B9AH/AkMBQQF2Ax0BKhgA
AkMBQQF2Av8B8AH/AukB2gH/AuoB3AH/AusB3gH/AuwB3wH/Au0B4QP/AfQB/wGAAUQBMQHaAc4BcAFN
AfwBugFMASoB/wPSAf8BvgGLAXgB/wG7AVIBMgH8AW8BSQE/AbqEAAMdASkCQwFBAXQC/wHxAf8B5wHX
AasB/wHXAZYBDAH/AdcBlgEMAf8B1wGWAQwB/wHoAdgBrgP/AfUB/wJDAUEBdAMdASkUAAMdASkCQwFB
AXQC/wHxAf8C6wHeAf8C7AHfAf8C7QHhAf8C7gHjAf8C7wHlAf8BzQF5AV4B/wHOAXcBWAH3AbwBVAEy
Af8BtAFMASoB/wPmAf8BtwFlAUsB8AFdAUkBRAGdiAADHQEpAkIBQQFyAv8B8gH/AeUB1AGpAf8BzQGJ
AQAB/wHNAYkBAAH/Ac0BiQEAAf8B6AHXAa8D/wH3Af8CQgFBAXIDHAEoFAADHQEpAkIBQQFyAv8B8gH/
Au0B4QH/Au4B4wH/Au8B5QH/AvAB5wH/AeABuwGqAf8BzgFpAUgB/wHjAcsBwQH5BP8B3gHHAb0B9QF+
AU8BQgHEAi0BLAFFjAADHAEoAkEBQAFxAv8B9AH/AecB1gGsAf8B0QGOAQQB/wHRAY4BBAH/AdEBjgEE
Af8B7AHbAbMD/wH4Af8CQQFAAXEDHAEoFAADHAEoAkEBQAFxAv8B9AH/Au8B5QH/AvAB5wH/AvEB6QH/
AvMB6gH/AeQBvgGsAf8B1AGBAWIB/wGGAUoBNAHXAWYBTQFEAaoCLQEsAUWUAAMcAScCQQFAAW8C/wH1
Af8B7AHcAbMB/wHfAaEBFwH/Ad8BoQEXAf8B3wGhARcB/wHxAeIBuwP/AfoB/wJBAUABbwMcAScUAAMc
AScCQQFAAW8C/wH1Af8C8QHpAf8C8wHqAf8C9AHsAf8C9QHuAf8C9gHwA/8B+gH/AkEBQAFvAxwBJ5gA
AxwBJwJAAT8BbQL/AfcB/wHyAeMBuwH/AfABuAEuAf8B8AG4AS4B/wHwAbgBLgH/AvgB9AP/AfsB/wJA
AT8BbQMcAScUAAMcAScCQAE/AW0C/wH3Af8C9AHsAf8C9QHuAf8C9gHwAf8C9wHyAf8C+AH0A/8B+wH/
AkABPwFtAxwBJ5gAAxsBJgJAAT8BbAL/AfgB/wH3AeoBwwH/Af0ByQE/Af8B+QHsAccB/wL7AfcB/wL8
AfkD/wH8Af8CQAE/AWwDGwEmFAADGwEmAkABPwFsAv8B+AH/AvYB8AH/AvcB8gH/AvgB9AH/AvsB9wH/
AvwB+QP/AfwB/wJAAT8BbAMbASaYAAMbASYCPwE+AWsC/wH6Af8C+AH0Af8C+wH3Af8C3wHVAf8CyQG5
Af8C4AHWA/8B/gH/Aj8BPgFrGAADGwEmAj8BPgFrAv8B+gH/AvgB9AH/AvsB9wH/At8B1QH/AskBuQH/
AuAB1gP/Af4B/wI/AT4Ba5wAAxoBJQI/AT0BaQL/AfsB/wL8AfkB/wK8AawB/wQAArwBrAP/Af4B/wI/
AT0BaRwAAxoBJQI/AT0BaQL/AfsB/wL8AfkB/wK8AawB/wQAArwBrAP/Af4B/wI/AT0BaaAAAxoBJQI+
AT0BaAL/AfwB/wLLAcEB/wKgAZAB/wLLAcED/wH+Af8CPgE9AWggAAMaASUCPgE9AWgC/wH8Af8CywHB
Af8CoAGQAf8CywHBA/8B/gH/Aj4BPQFopAADGgElAj4BPQFnAv8B/gP/Af4D/wH+Bf8CPgE9AWckAAMa
ASUCPgE9AWcC/wH+A/8B/gP/Af4F/wI+AT0BZ6gAAxoBJAI+AT0BZgI+AT0BZgI+AT0BZgI+AT0BZgMx
AU0oAAMaASQCPgE9AWYCPgE9AWYCPgE9AWYCPgE9AWYDMQFNlAADIQEwAUABRgFIAXwBQwFOAVIBkgMF
AQccAAMHAQkDEAEWAxMBGgMTARoDEwEaAxMBGgMTARoDEwEaAxMBGgMTARoDEwEaAxMBGgMTARoDEwEa
AxABFgMHAQkDBwEJAxABFgMTARoDEwEaAxMBGgMTARoDEwEaAxMBGgMTARoDEwEaAxMBGgMTARoDEwEa
AxMBGgMQARYDBwEJAwcBCQMQARYDEwEaAxMBGgMTARoDEwEaAxMBGgMTARoDEwEaAxMBGgMTARoDEwEa
AxMBGgMTARoDEAEWAwcBCQwAAjIBMwFQAUMBUQFXAZkBRQFkAXQBwAFYAYsBogHgATwBWAFqAcEDEwEa
AwUBBxgAAjwBOwFpAkYBRAGHAkYBRAGHAkYBRAGHAkYBRAGHAkYBRAGHAkYBRAGHAkYBRAGHAkYBRAGH
AkYBRAGHAkYBRAGHAkYBRAGHAkYBRAGHAkYBRAGHAkYBRAGHAjwBOwFpAjkBNAFpAkABNwGHAkABNwGH
AkABNwGHAkABNwGHAkABNwGHAkABNwGHAkABNwGHAkABNwGHAkABNwGHAkABNwGHAkABNwGHAkABNwGH
AkABNwGHAkABNwGHAjkBNAFpAjwBOwFpAkYBRAGHAkYBRAGHAkYBRAGHAkYBRAGHAkYBRAGHAkYBRAGH
AkYBRAGHAkYBRAGHAkYBRAGHAkYBRAGHAkYBRAGHAkYBRAGHAkYBRAGHAkYBRAGHAjwBOwFpAw0BEQMa
ASQBRAFNAVEBmAE8AYkBrAHyAWcBrwHTAfoBggHLAewB/wGFAc4B7gH/ARUBWwGCAe8BOgFXAWYBxAE6
AVcBZgHEAT4BWgFqAb4BPgFaAWoBvgE+AVoBagG+AUQBTQFRAZgDGgEkAw0BEQJGAUMBgQL5AekB/wLz
AeIB/wLzAeIB/wLzAeIB/wLzAeIB/wLzAeIB/wLzAeIB/wLzAeIB/wLzAeIB/wLzAeIB/wLzAeIB/wLz
AeIB/wLzAeIB/wL5AekB/wJGAUMBgQJDAToBgQL5AekB/wLzAeIB/wLzAeIB/wLzAeIB/wLzAeIB/wLz
AeIB/wLzAeIB/wLzAeIB/wLzAeIB/wLzAeIB/wLzAeIB/wLzAeIB/wLzAeIB/wL5AekB/wJDAToBgQJG
AUMBgQL5AekB/wLzAeIB/wLzAeIB/wLzAeIB/wLzAeIB/wLzAeIB/wLzAeIB/wLzAeIB/wLzAeIB/wLz
AeIB/wLzAeIB/wLzAeIB/wLzAeIB/wL5AekB/wJGAUMBgQMHAQkDDQESAUIBWwFmAbIBiAHQAe8B/wF9
AcoB6QH/AX0BygHpAf8BhwHQAe8B/wEkAXsBqQH/AX0BvAHbAf8BfQG8AdsB/wGNAdEB8wH/AY0B0QHz
Af8BkAHUAfUB/wFCAVsBZgGyATACMQFNAwcBCQJEAUMBegL0AeQC/wHMAUIB/wH+AcsBQQH/AewB0gGG
Af8C2gHJAf8C2AHHAf8C1gHFAf8C1AHDAf8C0wHCAf8C0QHAAf8CzwG+Af8CzgG9Af8CzQG8Af8C9AHk
Af8CRAFDAXoCRgE+AXoC9AHkAv8BzAFDAf8B/gHLAUIB/wHsAdIBhgH/AtoByQH/AtgBxwH/AtYBxQH/
AtQBwwH/AtMBwgH/AtEBwAH/As8BvgH/As4BvQH/As0BvAH/AvQB5AH/AkYBPgF6AkQBQwF6AvQB5AL/
AcwBQgH/Af4BywFBAf8B7AHSAYYB/wLaAckB/wLYAccB/wHnAWEBPwH/AecBYQE/Af8B5wFhAT8B/wHn
AWEBPwH/As8BvgH/As4BvQH/As0BvAH/AvQB5AH/AkQBQwF6CAABQwFXAWABpAGKAdMB8AH/AYIBzQHr
Af8BggHNAesB/wGKAdMB8AH/ASQBfAGrAf8BegG5AdgB/wF6AbkB2AH/AYoBzgHwAf8BigHOAfAB/wGP
AdMB9AH/AfQBtgEsAf8BQwFXAWABpAQAAkQBQgF3AvUB5gL/AcwBQgL/Ae4BiAH/AewB0gGGAf8C9QHu
Af8C9QHuAf8C1gHFAf8C9QHuAf8C9QHuAf8C0QHAAf8C9QHuAf8C9QHuAf8CzQG8Af8C9QHmAf8CRAFC
AXcCRwE/AXcC9QHmAv8BzAFDAv8B7gGIAf8B7AHSAYYB/wL1Ae4B/wL1Ae4B/wLWAcUB/wL1Ae4B/wL1
Ae4B/wLRAcAB/wL1Ae4B/wL1Ae4B/wLNAbwB/wL1AeYB/wJHAT8BdwJEAUIBdwL1AeYC/wHMAUIC/wHu
AYgB/wHsAdIBhgH/AvUB7gH/AvUB7gH/AdkBWAE2Af8B8gHJAbgB/wHyAckBuAH/AdkBWAE2Af8C9QHu
Af8C9QHuAf8CzQG8Af8C9QHmAf8CRAFCAXcIAAFDAVUBXgGeAY4B1gHyAf8BhwHQAe0B/wGHAdAB7QH/
AY4B1gHyAf8BJgGCAa8B/wF7AboB2AH/AXsBugHYAf8BiwHPAfEB/wGLAc8B8QH/AZEB1QH1Af8B/gHJ
AT8B/wFDAVUBXgGeBAACQwFBAXUC9gHpAv8BzAFCAf8B/gHLAUEB/wHsAdIBhgH/AtoByQH/AtgBxwH/
AtwBzAH/AtQBwwH/AtMBwgH/AtgByAH/As8BvgH/As4BvQH/As0BvAH/AvYB6QH/AkMBQQF1AkcBPwF1
AvYB6QL/AcwBQwH/Af4BywFCAf8B7AHSAYYB/wLaAckB/wLYAccB/wLcAcwB/wLUAcMB/wLTAcIB/wLY
AcgB/wLPAb4B/wLOAb0B/wLNAbwB/wL2AekB/wJHAT8BdQJDAUEBdQL2AekC/wHMAUIB/wH+AcsBQQH/
AewB0gGGAf8C2gHJAf8C2AHHAf8ByAFPAS0B/wHeAbYBngH/Ad4BtQGdAf8ByAFPAS0B/wLPAb4B/wLO
Ab0B/wLNAbwB/wL2AekB/wJDAUEBdQgAAUQBVQFdAZsBkgHaAfQB/wGLAdQB8AH/AYsB1AHwAf8BkgHa
AfQB/wEpAYUBswH/AX0BvAHaAf8BfQG8AdoB/wGNAdEB8wH/AY0B0QHzAf8BkwHXAfYB/wLrAd0B/wFE
AVUBXQGbBAACQgFBAXMC9wHrAv8BzAFCAv8B7gGIAf8B7AHSAYYB/wL3AfEB/wL3AfEB/wLWAcUB/wL3
AfEB/wL3AfEB/wLRAcAB/wL3AfEB/wL3AfEB/wLNAbwB/wL3AesB/wJCAUEBcwJHAT8BcwL3AesC/wHM
AUMC/wHuAYgB/wHsAdIBhgH/AvcB8QH/AvcB8QH/AtYBxQH/AvcB8QH/AvcB8QH/AtEBwAH/AvcB8QH/
AvcB8QH/As0BvAH/AvcB6wH/AkcBPwFzAkIBQQFzAvcB6wL/AcwBQgL/Ae4BiAH/AewB0gGGAf8C9wHx
Af8C9wHxAf8BuAFHASUB/wHzAcsBuQH/AfMBywG5Af8BuAFHASUB/wL3AfEB/wL3AfEB/wLNAbwB/wL3
AesB/wJCAUEBcwgAAUQBUwFbApcB3gH2Af8BkAHYAfIB/wGQAdgB8gH/AZcB3gH2Af8BKwGJAbcB/wGA
Ab0B3AH/AYABvQHcAf8BjwHTAfUB/wGPAdMB9QH/AZUB2QH4Af8C9QHuAf8BRAFTAVsBlwQAAkIBQQFy
AvgB7gL/AcwBQgH/Af4BywFBAf8B7AHSAYYB/wLaAckB/wLYAccB/wLdAc4B/wLUAcMB/wLTAcIB/wLZ
AcoB/wLPAb4B/wLOAb0B/wLNAbwB/wL4Ae4B/wJCAUEBcgJIAUABcgL4Ae4B/wHsAYYBYwH/AeIBewFZ
Af8B1AFuAUwB/wHEAWABPgH/AbYBUgEwAf8BrQFHASUB/wGrAUMBIQH/AbEBRAEiAf8BvQFKASgB/wHM
AVIBMAH/AdsBWgE4Af8B6AFiAUAB/wL4Ae4B/wJIAUABcgJCAUEBcgL4Ae4C/wHMAUIB/wH+AcsBQQH/
AewB0gGGAf8C2gHJAf8C2AHHAf8BrQFCASAB/wHeAbYBngH/Ad4BtQGdAf8BrQFCASAB/wLPAb4B/wLO
Ab0B/wLNAbwB/wL4Ae4B/wJCAUEBcggAAUQBUwFaAZQBmwHhAfcB/wGUAdsB9AH/AZQB2wH0Af8BmwHh
AfcB/wEuAY0BvAH/AYEBvgHdAf8BgQG+Ad0B/wGQAdQB9gH/AZAB1AH2Af8BlwHbAfkB/wL+Af0B/wFE
AVMBWgGUBAACQQFAAXAC+QHxAv8BzAFCAv8B7gGIAf8B7AHSAYYB/wL5AfUB/wL5AfUB/wLWAcUB/wL5
AfUB/wL5AfUB/wLRAcAB/wL5AfUB/wL5AfUB/wLNAbwB/wL5AfEB/wJBAUABcAJHAUABcAL5AfEB/wHs
AYYBYwH/AfgBxQF5Af8B7QG1AXgB/wH1AcwBvAH/AfUBzAG8Af8B4AG3AZ8B/wH1AcwBvAH/AfUBzAG8
Af8B3QG0AZwB/wH1AcwBvAH/AfUBzAG8Af8B6AFiAUAB/wL5AfEB/wJHAUABcAJBAUABcAL5AfEC/wHM
AUIC/wHuAYgB/wHsAdIBhgH/AvkB9QH/AvkB9QH/AasBRAEiAf8B9QHMAbwB/wH1AcwBvAH/AasBRAEi
Af8C+QH1Af8C+QH1Af8CzQG8Af8C+QHxAf8CQQFAAXAIAAFEAVEBVwGQAZ4B5QH5Af8BmAHfAfYB/wGY
Ad8B9gH/AZ4B5QH5Af8BMAGQAcAB/wGDAcAB3wH/AYMBwAHfAf8BkgHWAfgB/wGSAdYB+AH/AZkB3QH6
Af8BRAFRAVcBkAMjATMEAAJBAUABbgL7AfQC/wHMAUIB/wH+AcsBQQH/AewB0gGGAf8C2gHJAf8C2AHH
Af8C3gHQAf8C1AHDAf8C0wHCAf8C2gHMAf8CzwG+Af8CzgG9Af8CzQG8Af8C+wH0Af8CQQFAAW4CRwFA
AW4C+wH0Af8B7AGGAWMB/wHiAXsBWQH/AdQBbgFMAf8BxAFgAT4B/wG2AVIBMAH/Aa0BRwElAf8BqwFD
ASEB/wGxAUQBIgH/Ab0BSgEoAf8BzAFSATAB/wHbAVoBOAH/AegBYgFAAf8C+wH0Af8CRwFAAW4CQQFA
AW4C+wH0Av8BzAFCAf8B/gHLAUEB/wHsAdIBhgH/AtoByQH/AtgBxwH/AbIBTAEqAf8B3gG2AZ4B/wHe
AbUBnQH/AbIBTAEqAf8CzwG+Af8CzgG9Af8CzQG8Af8C+wH0Af8CQQFAAW4IAAFDAU8BVQGNAaMB6AH7
Af8BnQHjAfkB/wGdAeMB+QH/AaMB6AH7Af8BMwGUAcUB/wGFAcIB4QH/AYUBwgHhAf8BlAHYAfoB/wGU
AdgB+gH/AZsB3wH8Af8BQwFPAVUBjQgAAkABPwFtAvwB9wL/AcwBQgL/Ae4BiAH/AewB0gGGAf8C/AH6
Af8C/AH6Af8C1gHFAf8C/AH6Af8C/AH6Af8C0QHAAf8C/AH6Af8C/AH6Af8CzQG8Af8C/AH3Af8CQAE/
AW0CRwFAAW0C/AH3Av8BzAFDAv8B7gGIAf8B7AHSAYYB/wL8AfoB/wL8AfoB/wLWAcUB/wL8AfoB/wL8
AfoB/wLRAcAB/wL8AfoB/wL8AfoB/wLNAbwB/wL8AfcB/wJHAUABbQJAAT8BbQL8AfcC/wHMAUIC/wHu
AYgB/wHsAdIBhgH/AvwB+gH/AvwB+gH/AcABWgE4Af8B9gHOAb8B/wH2Ac4BvwH/AcABWgE4Af8C/AH6
Af8C/AH6Af8CzQG8Af8C/AH3Af8CQAE/AW0IAAFDAU8BVAGKAaYB6wH8Af8BoQHmAfsB/wGhAeYB+wH/
AaYB6wH8Af8BOgGdAc8B/wGHAcQB4gH/AYcBxAHiAf8BlgHaAfwB/wGWAdoB/AH/AZ4B4gH9Af8BQwFP
AVQBiggAAj8BPgFrAv0B+QL/AcwBQgH/Af4BywFBAf8B9QHOAWIB/wHrAdIBhQH/AekB0AGDAf8B5wHO
AYEB/wHlAcwBgAH/AeQBywF8Af8B4gHJAXoB/wHgAccBeAH/Ad8BxgF3Af8B3gHFAXYB/wL9AfkB/wI/
AT4BawJHAUABawL9AfkC/wHMAUMB/wH+AcsBQgH/AfUBzgFjAf8B6wHSAYUB/wHpAdABgwH/AecBzgGB
Af8B5QHMAYAB/wHkAcsBfQH/AeIByQF7Af8B4AHHAXkB/wHfAcYBeAH/Ad4BxQF3Af8C/QH5Af8CRwFA
AWsCPwE+AWsC/QH5Av8BzAFCAf8B/gHLAUEB/wH1Ac4BYgH/AesB0gGFAf8B6QHQAYMB/wHRAWoBSAH/
AekBsQF0Af8B6AGwAXMB/wHRAWoBSAH/AeABxwF4Af8B3wHGAXcB/wHeAcUBdgH/Av0B+QH/Aj8BPgFr
CAABQgFNAVIBhwGpAe4B/QH/AaQB6QH8Af8BpAHpAfwB/wGqAe8B/QH/AUABoQHRAf8BkAHRAfEB/wGW
AdoB+wH/AZcB2wH9Af8BlwHbAf0B/wGfAeMB/gH/AUIBTQFSAYcIAAI/AT4BagL+AfwC/wHMAUIC/wHu
AYgB/wH9AcoBQAH/AfwB6wGFAf8B+wHqAYQB/wH4AcUBOwH/AfYB5QF9Af8B9AHjAXsB/wHzAcABNgH/
AfEB4AF4Af8B7wHeAXYB/wHvAbwBMgH/Av4B/AH/Aj8BPgFqAkcBQAFqAv4B/AL/AcwBQwL/Ae4BiAH/
Af0BygFBAf8B/AHrAYUB/wH7AeoBhAH/AfgBxQE8Af8B9gHlAX4B/wH0AeMBfAH/AfMBwAE3Af8B8QHg
AXkB/wHvAd4BdwH/Ae8BvAEzAf8C/gH8Af8CRwFAAWoCPwE+AWoC/gH8Av8BzAFCAv8B7gGIAf8B/QHK
AUAB/wH8AesBhQH/AfsB6gGEAf8B4QF5AVcB/wHzAcABcwH/AfIBvwFyAf8B4QF5AVcB/wHxAeABeAH/
Ae8B3gF2Af8B7wG8ATIB/wL+AfwB/wI/AT4BaggAAUMBTAFSAYUBrQHxAv8BqwHvAf4B/wGVAeIB+AH/
AWwByQHtAf8BRgGpAdkB/wGYAdwB/gH/AZgB3AH+Af8BmAHcAf4B/wGYAdwB/gH/AaEB5QL/AUMBTAFS
AYUIAAI+AT0BaAL/Af4C/wHMAUIB/wH+AcsBQQH/Af0BygFAAf8B/AHJAT8B/wH6AccBPQH/AfgBxQE7
Af8B9gHDAToB/wH1AcIBOAH/AfMBwAE2Af8B8QG+ATQB/wHwAb0BMwH/Ae8BvAEyA/8B/gH/Aj4BPQFo
AkcBQAFoAv8B/gL/AcwBQwH/Af4BywFCAf8B/QHKAUEB/wH8AckBQAH/AfoBxwE+Af8B+AHFATwB/wH2
AcMBOwH/AfUBwgE5Af8B8wHAATcB/wHxAb4BNQH/AfABvQE0Af8B7wG8ATMD/wH+Af8CRwFAAWgCPgE9
AWgC/wH+Av8BzAFCAf8B/gHLAUEB/wH9AcoBQAH/AfwByQE/Af8B+gHHAT0B/wHsAYYBYgH/AewBhgFi
Af8B7AGGAWIB/wHsAYYBYgH/AfEBvgE0Af8B8AG9ATMB/wHvAbwBMgP/Af4B/wI+AT0BaAgAAUMBTAFQ
AYMBiAHcAfQB/wFeAcAB6QH/AV0BvwHqAf8BgAHTAfQB/wGcAeMB/QH/AaIB5gL/AaIB5gL/AaIB5gL/
AaIB5gL/AaYB6gL/AUMBTAFQAYMIAAI+AT0BZzj/Aj4BPQFnAkcBQAFnOP8CRwFAAWcCPgE9AWc4/wI+
AT0BZwgAATkBOwE9AWEBQgFLAU8BgQFCAUsBTwGBAUIBSwFPAYEBQgFLAU8BgQFCAUsBTwGBAUIBSwFP
AYEBQgFLAU8BgQFCAUsBTwGBAUIBSwFPAYEBQgFLAU8BgQE5ATsBPQFhCAADMQFNAj4BPQFmAj4BPQFm
Aj4BPQFmAj4BPQFmAj4BPQFmAj4BPQFmAj4BPQFmAj4BPQFmAj4BPQFmAj4BPQFmAj4BPQFmAj4BPQFm
Aj4BPQFmAj4BPQFmAzEBTQI3ATQBTQJHAUABZgJHAUABZgJHAUABZgJHAUABZgJHAUABZgJHAUABZgJH
AUABZgJHAUABZgJHAUABZgJHAUABZgJHAUABZgJHAUABZgJHAUABZgJHAUABZgI3ATQBTQMxAU0CPgE9
AWYCPgE9AWYCPgE9AWYCPgE9AWYCPgE9AWYCPgE9AWYCPgE9AWYCPgE9AWYCPgE9AWYCPgE9AWYCPgE9
AWYCPgE9AWYCPgE9AWYCPgE9AWYDMQFNAUIBTQE+BwABPgMAASgDAAFAAwABIAMAAQEBAAEBBgABARYA
A/8RAAGAAf8BgAEBBQABfwEAAQEFAAE/AQABAQUAAR8BAAEBBAABgAEPAYABAQQAAcABBwHAAQMEAAHg
AQMB4AEDBAAB8AEBAfABAQQAAfgBAAH4BQAB/AEAAfwFAAH+AQgB/gEIBAAB/wEAAf8FAAH/AYAB/wGA
BAAB/wHAAf8BwAQAAfgBfwYAAeABPxYAAcABAQYAAcABAQYAAcABAQYAAcABAQYAAcABAQYAAcABAQYA
AcABAwYAAcABAwYAAcABAwYAAcABAwYAAcABAwYAAcABAwYACw==
</value>
</data>
<metadata name="toolStripMain.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>211, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="toolbuttonOpenMib.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAK6SURBVDhPjZNbSNNRHMfPU9DtwR71oZf5IgkF0YMEEYb2
EGgG5YNgGQmGSUoYimbel5KKmlM0u3jJSpv3ad7WnGkzb2yO4bByF3WuuTnnnLv47Zw/9YclQQc+/L//
P+d8/r/f+Z8/Ib/HjJDcmhaS3P+Bzf2zjr8qiki+QyuE6dNNbIzFw6F8DJ++AVh97c9GK9jcA4LJAlKI
rQ7sW9/DpauGZSoFg6JwfJSU+TE0XIXOgqCaAwJ5ASn2bb6F19TM4bO+w4z4HgwWC9YcDugpK3Y7umQy
FOZEDMRkZQX7SWS5pMRrboVn9RUHy1/aEqDSajGn0WDZbIZ6bQ0t/f1gIzojI8lPMvaIPPWsN2FP/5yD
ZdmLWLwUi/FhZASSqSlOUtXczBMcGZnFVzGUTSr2jI1wfq/lYHms4Tqkc3MYnZ2F0mDAqs3GV8LaiUhN
TeYFA5mkenelHg5tNQfLw3UxaOrpQZdUiu7xca5/Mc0do6PQb28jPDk5hRf0PiQi5zcR7JoKDpYHaqIg
VyohW1jg+lcZjVwlCzod1p1OXEhMvM8LOtNJvWOpEjZVKQfL/ZVX0NrXh165HP2Tk5hQqzGuUmFQocCm
y4XzCQlpvKA9jTTa1WWwzBdzsNxdfhmfFxcxQRct0Q3UmEzY2t2FdWcHdrcb5+LiHvCC1hTSbFOWwDyT
x8GyuDQCbRIJ3tBPp6CfU0pbcdA3M4mDCs7ExqYzwWHKibo7pNs6T4+yIofDSqtof3IJBtqzTq+Hx+uF
y+OBky5kkh2aT0VFZTNBAEWQFEFqhyvO2pclSe6f03nYnC1EW9FFGOnGGSi+/X14KW6fD3tUtkdzYFiY
0O801iWSaNFtUteWGST92nL1R/q1Q7ojAkHV0ZCQkuOhocV/c0wguHvgn2APyuPJ6dI4kpV/gzyjtycp
gf8g4Begs1B6Kbj3cQAAAABJRU5ErkJggg==
</value>
</data>
<metadata name="dialogOpenMib.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>337, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{86CC0B65-7985-4017-A252-0A7A18DCAEF3}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LwipMibViewer</RootNamespace>
<AssemblyName>MibViewer</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<WarningLevel>4</WarningLevel>
<Optimize>false</Optimize>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="FormMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormMain.Designer.cs">
<DependentUpon>FormMain.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="FormMain.resx">
<DependentUpon>FormMain.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SharpSnmpLib\SharpSnmpLib.Mib.csproj">
<Project>{CBE20411-5DB7-487D-825D-7694267BB6F5}</Project>
<Name>SharpSnmpLib.Mib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Martin Hentschel <info@cl-soft.de>
*
*/
using System;
using System.Windows.Forms;
namespace LwipMibViewer
{
static class Program
{
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormMain());
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("LwipMibViewer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LwipMibViewer")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("7ffbd1c1-1c64-45bb-b243-2400446c649d")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.225
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
namespace LwipMibViewer.Properties {
using System;
/// <summary>
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
/// </summary>
// Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
// -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
// mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LwipMibViewer.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
/// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.225
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
namespace LwipMibViewer.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

View File

@ -0,0 +1,131 @@
IANA-ADDRESS-FAMILY-NUMBERS-MIB DEFINITIONS ::= BEGIN
IMPORTS
MODULE-IDENTITY,
mib-2 FROM SNMPv2-SMI
TEXTUAL-CONVENTION FROM SNMPv2-TC;
ianaAddressFamilyNumbers MODULE-IDENTITY
LAST-UPDATED "200203140000Z" -- March 14, 2002
ORGANIZATION "IANA"
CONTACT-INFO
"Postal: Internet Assigned Numbers Authority
Internet Corporation for Assigned Names
and Numbers
4676 Admiralty Way, Suite 330
Marina del Rey, CA 90292-6601
USA
Tel: +1 310-823-9358
E-Mail: iana&iana.org"
DESCRIPTION
"The MIB module defines the AddressFamilyNumbers
textual convention."
-- revision history
REVISION "200203140000Z" -- March 14, 2002
DESCRIPTION "AddressFamilyNumbers assignment 22 to
fibreChannelWWPN. AddressFamilyNumbers
assignment 23 to fibreChannelWWNN.
AddressFamilyNumers assignment 24 to gwid."
REVISION "200009080000Z" -- September 8, 2000
DESCRIPTION "AddressFamilyNumbers assignment 19 to xtpOverIpv4.
AddressFamilyNumbers assignment 20 to xtpOverIpv6.
AddressFamilyNumbers assignment 21 to xtpNativeModeXTP."
REVISION "200003010000Z" -- March 1, 2000
DESCRIPTION "AddressFamilyNumbers assignment 17 to distinguishedName.
AddressFamilyNumbers assignment 18 to asNumber."
REVISION "200002040000Z" -- February 4, 2000
DESCRIPTION "AddressFamilyNumbers assignment 16 to dns."
REVISION "9908260000Z" -- August 26, 1999
DESCRIPTION "Initial version, published as RFC 2677."
::= { mib-2 72 }
AddressFamilyNumbers ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"The definition of this textual convention with the
addition of newly assigned values is published
periodically by the IANA, in either the Assigned
Numbers RFC, or some derivative of it specific to
Internet Network Management number assignments.
(The latest arrangements can be obtained by
contacting the IANA.)
The enumerations are described as:
other(0), -- none of the following
ipV4(1), -- IP Version 4
ipV6(2), -- IP Version 6
nsap(3), -- NSAP
hdlc(4), -- (8-bit multidrop)
bbn1822(5),
all802(6), -- (includes all 802 media
-- plus Ethernet 'canonical format')
e163(7),
e164(8), -- (SMDS, Frame Relay, ATM)
f69(9), -- (Telex)
x121(10), -- (X.25, Frame Relay)
ipx(11), -- IPX (Internet Protocol Exchange)
appleTalk(12), -- Apple Talk
decnetIV(13), -- DEC Net Phase IV
banyanVines(14), -- Banyan Vines
e164withNsap(15),
-- (E.164 with NSAP format subaddress)
dns(16), -- (Domain Name System)
distinguishedName(17), -- (Distinguished Name, per X.500)
asNumber(18), -- (16-bit quantity, per the AS number space)
xtpOverIpv4(19), -- XTP over IP version 4
xtpOverIpv6(20), -- XTP over IP version 6
xtpNativeModeXTP(21), -- XTP native mode XTP
fibreChannelWWPN(22), -- Fibre Channel World-Wide Port Name
fibreChannelWWNN(23), -- Fibre Channel World-Wide Node Name
gwid(24), -- Gateway Identifier
afi(25), -- AFI for L2VPN information
reserved(65535)
Requests for new values should be made to IANA via
email (iana&iana.org)."
SYNTAX INTEGER {
other(0),
ipV4(1),
ipV6(2),
nsap(3),
hdlc(4),
bbn1822(5),
all802(6),
e163(7),
e164(8),
f69(9),
x121(10),
ipx(11),
appleTalk(12),
decnetIV(13),
banyanVines(14),
e164withNsap(15),
dns(16),
distinguishedName(17), -- (Distinguished Name, per X.500)
asNumber(18), -- (16-bit quantity, per the AS number space)
xtpOverIpv4(19),
xtpOverIpv6(20),
xtpNativeModeXTP(21),
fibreChannelWWPN(22),
fibreChannelWWNN(23),
gwid(24),
afi(25),
reserved(65535)
}
END

View File

@ -0,0 +1,345 @@
IANA-CHARSET-MIB DEFINITIONS ::= BEGIN
-- http://www.iana.org/assignments/ianacharset-mib
IMPORTS
MODULE-IDENTITY,
mib-2
FROM SNMPv2-SMI -- [RFC2578]
TEXTUAL-CONVENTION
FROM SNMPv2-TC; -- [RFC2579]
ianaCharsetMIB MODULE-IDENTITY
LAST-UPDATED "200705140000Z"
ORGANIZATION "IANA"
CONTACT-INFO " Internet Assigned Numbers Authority
Postal: ICANN
4676 Admiralty Way, Suite 330
Marina del Rey, CA 90292
Tel: +1 310 823 9358
E-Mail: iana&iana.org"
DESCRIPTION "This MIB module defines the IANACharset
TEXTUAL-CONVENTION. The IANACharset TC is used to
specify the encoding of string objects defined in
a MIB.
Each version of this MIB will be released based on
the IANA Charset Registry file (see RFC 2978) at
http://www.iana.org/assignments/character-sets.
Note: The IANACharset TC, originally defined in
RFC 1759, was inaccurately named CodedCharSet.
Note: Best practice is to define new MIB string
objects with invariant UTF-8 (RFC 3629) syntax
using the SnmpAdminString TC (defined in RFC 3411)
in accordance with IETF Policy on Character Sets and
Languages (RFC 2277).
Copyright (C) The Internet Society (2004). The
initial version of this MIB module was published
in RFC 3808; for full legal notices see the RFC
itself. Supplementary information may be
available on
http://www.ietf.org/copyrights/ianamib.html."
-- revision history
REVISION "200705140000Z"
DESCRIPTION "Registration of new charset 2107."
REVISION "200612070000Z"
DESCRIPTION "Registration of new charsets numbered 118, 119,
and 2106."
REVISION "200406080000Z"
DESCRIPTION "Original version transferred from Printer MIB,
generated from the IANA maintained assignments
http://www.iana.org/assignments/character-sets."
::= { mib-2 106 }
IANACharset ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"Specifies an IANA registered 'charset' - coded character set
(CCS) plus optional character encoding scheme (CES) - terms
defined in 'IANA Charset Registration Procedures' (RFC 2978).
Objects of this syntax are used to specify the encoding for
string objects defined in one or more MIBs. For example, the
prtLocalizationCharacterSet, prtInterpreterDefaultCharSetIn, and
prtInterpreterDefaultCharSetOut objects defined in Printer MIB.
The current list of 'charset' names and enumerated values
is contained in the IANA Character Set Registry at:
http://www.iana.org/assignments/character-sets
Enum names are derived from the IANA Charset Registry 'Alias'
fields that begin with 'cs' (for character set).
Enum values are derived from the parallel 'MIBenum' fields."
SYNTAX INTEGER {
other(1), -- used if the designated
-- character set is not currently
-- registered by IANA
unknown(2), -- used as a default value
csASCII(3),
csISOLatin1(4),
csISOLatin2(5),
csISOLatin3(6),
csISOLatin4(7),
csISOLatinCyrillic(8),
csISOLatinArabic(9),
csISOLatinGreek(10),
csISOLatinHebrew(11),
csISOLatin5(12),
csISOLatin6(13),
csISOTextComm(14),
csHalfWidthKatakana(15),
csJISEncoding(16),
csShiftJIS(17),
csEUCPkdFmtJapanese(18),
csEUCFixWidJapanese(19),
csISO4UnitedKingdom(20),
csISO11SwedishForNames(21),
csISO15Italian(22),
csISO17Spanish(23),
csISO21German(24),
csISO60DanishNorwegian(25),
csISO69French(26),
csISO10646UTF1(27),
csISO646basic1983(28),
csINVARIANT(29),
csISO2IntlRefVersion(30),
csNATSSEFI(31),
csNATSSEFIADD(32),
csNATSDANO(33),
csNATSDANOADD(34),
csISO10Swedish(35),
csKSC56011987(36),
csISO2022KR(37),
csEUCKR(38),
csISO2022JP(39),
csISO2022JP2(40),
csISO13JISC6220jp(41),
csISO14JISC6220ro(42),
csISO16Portuguese(43),
csISO18Greek7Old(44),
csISO19LatinGreek(45),
csISO25French(46),
csISO27LatinGreek1(47),
csISO5427Cyrillic(48),
csISO42JISC62261978(49),
csISO47BSViewdata(50),
csISO49INIS(51),
csISO50INIS8(52),
csISO51INISCyrillic(53),
csISO54271981(54),
csISO5428Greek(55),
csISO57GB1988(56),
csISO58GB231280(57),
csISO61Norwegian2(58),
csISO70VideotexSupp1(59),
csISO84Portuguese2(60),
csISO85Spanish2(61),
csISO86Hungarian(62),
csISO87JISX0208(63),
csISO88Greek7(64),
csISO89ASMO449(65),
csISO90(66),
csISO91JISC62291984a(67),
csISO92JISC62991984b(68),
csISO93JIS62291984badd(69),
csISO94JIS62291984hand(70),
csISO95JIS62291984handadd(71),
csISO96JISC62291984kana(72),
csISO2033(73),
csISO99NAPLPS(74),
csISO102T617bit(75),
csISO103T618bit(76),
csISO111ECMACyrillic(77),
csa71(78),
csa72(79),
csISO123CSAZ24341985gr(80),
csISO88596E(81),
csISO88596I(82),
csISO128T101G2(83),
csISO88598E(84),
csISO88598I(85),
csISO139CSN369103(86),
csISO141JUSIB1002(87),
csISO143IECP271(88),
csISO146Serbian(89),
csISO147Macedonian(90),
csISO150(91),
csISO151Cuba(92),
csISO6937Add(93),
csISO153GOST1976874(94),
csISO8859Supp(95),
csISO10367Box(96),
csISO158Lap(97),
csISO159JISX02121990(98),
csISO646Danish(99),
csUSDK(100),
csDKUS(101),
csKSC5636(102),
csUnicode11UTF7(103),
csISO2022CN(104),
csISO2022CNEXT(105),
csUTF8(106),
csISO885913(109),
csISO885914(110),
csISO885915(111),
csISO885916(112),
csGBK(113),
csGB18030(114),
csOSDEBCDICDF0415(115),
csOSDEBCDICDF03IRV(116),
csOSDEBCDICDF041(117),
csISO115481(118),
csKZ1048(119),
csUnicode(1000),
csUCS4(1001),
csUnicodeASCII(1002),
csUnicodeLatin1(1003),
csUnicodeIBM1261(1005),
csUnicodeIBM1268(1006),
csUnicodeIBM1276(1007),
csUnicodeIBM1264(1008),
csUnicodeIBM1265(1009),
csUnicode11(1010),
csSCSU(1011),
csUTF7(1012),
csUTF16BE(1013),
csUTF16LE(1014),
csUTF16(1015),
csCESU8(1016),
csUTF32(1017),
csUTF32BE(1018),
csUTF32LE(1019),
csBOCU1(1020),
csWindows30Latin1(2000),
csWindows31Latin1(2001),
csWindows31Latin2(2002),
csWindows31Latin5(2003),
csHPRoman8(2004),
csAdobeStandardEncoding(2005),
csVenturaUS(2006),
csVenturaInternational(2007),
csDECMCS(2008),
csPC850Multilingual(2009),
csPCp852(2010),
csPC8CodePage437(2011),
csPC8DanishNorwegian(2012),
csPC862LatinHebrew(2013),
csPC8Turkish(2014),
csIBMSymbols(2015),
csIBMThai(2016),
csHPLegal(2017),
csHPPiFont(2018),
csHPMath8(2019),
csHPPSMath(2020),
csHPDesktop(2021),
csVenturaMath(2022),
csMicrosoftPublishing(2023),
csWindows31J(2024),
csGB2312(2025),
csBig5(2026),
csMacintosh(2027),
csIBM037(2028),
csIBM038(2029),
csIBM273(2030),
csIBM274(2031),
csIBM275(2032),
csIBM277(2033),
csIBM278(2034),
csIBM280(2035),
csIBM281(2036),
csIBM284(2037),
csIBM285(2038),
csIBM290(2039),
csIBM297(2040),
csIBM420(2041),
csIBM423(2042),
csIBM424(2043),
csIBM500(2044),
csIBM851(2045),
csIBM855(2046),
csIBM857(2047),
csIBM860(2048),
csIBM861(2049),
csIBM863(2050),
csIBM864(2051),
csIBM865(2052),
csIBM868(2053),
csIBM869(2054),
csIBM870(2055),
csIBM871(2056),
csIBM880(2057),
csIBM891(2058),
csIBM903(2059),
csIBBM904(2060),
csIBM905(2061),
csIBM918(2062),
csIBM1026(2063),
csIBMEBCDICATDE(2064),
csEBCDICATDEA(2065),
csEBCDICCAFR(2066),
csEBCDICDKNO(2067),
csEBCDICDKNOA(2068),
csEBCDICFISE(2069),
csEBCDICFISEA(2070),
csEBCDICFR(2071),
csEBCDICIT(2072),
csEBCDICPT(2073),
csEBCDICES(2074),
csEBCDICESA(2075),
csEBCDICESS(2076),
csEBCDICUK(2077),
csEBCDICUS(2078),
csUnknown8BiT(2079),
csMnemonic(2080),
csMnem(2081),
csVISCII(2082),
csVIQR(2083),
csKOI8R(2084),
csHZGB2312(2085),
csIBM866(2086),
csPC775Baltic(2087),
csKOI8U(2088),
csIBM00858(2089),
csIBM00924(2090),
csIBM01140(2091),
csIBM01141(2092),
csIBM01142(2093),
csIBM01143(2094),
csIBM01144(2095),
csIBM01145(2096),
csIBM01146(2097),
csIBM01147(2098),
csIBM01148(2099),
csIBM01149(2100),
csBig5HKSCS(2101),
csIBM1047(2102),
csPTCP154(2103),
csAmiga1251(2104),
csKOI7switched(2105),
csBRF(2106),
csTSCII(2107),
cswindows1250(2250),
cswindows1251(2251),
cswindows1252(2252),
cswindows1253(2253),
cswindows1254(2254),
cswindows1255(2255),
cswindows1256(2256),
cswindows1257(2257),
cswindows1258(2258),
csTIS620(2259),
reserved(3000)
}
END

View File

@ -0,0 +1,333 @@
IANA-ITU-ALARM-TC-MIB DEFINITIONS ::= BEGIN
IMPORTS
MODULE-IDENTITY, mib-2 FROM SNMPv2-SMI
TEXTUAL-CONVENTION FROM SNMPv2-TC;
ianaItuAlarmNumbers MODULE-IDENTITY
LAST-UPDATED "200409090000Z" -- September 09, 2004
ORGANIZATION "IANA"
CONTACT-INFO
"Postal: Internet Assigned Numbers Authority
Internet Corporation for Assigned Names
and Numbers
4676 Admiralty Way, Suite 330
Marina del Rey, CA 90292-6601
USA
Tel: +1 310-823-9358
E-Mail: iana&iana.org"
DESCRIPTION
"The MIB module defines the ITU Alarm
textual convention for objects expected to require
regular extension.
Copyright (C) The Internet Society (2004). The
initial version of this MIB module was published
in RFC 3877. For full legal notices see the RFC
itself. Supplementary information may be available on:
http://www.ietf.org/copyrights/ianamib.html"
REVISION "200409090000Z"
DESCRIPTION
"Initial version, published as RFC 3877."
::= { mib-2 119 }
IANAItuProbableCause ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"ITU-T probable cause values. Duplicate values defined in
X.733 are appended with X733 to ensure syntactic uniqueness.
Probable cause value 0 is reserved for special purposes.
The Internet Assigned Number Authority (IANA) is responsible
for the assignment of the enumerations in this TC.
IANAItuProbableCause value of 0 is reserved for special
purposes and MUST NOT be assigned.
Values of IANAItuProbableCause in the range 1 to 1023 are
reserved for causes that correspond to ITU-T probable cause.
All other requests for new causes will be handled on a
first-come, first served basis and will be assigned
enumeration values starting with 1025.
Request should come in the form of well-formed
SMI [RFC2578] for enumeration names that are unique and
sufficiently descriptive.
While some effort will be taken to ensure that new probable
causes do not conceptually duplicate existing probable
causes it is acknowledged that the existence of conceptual
duplicates in the starting probable cause list is an known
industry reality.
To aid IANA in the administration of probable cause names
and values, the OPS Area Director will appoint one or more
experts to help review requests.
See http://www.iana.org"
REFERENCE
"ITU Recommendation M.3100, 'Generic Network Information
Model', 1995
ITU Recommendation X.733, 'Information Technology - Open
Systems Interconnection - System Management: Alarm
Reporting Function', 1992
ITU Recommendation X.736, 'Information Technology - Open
Systems Interconnection - System Management: Security
Alarm Reporting Function', 1992"
SYNTAX INTEGER
{
-- The following probable causes were defined in M.3100
aIS (1),
callSetUpFailure (2),
degradedSignal (3),
farEndReceiverFailure (4),
framingError (5),
lossOfFrame (6),
lossOfPointer (7),
lossOfSignal (8),
payloadTypeMismatch (9),
transmissionError (10),
remoteAlarmInterface (11),
excessiveBER (12),
pathTraceMismatch (13),
unavailable (14),
signalLabelMismatch (15),
lossOfMultiFrame (16),
receiveFailure (17),
transmitFailure (18),
modulationFailure (19),
demodulationFailure (20),
broadcastChannelFailure (21),
connectionEstablishmentError (22),
invalidMessageReceived (23),
localNodeTransmissionError (24),
remoteNodeTransmissionError (25),
routingFailure (26),
--Values 27-50 are reserved for communications alarm related
--probable causes
-- The following are used with equipment alarm.
backplaneFailure (51),
dataSetProblem (52),
equipmentIdentifierDuplication (53),
externalIFDeviceProblem (54),
lineCardProblem (55),
multiplexerProblem (56),
nEIdentifierDuplication (57),
powerProblem (58),
processorProblem (59),
protectionPathFailure (60),
receiverFailure (61),
replaceableUnitMissing (62),
replaceableUnitTypeMismatch (63),
synchronizationSourceMismatch (64),
terminalProblem (65),
timingProblem (66),
transmitterFailure (67),
trunkCardProblem (68),
replaceableUnitProblem (69),
realTimeClockFailure (70),
--An equipment alarm to be issued if the system detects that the
--real time clock has failed
antennaFailure (71),
batteryChargingFailure (72),
diskFailure (73),
frequencyHoppingFailure (74),
iODeviceError (75),
lossOfSynchronisation (76),
lossOfRedundancy (77),
powerSupplyFailure (78),
signalQualityEvaluationFailure (79),
tranceiverFailure (80),
protectionMechanismFailure (81),
protectingResourceFailure (82),
-- Values 83-100 are reserved for equipment alarm related probable
-- causes
-- The following are used with environmental alarm.
airCompressorFailure (101),
airConditioningFailure (102),
airDryerFailure (103),
batteryDischarging (104),
batteryFailure (105),
commercialPowerFailure (106),
coolingFanFailure (107),
engineFailure (108),
fireDetectorFailure (109),
fuseFailure (110),
generatorFailure (111),
lowBatteryThreshold (112),
pumpFailure (113),
rectifierFailure (114),
rectifierHighVoltage (115),
rectifierLowFVoltage (116),
ventilationsSystemFailure (117),
enclosureDoorOpen (118),
explosiveGas (119),
fire (120),
flood (121),
highHumidity (122),
highTemperature (123),
highWind (124),
iceBuildUp (125),
intrusionDetection (126),
lowFuel (127),
lowHumidity (128),
lowCablePressure (129),
lowTemperatue (130),
lowWater (131),
smoke (132),
toxicGas (133),
coolingSystemFailure (134),
externalEquipmentFailure (135),
externalPointFailure (136),
-- Values 137-150 are reserved for environmental alarm related
-- probable causes
-- The following are used with Processing error alarm.
storageCapacityProblem (151),
memoryMismatch (152),
corruptData (153),
outOfCPUCycles (154),
sfwrEnvironmentProblem (155),
sfwrDownloadFailure (156),
lossOfRealTimel (157),
--A processing error alarm to be issued after the system has
--reinitialised. This will indicate
--to the management systems that the view they have of the managed
--system may no longer
--be valid. Usage example: The managed
--system issues this alarm after a reinitialization with severity
--warning to inform the
--management system about the event. No clearing notification will
--be sent.
applicationSubsystemFailure (158),
configurationOrCustomisationError (159),
databaseInconsistency (160),
fileError (161),
outOfMemory (162),
softwareError (163),
timeoutExpired (164),
underlayingResourceUnavailable (165),
versionMismatch (166),
--Values 168-200 are reserved for processing error alarm related
-- probable causes.
bandwidthReduced (201),
congestion (202),
excessiveErrorRate (203),
excessiveResponseTime (204),
excessiveRetransmissionRate (205),
reducedLoggingCapability (206),
systemResourcesOverload (207 ),
-- The following were defined X.733
adapterError (500),
applicationSubsystemFailture (501),
bandwidthReducedX733 (502),
callEstablishmentError (503),
communicationsProtocolError (504),
communicationsSubsystemFailure (505),
configurationOrCustomizationError (506),
congestionX733 (507),
coruptData (508),
cpuCyclesLimitExceeded (509),
dataSetOrModemError (510),
degradedSignalX733 (511),
dteDceInterfaceError (512),
enclosureDoorOpenX733 (513),
equipmentMalfunction (514),
excessiveVibration (515),
fileErrorX733 (516),
fireDetected (517),
framingErrorX733 (518),
heatingVentCoolingSystemProblem (519),
humidityUnacceptable (520),
inputOutputDeviceError (521),
inputDeviceError (522),
lanError (523),
leakDetected (524),
localNodeTransmissionErrorX733 (525),
lossOfFrameX733 (526),
lossOfSignalX733 (527),
materialSupplyExhausted (528),
multiplexerProblemX733 (529),
outOfMemoryX733 (530),
ouputDeviceError (531),
performanceDegraded (532),
powerProblems (533),
pressureUnacceptable (534),
processorProblems (535),
pumpFailureX733 (536),
queueSizeExceeded (537),
receiveFailureX733 (538),
receiverFailureX733 (539),
remoteNodeTransmissionErrorX733 (540),
resourceAtOrNearingCapacity (541),
responseTimeExecessive (542),
retransmissionRateExcessive (543),
softwareErrorX733 (544),
softwareProgramAbnormallyTerminated (545),
softwareProgramError (546),
storageCapacityProblemX733 (547),
temperatureUnacceptable (548),
thresholdCrossed (549),
timingProblemX733 (550),
toxicLeakDetected (551),
transmitFailureX733 (552),
transmiterFailure (553),
underlyingResourceUnavailable (554),
versionMismatchX733 (555),
-- The following are defined in X.736
authenticationFailure (600),
breachOfConfidentiality (601),
cableTamper (602),
delayedInformation (603),
denialOfService (604),
duplicateInformation (605),
informationMissing (606),
informationModificationDetected (607),
informationOutOfSequence (608),
keyExpired (609),
nonRepudiationFailure (610),
outOfHoursActivity (611),
outOfService (612),
proceduralError (613),
unauthorizedAccessAttempt (614),
unexpectedInformation (615),
other (1024)
}
IANAItuEventType ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"The ITU event Type values.
The Internet Assigned Number Authority (IANA) is
responsible for the assignment of the enumerations
in this TC.
Request should come in the form of well-formed
SMI [RFC2578] for enumeration names that are unique
and sufficiently descriptive.
See http://www.iana.org "
REFERENCE
"ITU Recommendation X.736, 'Information Technology - Open
Systems Interconnection - System Management: Security
Alarm Reporting Function', 1992"
SYNTAX INTEGER
{
other (1),
communicationsAlarm (2),
qualityOfServiceAlarm (3),
processingErrorAlarm (4),
equipmentAlarm (5),
environmentalAlarm (6),
integrityViolation (7),
operationalViolation (8),
physicalViolation (9),
securityServiceOrMechanismViolation (10),
timeDomainViolation (11)
}
END

View File

@ -0,0 +1,127 @@
IANA-LANGUAGE-MIB DEFINITIONS ::= BEGIN
IMPORTS
MODULE-IDENTITY, OBJECT-IDENTITY, mib-2
FROM SNMPv2-SMI;
ianaLanguages MODULE-IDENTITY
LAST-UPDATED "200005100000Z" -- May 10, 2000
ORGANIZATION "IANA"
CONTACT-INFO
"Internet Assigned Numbers Authority (IANA)
Postal: ICANN
4676 Admiralty Way, Suite 330
Marina del Rey, CA 90292
Tel: +1 310 823 9358 x20
E-Mail: iana&iana.org"
DESCRIPTION
"The MIB module registers object identifier values for
well-known programming and scripting languages. Every
language registration MUST describe the format used
when transferring scripts written in this language.
Any additions or changes to the contents of this MIB
module require Designated Expert Review as defined in
the Guidelines for Writing IANA Considerations Section
document. The Designated Expert will be selected by
the IESG Area Director of the OPS Area.
Note, this module does not have to register all possible
languages since languages are identified by object
identifier values. It is therefore possible to registered
languages in private OID trees. The references given below are not
normative with regard to the language version. Other
references might be better suited to describe some newer
versions of this language. The references are only
provided as `a pointer into the right direction'."
-- Revision log, in reverse chronological order
REVISION "200005100000Z" -- May 10, 2000
DESCRIPTION "Import mib-2 instead of experimental, so that
this module compiles"
REVISION "199909090900Z" -- September 9, 1999
DESCRIPTION "Initial version as published at time of
publication of RFC 2591."
::= { mib-2 73 }
ianaLangJavaByteCode OBJECT-IDENTITY
STATUS current
DESCRIPTION
"Java byte code to be processed by a Java virtual machine.
A script written in Java byte code is transferred by using
the Java archive file format (JAR)."
REFERENCE
"The Java Virtual Machine Specification.
ISBN 0-201-63452-X"
::= { ianaLanguages 1 }
ianaLangTcl OBJECT-IDENTITY
STATUS current
DESCRIPTION
"The Tool Command Language (Tcl). A script written in the
Tcl language is transferred in Tcl source code format."
REFERENCE
"Tcl and the Tk Toolkit.
ISBN 0-201-63337-X"
::= { ianaLanguages 2 }
ianaLangPerl OBJECT-IDENTITY
STATUS current
DESCRIPTION
"The Perl language. A script written in the Perl language
is transferred in Perl source code format."
REFERENCE
"Programming Perl.
ISBN 1-56592-149-6"
::= { ianaLanguages 3 }
ianaLangScheme OBJECT-IDENTITY
STATUS current
DESCRIPTION
"The Scheme language. A script written in the Scheme
language is transferred in Scheme source code format."
REFERENCE
"The Revised^4 Report on the Algorithmic Language Scheme.
MIT Press"
::= { ianaLanguages 4 }
ianaLangSRSL OBJECT-IDENTITY
STATUS current
DESCRIPTION
"The SNMP Script Language defined by SNMP Research. A
script written in the SNMP Script Language is transferred
in the SNMP Script Language source code format."
::= { ianaLanguages 5 }
ianaLangPSL OBJECT-IDENTITY
STATUS current
DESCRIPTION
"The Patrol Script Language defined by BMC Software. A script
written in the Patrol Script Language is transferred in the
Patrol Script Language source code format."
REFERENCE
"PATROL Script Language Reference Manual, Version 3.0,
November 30, 1995. BMC Software, Inc. 2101 City West Blvd.,
Houston, Texas 77042."
::= { ianaLanguages 6 }
ianaLangSMSL OBJECT-IDENTITY
STATUS current
DESCRIPTION
"The Systems Management Scripting Language. A script written
in the SMSL language is transferred in the SMSL source code
format."
REFERENCE
"ISO/ITU Command Sequencer.
ISO 10164-21 or ITU X.753"
::= { ianaLanguages 7 }
END

View File

@ -0,0 +1,67 @@
IANA-MALLOC-MIB DEFINITIONS ::= BEGIN
IMPORTS
MODULE-IDENTITY, mib-2 FROM SNMPv2-SMI
TEXTUAL-CONVENTION FROM SNMPv2-TC;
ianaMallocMIB MODULE-IDENTITY
LAST-UPDATED "200301271200Z" -- January 27, 2003
ORGANIZATION "IANA"
CONTACT-INFO
" Internet Assigned Numbers Authority
Internet Corporation for Assigned Names and Numbers
4676 Admiralty Way, Suite 330
Marina del Rey, CA 90292-6601
Phone: +1 310 823 9358
EMail: iana&iana.org"
DESCRIPTION
"This MIB module defines the IANAscopeSource and
IANAmallocRangeSource textual conventions for use in MIBs
which need to identify ways of learning multicast scope and
range information.
Any additions or changes to the contents of this MIB module
require either publication of an RFC, or Designated Expert
Review as defined in the Guidelines for Writing IANA
Considerations Section document. The Designated Expert will
be selected by the IESG Area Director(s) of the Transport
Area."
-- revision log
REVISION "200301271200Z" -- January 27, 2003
DESCRIPTION
"Initial version."
::= { mib-2 102 }
IANAscopeSource ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"The source of multicast scope information."
SYNTAX INTEGER {
other(1), -- none of the following
manual(2), -- statically configured
local(3), -- automatically added by the system,
-- such as a Source-Specific Multicast
-- scope
mzap(4), -- MZAP
madcap(5) -- MADCAP
}
IANAmallocRangeSource ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"The source of multicast address allocation range
information."
SYNTAX INTEGER {
other(1), -- none of the following
manual(2), -- statically configured
local(3) -- automatically added by the system,
-- such as a Source-Specific Multicast
-- range
}
END

View File

@ -0,0 +1,770 @@
IANA-MAU-MIB DEFINITIONS ::= BEGIN
IMPORTS
MODULE-IDENTITY, OBJECT-IDENTITY, mib-2
FROM SNMPv2-SMI
TEXTUAL-CONVENTION
FROM SNMPv2-TC
;
ianaMauMIB MODULE-IDENTITY
LAST-UPDATED "200704210000Z" -- April 21, 2007
ORGANIZATION "IANA"
CONTACT-INFO " Internet Assigned Numbers Authority
Postal: ICANN
4676 Admiralty Way, Suite 330
Marina del Rey, CA 90292
Tel: +1-310-823-9358
EMail: iana&iana.org"
DESCRIPTION
"This MIB module defines dot3MauType OBJECT-IDENTITIES and
IANAifMauListBits, IANAifMauMediaAvailable,
IANAifMauAutoNegCapBits, and IANAifJackType
TEXTUAL-CONVENTIONs, specifying enumerated values of the
ifMauTypeListBits, ifMauMediaAvailable / rpMauMediaAvailable,
ifMauAutoNegCapabilityBits / ifMauAutoNegCapAdvertisedBits /
ifMauAutoNegCapReceivedBits and ifJackType / rpJackType objects
respectively, defined in the MAU-MIB.
It is intended that each new MAU type, Media Availability
state, Auto Negotiation capability and/or Jack type defined by
the IEEE 802.3 working group and approved for publication in a
revision of IEEE Std 802.3 will be added to this MIB module,
provided that it is suitable for being managed by the base
objects in the MAU-MIB. An Expert Review, as defined in
RFC 2434 [RFC2434], is REQUIRED for such additions.
The following reference is used throughout this MIB module:
[IEEE802.3] refers to:
IEEE Std 802.3, 2005 Edition: 'IEEE Standard for
Information technology - Telecommunications and information
exchange between systems - Local and metropolitan area
networks - Specific requirements -
Part 3: Carrier sense multiple access with collision
detection (CSMA/CD) access method and physical layer
specifications'.
This reference should be updated as appropriate when new
MAU types, Media Availability states, Auto Negotiation
capabilities, and/or Jack types are added to this MIB module.
Copyright (C) The IETF Trust (2007).
The initial version of this MIB module was published in
RFC 4836; for full legal notices see the RFC itself.
Supplementary information may be available at:
http://www.ietf.org/copyrights/ianamib.html"
REVISION "200704210000Z" -- April 21, 2007
DESCRIPTION "Initial version of this MIB as published in
RFC 4836."
::= { mib-2 154 }
-- Textual Conventions
IANAifMauTypeListBits ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"This data type is used as the syntax of the ifMauTypeListBits
object in the (updated) definition of MAU-MIB's ifMauTable.
The most recent version of this textual convention is available
in the online version of this MIB module on the IANA web site.
Requests for new values should be made to IANA via email
(iana&iana.org).
Note that changes in this textual convention SHALL be
synchronized with relevant changes in the dot3MauType
OBJECT-IDENTITIES."
REFERENCE
"[IEEE802.3], Section 30.5.1.1.2"
SYNTAX BITS {
bOther(0), -- other or unknown
bAUI(1), -- AUI
b10base5(2), -- 10BASE-5
bFoirl(3), -- FOIRL
b10base2(4), -- 10BASE-2
b10baseT(5), -- 10BASE-T duplex mode unknown
b10baseFP(6), -- 10BASE-FP
b10baseFB(7), -- 10BASE-FB
b10baseFL(8), -- 10BASE-FL duplex mode unknown
b10broad36(9), -- 10BROAD36
b10baseTHD(10), -- 10BASE-T half duplex mode
b10baseTFD(11), -- 10BASE-T full duplex mode
b10baseFLHD(12), -- 10BASE-FL half duplex mode
b10baseFLFD(13), -- 10BASE-FL full duplex mode
b100baseT4(14), -- 100BASE-T4
b100baseTXHD(15), -- 100BASE-TX half duplex mode
b100baseTXFD(16), -- 100BASE-TX full duplex mode
b100baseFXHD(17), -- 100BASE-FX half duplex mode
b100baseFXFD(18), -- 100BASE-FX full duplex mode
b100baseT2HD(19), -- 100BASE-T2 half duplex mode
b100baseT2FD(20), -- 100BASE-T2 full duplex mode
b1000baseXHD(21), -- 1000BASE-X half duplex mode
b1000baseXFD(22), -- 1000BASE-X full duplex mode
b1000baseLXHD(23), -- 1000BASE-LX half duplex mode
b1000baseLXFD(24), -- 1000BASE-LX full duplex mode
b1000baseSXHD(25), -- 1000BASE-SX half duplex mode
b1000baseSXFD(26), -- 1000BASE-SX full duplex mode
b1000baseCXHD(27), -- 1000BASE-CX half duplex mode
b1000baseCXFD(28), -- 1000BASE-CX full duplex mode
b1000baseTHD(29), -- 1000BASE-T half duplex mode
b1000baseTFD(30), -- 1000BASE-T full duplex mode
b10GbaseX(31), -- 10GBASE-X
b10GbaseLX4(32), -- 10GBASE-LX4
b10GbaseR(33), -- 10GBASE-R
b10GbaseER(34), -- 10GBASE-ER
b10GbaseLR(35), -- 10GBASE-LR
b10GbaseSR(36), -- 10GBASE-SR
b10GbaseW(37), -- 10GBASE-W
b10GbaseEW(38), -- 10GBASE-EW
b10GbaseLW(39), -- 10GBASE-LW
b10GbaseSW(40), -- 10GBASE-SW
-- new since RFC 3636
b10GbaseCX4(41), -- 10GBASE-CX4
b2BaseTL(42), -- 2BASE-TL
b10PassTS(43), -- 10PASS-TS
b100BaseBX10D(44), -- 100BASE-BX10D
b100BaseBX10U(45), -- 100BASE-BX10U
b100BaseLX10(46), -- 100BASE-LX10
b1000BaseBX10D(47), -- 1000BASE-BX10D
b1000BaseBX10U(48), -- 1000BASE-BX10U
b1000BaseLX10(49), -- 1000BASE-LX10
b1000BasePX10D(50), -- 1000BASE-PX10D
b1000BasePX10U(51), -- 1000BASE-PX10U
b1000BasePX20D(52), -- 1000BASE-PX20D
b1000BasePX20U(53) -- 1000BASE-PX20U
}
IANAifMauMediaAvailable ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"This data type is used as the syntax of the
ifMauMediaAvailable and rpMauMediaAvailable objects in the
(updated) definition of MAU-MIB's ifMauTable and rpMauTable
respectively.
Possible values are:
other(1) - undefined (not listed below)
unknown(2) - MAU's true state is unknown; e.g.,
during initialization
available(3) - link, light, or loopback is normal
notAvailable(4) - link loss, low light, or no loopback
remoteFault(5) - a fault has been detected at the
remote end of the link. This value
applies to 10BASE-FB, 100BASE-T4 Far
End Fault Indication and non-specified
remote faults from a system running
auto-negotiation
invalidSignal(6) - invalid signal has been received from
the other end of the link, 10BASE-FB
only
remoteJabber(7) - remote fault, due to jabber
remoteLinkLoss(8) - remote fault, due to link loss
remoteTest(9) - remote fault, due to test
offline(10) - offline, Clause 37 Auto-Negotiation
only
autoNegError(11) - Auto-Negotiation Error, Clause 37
Auto-Negotiation only
pmdLinkFault(12) - PMA/PMD receive link fault. In case
of PAF (2BASE-TL / 10PASS-TS PHYs),
all PMEs in the aggregation group have
detected a link fault
wisFrameLoss(13) - WIS loss of frame, 10GBASE-W only
wisSignalLoss(14) - WIS loss of signal, 10GBASE-W only
pcsLinkFault(15) - PCS receive link fault
excessiveBER(16) - PCS Bit Error Ratio monitor
reporting excessive error ratio
dxsLinkFault(17) - DTE XGXS receive link fault, XAUI only
pxsLinkFault(18) - PHY XGXS receive link fault, XAUI only
availableReduced(19) - link normal, reduced bandwidth,
2BASE-TL / 10PASS-TS only
ready(20) - at least one PME in the aggregation
group is detecting handshake tones,
2BASE-TL / 10PASS-TS only
If the MAU is a 10M b/s link or fiber type (FOIRL, 10BASE-T,
10BASE-F), then this is equivalent to the link test fail
state/low light function. For an AUI, 10BASE2, 10BASE5, or
10BROAD36 MAU, this indicates whether loopback is detected on
the DI circuit. The value of this attribute persists between
packets for MAU types AUI, 10BASE5, 10BASE2, 10BROAD36, and
10BASEFP.
At power-up or following a reset, the Media Available state
will be unknown(2) for AUI, 10BASE5, 10BASE2, 10BROAD36, and
10BASE-FP MAUs. For these MAUs loopback will be tested on each
transmission during which no collision is detected.
If DI is receiving input when DO returns to IDL after a
transmission and there has been no collision during the
transmission, then loopback will be detected. The Media
Available state will only change during noncollided
transmissions for AUI, 10BASE2, 10BASE5, 10BROAD36, and
10BASE-FP MAUs.
For 100BASE-T2, 100BASE-T4, 100BASE-TX, 100BASE-FX,
100BASE-LX10, and 100BASE-BX10 PHYs the enumerations match the
states within the link integrity state diagram.
Any MAU that implements management of [IEEE802.3] Clause
28 Auto-Negotiation, will map remote fault indication to
remoteFault(5).
Any MAU that implements management of Clause 37
Auto-Negotiation, will map the received RF1 and RF2 bits as
follows: Offline maps to offline(10), Link_Failure maps to
remoteFault(5), and Auto-Negotiation Error maps to
autoNegError(11).
The value remoteFault(5) applies to 10BASE-FB remote
fault indication, the 100BASE-X far-end fault indication, and
nonspecified remote faults from a system running Clause 28
Auto-Negotiation.
The value remoteJabber(7), remoteLink loss(8), or remoteTest(9)
SHOULD be used instead of remoteFault(5) where the reason for
remote fault is identified in the remote signaling protocol.
Where a Clause 22 MII or Clause 35 GMII is present, a logic
one in the remote fault bit maps to the value remoteFault(5),
a logic zero in the link status bit maps to the enumeration
notAvailable(4). The value notAvailable(4) takes precedence
over remoteFault(5).
For 2BASE-TL and 10PASS-TS PHYs, the value unknown(2) maps to
the condition where the PHY (PCS with connected PMEs) is
initializing, the value ready(20) maps to the condition where
the interface is down and at least one PME in the aggregation
group is ready for handshake, the value available(3) maps to
the condition where all the PMEs in the aggregation group are
up, the value notAvailable(4) maps to the condition where all
the PMEs in the aggregation group are down and no handshake
tones are detected, the value availableReduced(19) maps to the
condition where the interface is up, a link fault is detected
at the receive direction by one or more PMEs in the
aggregation group, but at least one PME is up and the
enumeration pmdLinkFault(12) maps to the condition where a link
fault is detected at the receive direction by all of the PMEs
in the aggregation group.
For 10 Gb/s the enumerations map to value of the link_fault
variable within the Link Fault Signaling state diagram
as follows: the value OK maps to the value available(3),
the value Local Fault maps to the value notAvailable(4),
and the value Remote Fault maps to the value remoteFault(5).
The value pmdLinkFault(12), wisFrameLoss(13),
wisSignalLoss(14), pcsLinkFault(15), excessiveBER(16), or
dxsLinkFault(17) SHOULD be used instead of the value
notAvailable(4), where the reason for the Local Fault state can
be identified through the use of the Clause 45 MDIO Interface.
Where multiple reasons for the Local Fault state can be
identified, only the highest precedence error SHOULD be
reported. This precedence in descending order is as follows:
pxsLinkFault
pmdLinkFault
wisFrameLoss
wisSignalLoss
pcsLinkFault
excessiveBER
dxsLinkFault.
Where a Clause 45 MDIO interface is present a logic zero in
the PMA/PMD Receive link status bit ([IEEE802.3]
Section 45.2.1.2.2) maps to the value pmdLinkFault(12),
logic one in the LOF status bit (Section 45.2.2.10.4) maps
to the value wisFrameLoss(13), a logic one in the LOS
status bit (Section 45.2.2.10.5) maps to the value
wisSignalLoss, a logic zero in the PCS Receive
link status bit (Section 45.2.3.2.2) maps to the value
pcsLinkFault(15), a logic one in the 10GBASE-R PCS Latched
high BER status bit (Section 45.2.3.12.2) maps to the value
excessiveBER, a logic zero in the DTE XS receive link status
bit (Section 45.2.5.2.2) maps to the value dxsLinkFault(17)
and a logic zero in the PHY XS transmit link status bit
(Section 45.2.4.2.2) maps to the value pxsLinkFault(18).
The most recent version of this textual convention is available
in the online version of this MIB module on the IANA web site.
Requests for new values should be made to IANA via email
(iana&iana.org)."
REFERENCE
"[IEEE802.3], Section 30.5.1.1.4"
SYNTAX INTEGER {
other(1),
unknown(2),
available(3),
notAvailable(4),
remoteFault(5),
invalidSignal(6),
remoteJabber(7),
remoteLinkLoss(8),
remoteTest(9),
offline(10),
autoNegError(11),
pmdLinkFault(12),
wisFrameLoss(13),
wisSignalLoss(14),
pcsLinkFault(15),
excessiveBER(16),
dxsLinkFault(17),
pxsLinkFault(18),
availableReduced(19),
ready(20)
}
IANAifMauAutoNegCapBits ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"This data type is used as the syntax of the
ifMauAutoNegCapabilityBits, ifMauAutoNegCapAdvertisedBits, and
ifMauAutoNegCapReceivedBits objects in the (updated) definition
of MAU-MIB's ifMauAutoNegTable.
The most recent version of this textual convention is available
in the online version of this MIB module on the IANA web site.
Requests for new values should be made to IANA via email
(iana&iana.org)."
REFERENCE
"[IEEE802.3], Section 30.6.1.1.5"
SYNTAX BITS {
bOther(0), -- other or unknown
b10baseT(1), -- 10BASE-T half duplex mode
b10baseTFD(2), -- 10BASE-T full duplex mode
b100baseT4(3), -- 100BASE-T4
b100baseTX(4), -- 100BASE-TX half duplex mode
b100baseTXFD(5), -- 100BASE-TX full duplex mode
b100baseT2(6), -- 100BASE-T2 half duplex mode
b100baseT2FD(7), -- 100BASE-T2 full duplex mode
bFdxPause(8), -- PAUSE for full-duplex links
bFdxAPause(9), -- Asymmetric PAUSE for full-duplex
-- links
bFdxSPause(10), -- Symmetric PAUSE for full-duplex
-- links
bFdxBPause(11), -- Asymmetric and Symmetric PAUSE for
-- full-duplex links
b1000baseX(12), -- 1000BASE-X, -LX, -SX, -CX half
-- duplex mode
b1000baseXFD(13), -- 1000BASE-X, -LX, -SX, -CX full
-- duplex mode
b1000baseT(14), -- 1000BASE-T half duplex mode
b1000baseTFD(15) -- 1000BASE-T full duplex mode
}
IANAifJackType ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"Common enumeration values for repeater and interface MAU
jack types. This data type is used as the syntax of the
ifJackType and rpJackType objects in the (updated) definition
of MAU-MIB's ifJackTable and rpJackTable respectively.
Possible values are:
other(1) - undefined or unknown
rj45(2) - RJ45
rj45S(3) - RJ45 shielded
db9(4) - DB9
bnc(5) - BNC
fAUI(6) - AUI female
mAUI(7) - AUI male
fiberSC(8) - SC fiber
fiberMIC(9) - MIC fiber
fiberST(10) - ST fiber
telco(11) - Telco
mtrj(12) - MT-RJ fiber
hssdc(13) - fiber channel style-2
fiberLC(14) - LC fiber
cx4(15) - IB4X for 10GBASE-CX4
The most recent version of this textual convention is available
in the online version of this MIB module on the IANA web site.
Requests for new values should be made to IANA via email
(iana&iana.org)."
SYNTAX INTEGER {
other(1),
rj45(2),
rj45S(3),
db9(4),
bnc(5),
fAUI(6),
mAUI(7),
fiberSC(8),
fiberMIC(9),
fiberST(10),
telco(11),
mtrj(12),
hssdc(13),
fiberLC(14),
-- new since RFC 3636
cx4(15)
}
-- OBJECT IDENTITIES for MAU types
-- (see rpMauType and ifMauType of MAU-MIB for usage)
-- The following definitions has been moved from RFC 3636 and
-- no longer appear in its revision.
dot3MauType OBJECT IDENTIFIER ::= { mib-2 snmpDot3MauMgt(26) 4 }
dot3MauTypeAUI OBJECT-IDENTITY
STATUS current
DESCRIPTION "no internal MAU, view from AUI"
REFERENCE "[IEEE802.3], Section 7"
::= { dot3MauType 1 }
dot3MauType10Base5 OBJECT-IDENTITY
STATUS current
DESCRIPTION "thick coax MAU"
REFERENCE "[IEEE802.3], Section 7"
::= { dot3MauType 2 }
dot3MauTypeFoirl OBJECT-IDENTITY
STATUS current
DESCRIPTION "FOIRL MAU"
REFERENCE "[IEEE802.3], Section 9.9"
::= { dot3MauType 3 }
dot3MauType10Base2 OBJECT-IDENTITY
STATUS current
DESCRIPTION "thin coax MAU"
REFERENCE "[IEEE802.3], Section 10"
::= { dot3MauType 4 }
dot3MauType10BaseT OBJECT-IDENTITY
STATUS current
DESCRIPTION "UTP MAU.
Note that it is strongly recommended that
agents return either dot3MauType10BaseTHD or
dot3MauType10BaseTFD if the duplex mode is
known. However, management applications should
be prepared to receive this MAU type value from
older agent implementations."
REFERENCE "[IEEE802.3], Section 14"
::= { dot3MauType 5 }
dot3MauType10BaseFP OBJECT-IDENTITY
STATUS current
DESCRIPTION "passive fiber MAU"
REFERENCE "[IEEE802.3], Section 16"
::= { dot3MauType 6 }
dot3MauType10BaseFB OBJECT-IDENTITY
STATUS current
DESCRIPTION "sync fiber MAU"
REFERENCE "[IEEE802.3], Section 17"
::= { dot3MauType 7 }
dot3MauType10BaseFL OBJECT-IDENTITY
STATUS current
DESCRIPTION "async fiber MAU.
Note that it is strongly recommended that
agents return either dot3MauType10BaseFLHD or
dot3MauType10BaseFLFD if the duplex mode is
known. However, management applications should
be prepared to receive this MAU type value from
older agent implementations."
REFERENCE "[IEEE802.3], Section 18"
::= { dot3MauType 8 }
dot3MauType10Broad36 OBJECT-IDENTITY
STATUS current
DESCRIPTION "broadband DTE MAU.
Note that 10BROAD36 MAUs can be attached to
interfaces but not to repeaters."
REFERENCE "[IEEE802.3], Section 11"
::= { dot3MauType 9 }
------ new since RFC 1515:
dot3MauType10BaseTHD OBJECT-IDENTITY
STATUS current
DESCRIPTION "UTP MAU, half duplex mode"
REFERENCE "[IEEE802.3], Section 14"
::= { dot3MauType 10 }
dot3MauType10BaseTFD OBJECT-IDENTITY
STATUS current
DESCRIPTION "UTP MAU, full duplex mode"
REFERENCE "[IEEE802.3], Section 14"
::= { dot3MauType 11 }
dot3MauType10BaseFLHD OBJECT-IDENTITY
STATUS current
DESCRIPTION "async fiber MAU, half duplex mode"
REFERENCE "[IEEE802.3], Section 18"
::= { dot3MauType 12 }
dot3MauType10BaseFLFD OBJECT-IDENTITY
STATUS current
DESCRIPTION "async fiber MAU, full duplex mode"
REFERENCE "[IEEE802.3], Section 18"
::= { dot3MauType 13 }
dot3MauType100BaseT4 OBJECT-IDENTITY
STATUS current
DESCRIPTION "4 pair category 3 UTP"
REFERENCE "[IEEE802.3], Section 23"
::= { dot3MauType 14 }
dot3MauType100BaseTXHD OBJECT-IDENTITY
STATUS current
DESCRIPTION "2 pair category 5 UTP, half duplex mode"
REFERENCE "[IEEE802.3], Section 25"
::= { dot3MauType 15 }
dot3MauType100BaseTXFD OBJECT-IDENTITY
STATUS current
DESCRIPTION "2 pair category 5 UTP, full duplex mode"
REFERENCE "[IEEE802.3], Section 25"
::= { dot3MauType 16 }
dot3MauType100BaseFXHD OBJECT-IDENTITY
STATUS current
DESCRIPTION "X fiber over PMT, half duplex mode"
REFERENCE "[IEEE802.3], Section 26"
::= { dot3MauType 17 }
dot3MauType100BaseFXFD OBJECT-IDENTITY
STATUS current
DESCRIPTION "X fiber over PMT, full duplex mode"
REFERENCE "[IEEE802.3], Section 26"
::= { dot3MauType 18 }
dot3MauType100BaseT2HD OBJECT-IDENTITY
STATUS current
DESCRIPTION "2 pair category 3 UTP, half duplex mode"
REFERENCE "[IEEE802.3], Section 32"
::= { dot3MauType 19 }
dot3MauType100BaseT2FD OBJECT-IDENTITY
STATUS current
DESCRIPTION "2 pair category 3 UTP, full duplex mode"
REFERENCE "[IEEE802.3], Section 32"
::= { dot3MauType 20 }
------ new since RFC 2239:
dot3MauType1000BaseXHD OBJECT-IDENTITY
STATUS current
DESCRIPTION "PCS/PMA, unknown PMD, half duplex mode"
REFERENCE "[IEEE802.3], Section 36"
::= { dot3MauType 21 }
dot3MauType1000BaseXFD OBJECT-IDENTITY
STATUS current
DESCRIPTION "PCS/PMA, unknown PMD, full duplex mode"
REFERENCE "[IEEE802.3], Section 36"
::= { dot3MauType 22 }
dot3MauType1000BaseLXHD OBJECT-IDENTITY
STATUS current
DESCRIPTION "Fiber over long-wavelength laser, half duplex
mode"
REFERENCE "[IEEE802.3], Section 38"
::= { dot3MauType 23 }
dot3MauType1000BaseLXFD OBJECT-IDENTITY
STATUS current
DESCRIPTION "Fiber over long-wavelength laser, full duplex
mode"
REFERENCE "[IEEE802.3], Section 38"
::= { dot3MauType 24 }
dot3MauType1000BaseSXHD OBJECT-IDENTITY
STATUS current
DESCRIPTION "Fiber over short-wavelength laser, half
duplex mode"
REFERENCE "[IEEE802.3], Section 38"
::= { dot3MauType 25 }
dot3MauType1000BaseSXFD OBJECT-IDENTITY
STATUS current
DESCRIPTION "Fiber over short-wavelength laser, full
duplex mode"
REFERENCE "[IEEE802.3], Section 38"
::= { dot3MauType 26 }
dot3MauType1000BaseCXHD OBJECT-IDENTITY
STATUS current
DESCRIPTION "Copper over 150-Ohm balanced cable, half
duplex mode"
REFERENCE "[IEEE802.3], Section 39"
::= { dot3MauType 27 }
dot3MauType1000BaseCXFD OBJECT-IDENTITY
STATUS current
DESCRIPTION "Copper over 150-Ohm balanced cable, full
duplex mode"
REFERENCE "[IEEE802.3], Section 39"
::= { dot3MauType 28 }
dot3MauType1000BaseTHD OBJECT-IDENTITY
STATUS current
DESCRIPTION "Four-pair Category 5 UTP, half duplex mode"
REFERENCE "[IEEE802.3], Section 40"
::= { dot3MauType 29 }
dot3MauType1000BaseTFD OBJECT-IDENTITY
STATUS current
DESCRIPTION "Four-pair Category 5 UTP, full duplex mode"
REFERENCE "[IEEE802.3], Section 40"
::= { dot3MauType 30 }
------ new since RFC 2668:
dot3MauType10GigBaseX OBJECT-IDENTITY
STATUS current
DESCRIPTION "X PCS/PMA, unknown PMD."
REFERENCE "[IEEE802.3], Section 48"
::= { dot3MauType 31 }
dot3MauType10GigBaseLX4 OBJECT-IDENTITY
STATUS current
DESCRIPTION "X fiber over WWDM optics"
REFERENCE "[IEEE802.3], Section 53"
::= { dot3MauType 32 }
dot3MauType10GigBaseR OBJECT-IDENTITY
STATUS current
DESCRIPTION "R PCS/PMA, unknown PMD."
REFERENCE "[IEEE802.3], Section 49"
::= { dot3MauType 33 }
dot3MauType10GigBaseER OBJECT-IDENTITY
STATUS current
DESCRIPTION "R fiber over 1550 nm optics"
REFERENCE "[IEEE802.3], Section 52"
::= { dot3MauType 34 }
dot3MauType10GigBaseLR OBJECT-IDENTITY
STATUS current
DESCRIPTION "R fiber over 1310 nm optics"
REFERENCE "[IEEE802.3], Section 52"
::= { dot3MauType 35 }
dot3MauType10GigBaseSR OBJECT-IDENTITY
STATUS current
DESCRIPTION "R fiber over 850 nm optics"
REFERENCE "[IEEE802.3], Section 52"
::= { dot3MauType 36 }
dot3MauType10GigBaseW OBJECT-IDENTITY
STATUS current
DESCRIPTION "W PCS/PMA, unknown PMD."
REFERENCE "[IEEE802.3], Section 49 and 50"
::= { dot3MauType 37 }
dot3MauType10GigBaseEW OBJECT-IDENTITY
STATUS current
DESCRIPTION "W fiber over 1550 nm optics"
REFERENCE "[IEEE802.3], Section 52"
::= { dot3MauType 38 }
dot3MauType10GigBaseLW OBJECT-IDENTITY
STATUS current
DESCRIPTION "W fiber over 1310 nm optics"
REFERENCE "[IEEE802.3], Section 52"
::= { dot3MauType 39 }
dot3MauType10GigBaseSW OBJECT-IDENTITY
STATUS current
DESCRIPTION "W fiber over 850 nm optics"
REFERENCE "[IEEE802.3], Section 52"
::= { dot3MauType 40 }
------ new since RFC 3636:
dot3MauType10GigBaseCX4 OBJECT-IDENTITY
STATUS current
DESCRIPTION "X copper over 8 pair 100-Ohm balanced cable"
REFERENCE "[IEEE802.3], Section 54"
::= { dot3MauType 41 }
dot3MauType2BaseTL OBJECT-IDENTITY
STATUS current
DESCRIPTION "Voice grade UTP copper, up to 2700m, optional PAF"
REFERENCE "[IEEE802.3], Sections 61 and 63"
::= { dot3MauType 42 }
dot3MauType10PassTS OBJECT-IDENTITY
STATUS current
DESCRIPTION "Voice grade UTP copper, up to 750m, optional PAF"
REFERENCE "[IEEE802.3], Sections 61 and 62"
::= { dot3MauType 43 }
dot3MauType100BaseBX10D OBJECT-IDENTITY
STATUS current
DESCRIPTION "One single-mode fiber OLT, long wavelength, 10km"
REFERENCE "[IEEE802.3], Section 58"
::= { dot3MauType 44 }
dot3MauType100BaseBX10U OBJECT-IDENTITY
STATUS current
DESCRIPTION "One single-mode fiber ONU, long wavelength, 10km"
REFERENCE "[IEEE802.3], Section 58"
::= { dot3MauType 45 }
dot3MauType100BaseLX10 OBJECT-IDENTITY
STATUS current
DESCRIPTION "Two single-mode fibers, long wavelength, 10km"
REFERENCE "[IEEE802.3], Section 58"
::= { dot3MauType 46 }
dot3MauType1000BaseBX10D OBJECT-IDENTITY
STATUS current
DESCRIPTION "One single-mode fiber OLT, long wavelength, 10km"
REFERENCE "[IEEE802.3], Section 59"
::= { dot3MauType 47 }
dot3MauType1000BaseBX10U OBJECT-IDENTITY
STATUS current
DESCRIPTION "One single-mode fiber ONU, long wavelength, 10km"
REFERENCE "[IEEE802.3], Section 59"
::= { dot3MauType 48 }
dot3MauType1000BaseLX10 OBJECT-IDENTITY
STATUS current
DESCRIPTION "Two sigle-mode fiber, long wavelength, 10km"
REFERENCE "[IEEE802.3], Section 59"
::= { dot3MauType 49 }
dot3MauType1000BasePX10D OBJECT-IDENTITY
STATUS current
DESCRIPTION "One single-mode fiber EPON OLT, 10km"
REFERENCE "[IEEE802.3], Section 60"
::= { dot3MauType 50 }
dot3MauType1000BasePX10U OBJECT-IDENTITY
STATUS current
DESCRIPTION "One single-mode fiber EPON ONU, 10km"
REFERENCE "[IEEE802.3], Section 60"
::= { dot3MauType 51 }
dot3MauType1000BasePX20D OBJECT-IDENTITY
STATUS current
DESCRIPTION "One single-mode fiber EPON OLT, 20km"
REFERENCE "[IEEE802.3], Section 60"
::= { dot3MauType 52 }
dot3MauType1000BasePX20U OBJECT-IDENTITY
STATUS current
DESCRIPTION "One single-mode fiber EPON ONU, 20km"
REFERENCE "[IEEE802.3], Section 60"
::= { dot3MauType 53 }
END

Some files were not shown because too many files have changed in this diff Show More