Compare commits

..

95 Commits

Author SHA1 Message Date
goldsimon
92f23d6ca0 set lwip version to 2.0.3 RELEASE 2017-09-15 20:11:17 +02:00
goldsimon
750c9a750b UPGRADING: added a note for 2.0.2 that was forgotten back then 2017-09-15 13:34:59 +02:00
goldsimon
8244fb523c Adapt CHANGELOG to changes for 2.0.3 2017-09-15 13:28:39 +02:00
goldsimon
a13c488e52 Fix bug #51687 (tcp_close(): is it OK to return ERR_MEM if TF_CLOSEPEND is set?)
(cherry picked from commit 1d4ca0bff6)

# Conflicts:
#	src/core/tcp.c
2017-09-15 13:19:11 +02:00
goldsimon
e8a3d42e2d Fix bug #51937 by checking TF_CLOSED at the end of all pcb callbacks in tcp_input()
(cherry picked from commit 86abfbe087)
2017-09-15 12:59:58 +02:00
goldsimon
66120f7d79 refactor tcp_input a bit in preparation of a fix for bug #51937
(cherry picked from commit a8ac37f419)

# Conflicts:
#	src/core/tcp_in.c
2017-09-15 12:59:57 +02:00
goldsimon
1d04b06450 Fixed bugs #51606 and #51535: IPv4 reassembly could be finished although there are holes
(cherry picked from commit 5ea7f507c3)

# Conflicts:
#	test/unit/Filelists.mk
#	test/unit/lwipopts.h
2017-09-15 12:52:40 +02:00
goldsimon
c51e6fbb12 Fixed bug #51623: DHCP request XID should probably be regenerated for INIT-REBOOT
(cherry picked from commit a81b19aa62)
2017-09-15 12:52:19 +02:00
goldsimon
9b19266e3d ip4_reass: fixed bug #51596 (Insufficient overlap check)
(cherry picked from commit 500598658d)
2017-09-15 12:52:18 +02:00
goldsimon
a2ac9b045a ip4_reass: fixed bug #51597 (Last fragment is assumed to have arrived even if it was discarded)
(cherry picked from commit 3dedfa3d1f)

# Conflicts:
#	src/core/ipv4/ip4_frag.c
2017-09-15 12:52:17 +02:00
goldsimon
737ed228c9 ip4_reass: fixed bug #51595 (ip_reass_pbufcount may be updated incorectly)
(cherry picked from commit f1072fee8a)

# Conflicts:
#	src/core/ipv4/ip4_frag.c
2017-09-15 12:52:04 +02:00
Matthias Hofmann
82e5a18b50 Fix using DHCP IP configuration after lease time is expired.
Signed-off-by: goldsimon <goldsimon@gmx.de>
(cherry picked from commit 9b06d71aeb)
2017-09-15 12:50:08 +02:00
Pascal Quantin
ac880ea907 Fixed bug #51528 (Bug when parsing WND_SCALE option)
Signed-off-by: goldsimon <goldsimon@gmx.de>
(cherry picked from commit 2e78b6dcae)
2017-09-15 12:49:51 +02:00
goldsimon
32aa50cfbc Fix sys_timeouts_init() for LWIP_TCP==0 (see patch #9375)
(cherry picked from commit 7b45f3fa3f)
2017-09-15 12:49:29 +02:00
Axel Lin
e6fa613633 tcp: Remove unreachable code in tcp_close_shutdown_fin
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Dirk Ziegelmeier <dirk@ziegelmeier.net>
(cherry picked from commit 9bbb741247)
2017-09-15 12:49:00 +02:00
Dirk Ziegelmeier
c6b19cad34 Fix bug #50932: LWIP-provided byteorder functions defined in the wrong scope
Apply suggested fix from "Fayek"
(cherry picked from commit fe8c62e7b6)
2017-09-15 12:48:47 +02:00
goldsimon
f389d78f7e Fixed bug #50838 (mem.c needs SYS_ARCH_PROTECTION around MEM_STATS)
(cherry picked from commit 3770adccfd)
2017-09-14 09:27:50 +02:00
Dirk Ziegelmeier
dced7dad41 Apply patch from Kudratov Olimjon: Array index used before limits check
while ((q != NULL) && (options[offset] != DHCP_OPTION_END) && (offset < offset_max)) {
should be
while ((q != NULL) && (offset < offset_max) && (options[offset] != DHCP_OPTION_END)) {

See https://jira.reactos.org/browse/CORE-8978 for more info.
(cherry picked from commit 32aa9a41e2)
2017-09-14 09:26:33 +02:00
goldsimon
56a295f0a0 dhcp_parse_reply: return ERR_VAL instead of asserting on offset-out-of-pbuf
(cherry picked from commit 33466ee6a8)
2017-09-14 09:23:56 +02:00
Dirk Ziegelmeier
aecb1b9eb0 Fix bug #50618: dhcp_remove_struct() macro does not work
Patch by Benjamin Silvestre

(cherry picked from commit 819224f0e5)
2017-09-14 09:20:37 +02:00
Mikhail Lappo
dbb3b3a3a1 Possible null-pointer dereference
The value should be dereferenced after
assertion is performed. This can lead
to crash

(cherry picked from commit 7eba14cb76)
2017-09-14 09:19:51 +02:00
Mikhail Lappo
77c12bb124 Possible null-pointer dereference
In assertion the pointer that is potentialy
null is dereferenced. The check for null was
located after.

(cherry picked from commit eba1b971c0)
2017-09-14 09:18:55 +02:00
Dirk Ziegelmeier
0623dc4038 Apply [patch #9287] Possible null-pointer dereference from Mikhail Lappo in a modified way
Moved the debug output to a location where we know that newpcb != NULL
Fixes possible NULL pointer dereferencing in debug message output

(cherry picked from commit 9e20fe2cfb)
2017-09-14 09:18:30 +02:00
goldsimon
f5438b1b43 try to satisfy clang's '-Wempty-body'
(cherry picked from commit aef2accfa3)
2017-09-14 09:16:42 +02:00
Dirk Ziegelmeier
1cf9fc0d39 Update doxygen version to 2.0.3 as in init.h
(cherry picked from commit 59fba75cd8)
2017-09-14 09:16:18 +02:00
goldsimon
f9872c519c memp.h: added missing include
(cherry picked from commit 3fd8440ab9)
2017-09-14 09:15:54 +02:00
Dirk Ziegelmeier
a4017a485c Fix coding style NO_SYS example code
(cherry picked from commit b9a40a5163)
2017-09-14 09:07:44 +02:00
Dirk Ziegelmeier
2490d034cd Fix starting DHCP in NO_SYS example code
(cherry picked from commit da0714d7cb)
2017-09-14 09:07:43 +02:00
goldsimon
282e85763b lwip_init(): at least IAR warns about "LWIP_UNUSED_ARG(a)" accessing an uninitialized variable... Try to fix this by initializing it (it will be optimized away anyway)
(cherry picked from commit 946b231516)
2017-09-14 09:06:34 +02:00
goldsimon
c0862d6074 Fixed LWIP_VERSION define for 2.0.2 2017-03-13 13:27:00 +01:00
goldsimon
ea2f6fb57c Add CHANGELOG for 2.0.2 2017-03-13 10:26:42 +01:00
Dirk Ziegelmeier
b307fea1b9 Rename "IPv6 mapped IPv4 addresses" to their correct name from RFC4191: "IPv4-mapped IPv6 address"
(cherry picked from commit 4d8fec3b67)

Conflicts:
	src/core/ipv6/ip6.c
2017-03-13 09:28:46 +01:00
Joel Cunningham
c31bd404e2 Fix unit test with assumed congestion avoidance
test_tcp_fast_rexmit_wraparound correctness relied on the congestion
window being in congestion avoidance so that only a single TCP_MSS
segment is sent upon ACKing the first segment.

It's not known whether the test was relying tcp_alloc() to set ssthresh
to 0 and thus start in congestion avoidance or if the test was working by
accident until changes in b90a54f989

This fixes the test by enforcing the requirement of starting in
congestion avoidance

Signed-off-by: goldsimon <goldsimon@gmx.de>
(cherry picked from commit 8bf402fd67)
2017-03-13 09:14:38 +01:00
goldsimon
0381849624 tcp unit tests: fixed that tcp_teardown() could lead to accessing a netif pointer that is not valid any more (netif added in test function stored on stack)
(cherry picked from commit e9e9ec23b8)
2017-03-13 09:14:24 +01:00
goldsimon
19d56b4096 tcp: watch out for pcb->nrtx overflows and tcp_backoff indexing overflow
(cherry picked from commit 7ffe5bfb3c)
2017-03-13 09:14:23 +01:00
David van Moolenbroek
66db517a28 tcp: do not keep sending SYNs when getting ACKs
If a locally generated TCP SYN packet is replied to with an ACK
packet, lwIP immediately sends a RST packet followed by resending the
SYN packet.  This is expected, but on loopback interfaces the resent
SYN packet may immediately get another ACK reply, typically when the
other endpoint is in TIME_WAIT state (which ignores the RSTs).  The
result is an endless loop of SYN, ACK, RST packets.

This patch applies the normal SYN retransmission limit in this
scenario, such that the endless loop is limited to a brief storm.

(cherry picked from commit 5827c168c2)
2017-03-13 09:14:22 +01:00
Joel Cunningham
2452bc9336 bug #50476: initialize ssthresh to TCP_SND_BUF
This commit changes ssthresh to be the largest effective congestion
window (amount of in-flight data). This follows the guidance of RFC
5681 which recommends setting ssthresh arbitrarily high.

LwIP was previously using the receive window value at the end of the
3-way handshake and in the case of an active open where the receiver
used window scaling and/or window auto-tuning, this resulted in a very
small ssthresh value even though the window ramped up once the connection
was established

(cherry picked from commit b90a54f989)
2017-03-13 09:13:41 +01:00
Sylvain Rochet
2848b17e80 PPP: remove unused and confusing return values other than ERR_OK for ppp_connect and ppp_listen
User should not use ppp_connect or ppp_listen return value to retry
later, it must wait for the callback to be called. This is primarily
done this way to have a consistent behavior with and without the
holdoff feature.

Remove returned error value from PPP link level API connect and listen
callbacks because we are not using them anymore, then make ppp_connect
or ppp_listen to always return ERR_OK, thus we are not breaking the PPP
user API.

We don't need the return code here, all PPP link level drivers can't
fail at all (e.g. PPPoS) or retry if necessary (PPPoE and PPPoL2TP).

(cherry picked from commit e16d10ade6)
2017-03-13 09:13:17 +01:00
goldsimon
c71c9882c2 arch.h: include <limits.h> if it exists (at least INT_MAX is used)
(cherry picked from commit aff1935e40)
2017-03-13 09:13:07 +01:00
Dirk Ziegelmeier
40fbd6bc24 One enum icmp_te_type member is not in doxygen docs - fix it.
(cherry picked from commit 927990d94e)
2017-03-13 09:12:30 +01:00
goldsimon
df7485de1c lwip_sendmsg/tcp: prevent PSH until all iovecs are enqueued
(cherry picked from commit 1b3aaef525)
2017-03-13 09:12:08 +01:00
goldsimon
fe6e1bd4af httpd: LWIP_HTTPD_POST_MANUAL_WND: fixed double-free when httpd_post_data_recved is called nested from httpd_post_receive_data() (bug #50424)
# Conflicts:
#	CHANGELOG
2017-03-01 22:15:59 +01:00
goldsimon
168fa1c38a Fix compiling httpd for LWIP_HTTPD_SUPPORT_POST==1 (assigning int to u16_t) 2017-03-01 22:15:42 +01:00
goldsimon
f0975b3c59 make tcp apps depend on LWIP_CALLBACK_API, too 2017-03-01 22:15:18 +01:00
goldsimon
563932b888 tcp: fixed bug #50418: LWIP_EVENT_API: fix invalid calbacks for SYN_RCVD pcb
# Conflicts:
#	CHANGELOG
2017-03-01 22:15:07 +01:00
goldsimon
8849a443a4 pbuf_ref: assert-check for 'ref' overflow
(cherry picked from commit 76763c9bcd)
2017-02-27 12:31:13 +01:00
goldsimon
e318688195 Improved DNS_LOCAL_HOSTLIST interface (bug #50325)
(cherry picked from commit deaa6e9406)

Conflicts:
	CHANGELOG
2017-02-27 12:30:38 +01:00
goldsimon
fa8b6a92b4 Fix portable initialization of non-dynamic DNS_LOCAL_HOSTLIST
(cherry picked from commit 19d63e6aa0)
2017-02-27 12:30:30 +01:00
sg
2ca39c275a LWIP_NETCONN_FULLDUPLEX: fixed shutdown during write (bug #50274)
(cherry picked from commit 6dca664217)

Conflicts:
	CHANGELOG
2017-02-27 12:29:23 +01:00
Joel Cunningham
4d1d567ab7 Fix comment typo from bug #47485
tcp_close_shutdown_impl() should be tcp_close_shutdown_fin()

(cherry picked from commit 0b257f71e7)
2017-02-27 12:28:18 +01:00
goldsimon
8927cda2f8 For tiny targtes, LWIP_RAND is optional -> fix compile time checks
(cherry picked from commit 693a74c286)
2017-02-27 12:27:47 +01:00
Dirk Ziegelmeier
bc78251f4a My documentation changes forced the usage of rand() function, which is not desired
By default, the code that does NOT need LWIP_RAND() is active now

(cherry picked from commit 06c84cb110)
2017-02-27 12:27:30 +01:00
David van Moolenbroek
0a3e4cd10e tcp: fix accept event on closed listening PCBs
If LWIP_CALLBACK_API is not defined, but TCP_LISTEN_BACKLOG is, then
the LWIP_EVENT_ACCEPT TCP event may be triggered for closed listening
sockets.  This case is just as disastrous for the event API as it is
for the callback API, as there is no way for the event hook to tell
whether the listening PCB is still around.  Add the same protection
against this case for TCP_LISTEN_BACKLOG as was already in place for
LWIP_CALLBACK_API.

Also remove one NULL check for LWIP_CALLBACK_API that had already
become redundant for all callers, making the TCP_EVENT_ACCEPT code
for that callback wrapper more in line with the rest of the wrappers.

(cherry picked from commit 240cf62056)
2017-02-27 12:25:52 +01:00
Dirk Ziegelmeier
76efa271e6 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-27 12:25:08 +01:00
goldsimon
b3293d903e Fixed bug #47485 (tcp_close() should not fail on memory error) by retrying to send FIN from tcp_fasttmr
(cherry picked from commit bc07fd9db5)

Conflicts:
	CHANGELOG
2017-02-27 12:24:51 +01:00
Dirk Ziegelmeier
5ef8a3cb60 igmp.c: igmp_lookup_group() should be static
(cherry picked from commit 702091d548)
2017-02-27 12:23:39 +01:00
sg
01c2e43c5c 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"
(cherry picked from commit c1c470fc4c)
2017-02-27 12:23:04 +01:00
goldsimon
0b7bef5420 http_add_connection: add connections to the front to be faster (and really fix bug #50059)
(cherry picked from commit ea093d3a53)
2017-02-27 12:22:42 +01:00
goldsimon
3c4aec99a4 Fixed bug #50059 (httpd LWIP_HTTPD_SUPPORT_11_KEEPALIVE vs. LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED)
(cherry picked from commit 5743864744)
2017-02-27 12:22:42 +01:00
Luc Revardel
dc38e21a70 Fix bug #50220 (mld6_leavegroup does not send ICMP6_TYPE_MLD, even if last reporter)
Signed-off-by: sg <goldsimon@gmx.de>
(cherry picked from commit 819bfbb943)
2017-02-27 12:22:41 +01:00
David van Moolenbroek
d471e5f89e Patch #9250 (slightly changed): fix source substitution in ip6_output_if() (broken in 2014 with be75c483d0)
Signed-off-by: sg <goldsimon@gmx.de>
(cherry picked from commit fffd61c746)
2017-02-27 12:22:03 +01:00
sg
99ef13f2be Fixed bug #50090 (ast_unsent->oversize_left can become wrong value in tcp_write error path)
(cherry picked from commit 21737f57e5)
2017-02-27 12:21:31 +01:00
Dirk Ziegelmeier
bb2b2be454 Fix bug #50206: UDP Netconn bind to IP6_ADDR_ANY fails
The tests were in to catch user errors, but they seem to get in the way of application programming :-)
The checks in *_send() remain active to catch when PCB source and destination address types do not match

(cherry picked from commit ff04c2046e)
2017-02-27 12:20:01 +01:00
goldsimon
faa7a21a83 Fix comment on lwip_shutdown() (it's not unimplemented any more)
(cherry picked from commit 4b091cfc2a)
2017-02-27 12:19:28 +01:00
Axel Lin
d6e8e05edd stats: Remove superfluous /t in end of stats display
The debug message after the stats display looks odd because the /t in end of
stats display.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
(cherry picked from commit 2685d742e8)
2017-02-27 12:19:08 +01:00
Dirk Ziegelmeier
0b299f96e9 Add CHANGELOG to lwIP HTML documentation
(cherry picked from commit ee3154999a)
2017-02-27 12:18:26 +01:00
Dirk Ziegelmeier
777d54f0e4 Retry 1 to fix bug #50064
Accidentally used the wrong destination HW addr

(cherry picked from commit 645ca84704)
2017-02-27 12:17:41 +01:00
Dirk Ziegelmeier
8c6ac8eb59 Optimize my last fix in etharp.c, I missed the variable declaration at the beginning of the function
(cherry picked from commit 7aaa888d1d)
2017-02-27 12:17:41 +01:00
Dirk Ziegelmeier
4fc3770278 Remove special ARP reply optimization from etharp.c
- Code duplication with etharp_raw()
- No great effect on perfomance
- May make reworking PBUF handling code more complicated (see bug #49914)
- The check for p->type == PBUF_REF is a strange special case, too
- Simon also voted to remove it

(cherry picked from commit 47bac3c11f)
2017-02-27 12:17:40 +01:00
Dirk Ziegelmeier
e53c84654e Fix bug #50064: Zero-copy RX: ARP reply fails with PBUF_REF
Kept the optimized version intact, see discussion in savannah bug tracker

(cherry picked from commit 199c38de29)
2017-02-27 12:17:40 +01:00
sg
d0b0cf983e fix compiling TCP unit tests with IPv6 enabled
(cherry picked from commit b198c877db)
2017-02-27 12:17:39 +01:00
Axel Lin
90d68b41df tcp_out: Use LWIP_MIN instead of open-coded for better readability
Make the intention of code more clear by using LWIP_MIN instead of open-coded.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
(cherry picked from commit 141b5def46)
2017-02-27 12:16:17 +01:00
Axel Lin
e6756387b0 tcp_out: Fix comment for last_unsent->oversize_left and tcp_pcb.unsent_oversize
Both last_unsent->unsent_oversize and tcp_pcb.unsent_oversized fields are not
exist, fix the comments.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
(cherry picked from commit 30aedfc3f7)
2017-02-27 12:16:17 +01:00
Dirk Ziegelmeier
4fe1436904 Add some parentheses for better code readability in tcp_in.c
(cherry picked from commit df8e404abd)
2017-02-27 12:16:16 +01:00
Dirk Ziegelmeier
1fdbda9700 Fix bug #50040: pbuf_alloc(..., 65534, PBUF_RAM) succeeds
Check for integer overflow when calculating memory allocation size
(cherry picked from commit 9898d406bc)
2017-02-27 12:16:16 +01:00
Dirk Ziegelmeier
fed15778dd Minor typo fix in tcp_out.c
(cherry picked from commit 0043bf78b6)
2017-02-27 12:16:16 +01:00
Axel Lin
bbe91e356f tcp_out: Fix oversize vs. space assertion test
oversize_used is always 0 at this point, should test oversize instead.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
(cherry picked from commit e1598b0b11)
2017-02-27 12:16:15 +01:00
Dirk Ziegelmeier
0a73e0ff30 Set lwIP version to 2.0.2 in doxygen script
(cherry picked from commit 861dab5b22)
2017-02-27 12:16:15 +01:00
Dirk Ziegelmeier
7ba2633ef0 Minor code readability improvement in mqtt.c
(cherry picked from commit 5c58e25de5)
2017-02-27 12:14:46 +01:00
Dirk Ziegelmeier
d860dd7655 Minor correction to last patch: Avoid #including socket.h in api_msg.c
(cherry picked from commit 2b1ebda6f1)
2017-02-27 12:13:27 +01:00
Knut Andre Tidemann
2694486309 lwip: fix broken default ICMPv6 handling of checksums.
ICMPv6 should always have checksum generated for it as per RFC 3542
chapter 3.1.

(cherry picked from commit 5e9df2c698)
2017-02-27 12:13:26 +01:00
Dirk Ziegelmeier
cb97e27120 MQTT: Add check that WILL topic length must be > 0
(cherry picked from commit 52f448978f)
2017-02-27 12:09:49 +01:00
Dirk Ziegelmeier
890c5982a1 MQTT: Fix possible bug in connect message generation that WILL flag can be set without appending a will message
The boolean condition of setting the WILL flag differs from that of appending the will message
Found by Axel Lin
(I fixed it the same way as Axel suggested, but I wanted a different commit message)
(cherry picked from commit 6d5ddb7139)
2017-02-27 12:09:49 +01:00
Axel Lin
4deaebae44 mqtt: Slightly improve mqtt_create_request
Mainly for better readability, also save NULL test while iterating the for loop.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
(cherry picked from commit a2915b7142)
2017-02-27 12:09:49 +01:00
Axel Lin
5fe195c3d3 mqtt: Prevent NULL pointer dereference before assertion checking
Signed-off-by: Axel Lin <axel.lin@ingics.com>
(cherry picked from commit 7faa4bcbe2)
2017-02-27 12:08:55 +01:00
Dirk Ziegelmeier
e5071daf45 Add MQTT to CHANGELOG (too late for 2.0.1 release...) 2017-01-10 10:42:25 +01:00
Dirk Ziegelmeier
980b219c28 Put 2.0.1 version tag in UPGRADING document 2017-01-10 10:42:23 +01:00
Erik Ekman
76b4365aaa Remove duplicate netif_dhcp_data() macro
Fix compilation of unit tests
2017-01-10 10:42:22 +01:00
Dirk Ziegelmeier
a5a4830b16 Set lwIP version to 2.0.1 RELEASE 2017-01-05 15:02:10 +01:00
Dirk Ziegelmeier
1a2a9a4e96 Merge branch 'master' into STABLE-2_0_0
# Conflicts:
#	src/include/lwip/init.h
2017-01-05 15:01:08 +01:00
Dirk Ziegelmeier
216bf89491 Set version to 2.0.0 release 2016-11-10 09:46:31 +01:00
Dirk Ziegelmeier
a68eddbd47 Merge branch 'master' into STABLE-2_0_0 2016-11-10 09:44:33 +01:00
goldsimon
fd096a5769 Set LWIP_VERSION_RC to RC2 2016-08-03 09:12:23 +02:00
goldsimon
15b75555a6 Merge branch 'master' into STABLE-2_0_0 2016-08-03 08:59:09 +02:00
sg
33955c636d Set LWIP_VERSION_RC to RC1 2016-04-27 22:04:51 +02:00
683 changed files with 15948 additions and 116786 deletions

6
.gitattributes vendored
View File

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

View File

@@ -1,45 +0,0 @@
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

@@ -1,6 +0,0 @@
#!/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 .

View File

@@ -1,124 +0,0 @@
# 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

View File

@@ -1,34 +0,0 @@
#!/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)

73
.gitignore vendored
View File

@@ -1,67 +1,18 @@
*.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
/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

View File

@@ -1,28 +0,0 @@
{
"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
View File

@@ -1,62 +0,0 @@
{
// 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
View File

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

54
.vscode/tasks.json vendored
View File

@@ -1,54 +0,0 @@
{
// 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
View File

@@ -1,119 +0,0 @@
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.

489
CHANGELOG
View File

@@ -1,406 +1,9 @@
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)
2017-11-14: Joel Cunningham
* netifapi: Add thread safe ARP cache APIs (task #14724)
2017-11-06: Axel Lin
* TCP: kill existing connections with a LOWER priority than the one currently being opened.
Previous implementations also kill existing connections of the SAME priority.
2017-09-21: Kalle Olavi Niemitalo
* sockets: add poll() implementation (patch #9450)
2017-09-10: Joel Cunningham
* sockets: add readv() implementation (task #14610)
2017-08-04: Simon Goldschmidt
* Clean up DHCP a bit: no need keep msg_out and msg_in as members in struct
dhcp - they are used in a call stack only (p_out and options_out_len as well)
2017-08-04: Simon Goldschmidt
* pbuf: split pbuf_header(s16_t) into pbuf_add_header(size_t) and
pbuf_remove_header(size_t)
2017-07-20: Douglas
* sys: deprecate sys_arch_sem_wait and sys_arch_mbox_fetch returning the
time waited rather they are now defined to return != SYS_ARCH_TIMEOUT
on success.
2017-07-03: Jakub Schmidtke
* tcp: added support for sending TCP SACKs
2017-06-20: Joel Cunningham
* netconn/netdb: added core locking support to netconn_gethostbyname (task #14523)
2017-04-25: Simon Goldschmidt
* dhcp: added two hooks for adding and parsing user defined DHCP options
2017-04-25: Joel Cunningham
* 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)
2017-04-11: Simon Goldschmidt
* 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)
2017-03-02: Simon Goldschmidt
* netconn: added nonblocking accept/recv to netconn API (task #14396)
2017-02-28: Simon Goldschmidt
* Added LWIP_SINGLE_NETIF for small targets with only one netif
2017-02-10: David van Moolenbroek
* Implement UDP and RAW multicast support for IPv6 (core API, not netconn/sockets)
2017-02-04: David van Moolenbroek
* 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
- Add raw_sendto_if_src()
- Support IP_HDRINCL socket option
++ 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)
2017-09-12: David Lockyer
* select: allocate select_cb from memp for LWIP_MPU_COMPATIBLE = 1 (bug #51990)
2017-09-11: Simon Goldschmidt
* tcp_in.c: fix bug #51937 (leaking tcp_pcbs on passive close with unacked data)
2017-08-11: Joel Cunningham
* lwip_itoa: fix converting the number 0 (previously converted to '\0') (bug #51729)
2017-08-08: Dirk Ziegelmeier
* 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.
2017-08-04: Joel Cunningham
* tcp: re-work persist timer to fully close window (details in bug #50837)
2017-07-26: Simon Goldschmidt
* snmp_msg.c: fix bug #51578 (SNMP failed to decode some values on non 32bit platforms)
2017-07-20: Simon Goldschmidt
* compatibility headers: moved from 'src/include/posix' to 'src/include/compat/posix',
'src/include/compat/stdc' etc.
2017-05-09: Joel Cunningham
* tcp: add zero-window probe timeout (bug #50837)
2017-04-11: Simon Goldschmidt
* 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:
@@ -410,7 +13,7 @@ HISTORY
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
@@ -555,7 +158,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)
@@ -830,7 +433,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.
@@ -1362,7 +965,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
@@ -1444,10 +1047,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
@@ -1902,7 +1505,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
@@ -1955,7 +1558,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.
@@ -2000,21 +1603,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
@@ -2118,7 +1721,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
@@ -2578,7 +2181,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
@@ -2586,7 +2189,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
@@ -2722,7 +2325,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)
@@ -2758,7 +2361,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
@@ -2843,7 +2446,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
@@ -2853,7 +2456,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
@@ -2879,8 +2482,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.
@@ -3004,7 +2607,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.
@@ -3024,7 +2627,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).
@@ -3048,7 +2651,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
@@ -3129,7 +2732,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".
@@ -3141,11 +2744,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.
@@ -3352,32 +2955,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).
@@ -3400,7 +3003,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)
@@ -3442,7 +3045,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.
@@ -3559,7 +3162,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
@@ -3579,13 +3182,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
@@ -3683,7 +3286,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.
@@ -3785,7 +3388,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).
@@ -3932,7 +3535,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
@@ -4024,13 +3627,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)
@@ -4114,7 +3717,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)
@@ -4184,7 +3787,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,37 +0,0 @@
cmake_minimum_required(VERSION 3.10)
set (CMAKE_CONFIGURATION_TYPES "Debug;Release")
project(lwIP)
# Example lwIP application
set(LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR})
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)
# 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,25 +1,33 @@
Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
All rights reserved.
/*
* 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>
*
*/
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.

View File

@@ -1,11 +0,0 @@
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,4 +1,3 @@
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.
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).
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,34 +17,27 @@ 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
fast recovery/fast retransmit and sending SACKs
and fast recovery/fast retransmit
* raw/native API for enhanced performance
* Optional Berkeley-like socket API
* 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)
* DNS (Domain names resolver)
APPLICATIONS
* HTTP server with SSI and CGI (HTTPS via altcp)
* SNMPv2c agent with MIB compiler (Simple Network Management Protocol), v3 via altcp
* HTTP server with SSI and CGI
* SNMPv2c agent with MIB compiler (Simple Network Management Protocol)
* SNTP (Simple network time protocol)
* NetBIOS name service responder
* MDNS (Multicast DNS) responder
* iPerf server implementation
* MQTT client (TLS support via altcp)
LICENSE
@@ -64,39 +57,37 @@ 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 'src' directory and
contributions (such as platform ports and applications) are in
the 'contrib' directory.
The lwIP TCP/IP stack is maintained in the 'lwip' Git module and
contributions (such as platform ports) are in the 'contrib' Git module.
See doc/savannah.txt for details on Git server access for users and
developers.
The current Git tree is web-browsable:
https://git.savannah.gnu.org/cgit/lwip.git
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
Submit patches and bugs via the lwIP project page:
https://savannah.nongnu.org/projects/lwip/
http://savannah.nongnu.org/projects/lwip/
Continuous integration builds (GCC, clang):
https://github.com/lwip-tcpip/lwip/actions
https://travis-ci.org/yarrick/lwip-merged
DOCUMENTATION
Self documentation of the source code is regularly extracted from the current
Git sources and is available from this web page:
https://www.nongnu.org/lwip/
http://www.nongnu.org/lwip/
There is now a constantly growing wiki about lwIP at
http://lwip.wikia.com/wiki/LwIP_Wiki
Also, there are mailing lists you can subscribe at
https://savannah.nongnu.org/mail/?group=lwip
http://savannah.nongnu.org/mail/?group=lwip
plus searchable archives:
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.
http://lists.nongnu.org/archive/html/lwip-users/
http://lists.nongnu.org/archive/html/lwip-devel/
lwIP was originally written by Adam Dunkels:
http://dunkels.com/adam/

View File

@@ -7,52 +7,6 @@ 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:
* 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. (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)
* 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)
@@ -62,8 +16,8 @@ with newer versions.
supported any more, netif->state is interpreted as an u8_t port number now
(it's not a POINTER to an u8_t any more!)
(2.0.1)
(2.0.1)
++ Application changes:
* UDP does NOT receive multicast traffic from ALL netifs on an UDP PCB bound to a specific

View File

@@ -1,26 +0,0 @@
# 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}
}

View File

@@ -1,59 +0,0 @@
#!/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

View File

@@ -1,106 +0,0 @@
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;
}
}

View File

@@ -1,61 +0,0 @@
# 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})

View File

@@ -1,57 +0,0 @@
#
# 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

@@ -1,5 +0,0 @@
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

@@ -1,91 +0,0 @@
/*
* 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

@@ -1,61 +0,0 @@
/*
* 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

@@ -1,43 +0,0 @@
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

@@ -1,248 +0,0 @@
/**
* @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

@@ -1,94 +0,0 @@
/**
* @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

@@ -1,164 +0,0 @@
/**
* @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

@@ -1,50 +0,0 @@
/**
* @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

@@ -1,182 +0,0 @@
/**
* @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

@@ -1,48 +0,0 @@
/*
* 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

@@ -1,27 +0,0 @@
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

@@ -1,534 +0,0 @@
/**
* @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

@@ -1,84 +0,0 @@
/*
* 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

@@ -1,67 +0,0 @@
<?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

@@ -1,54 +0,0 @@
/*
* 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

@@ -1,119 +0,0 @@
/*
* 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

@@ -1,56 +0,0 @@
/*
* 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

@@ -1,139 +0,0 @@
/*
* 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

@@ -1,41 +0,0 @@
/*
* 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

@@ -1,75 +0,0 @@
/*
* 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

@@ -1,64 +0,0 @@
/*
* 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

@@ -1,129 +0,0 @@
/*
* 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

@@ -1,114 +0,0 @@
/*
* 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

@@ -1,137 +0,0 @@
/*
* 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

@@ -1,67 +0,0 @@
/*
* 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

@@ -1,76 +0,0 @@
/*
* 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

@@ -1,71 +0,0 @@
/*
* 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

@@ -1,59 +0,0 @@
/*
* 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

@@ -1,49 +0,0 @@
/*
* 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

@@ -1,36 +0,0 @@
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

@@ -1,146 +0,0 @@
/*
* 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

@@ -1,82 +0,0 @@
/*
* 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

@@ -1,73 +0,0 @@
/*
* 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

@@ -1,130 +0,0 @@
/*
* 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

@@ -1,47 +0,0 @@

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

@@ -1,73 +0,0 @@
<?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

@@ -1,480 +0,0 @@
/*
* 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

@@ -1,36 +0,0 @@
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

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

View File

@@ -1,120 +0,0 @@
/*
* 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

@@ -1,199 +0,0 @@
/*
* 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

@@ -1,72 +0,0 @@
<?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

@@ -1,196 +0,0 @@
/*
* 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

@@ -1,129 +0,0 @@
/*
* 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

@@ -1,36 +0,0 @@
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

@@ -1,97 +0,0 @@
/*
* 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

@@ -1,119 +0,0 @@
/*
* 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

@@ -1,293 +0,0 @@
/*
* 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

@@ -1,105 +0,0 @@
/*
* 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

@@ -1,395 +0,0 @@
/*
* 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

@@ -1,121 +0,0 @@
/*
* 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

@@ -1,72 +0,0 @@
/*
* 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

@@ -1,86 +0,0 @@
/*
* 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

@@ -1,90 +0,0 @@
/*
* 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

@@ -1,118 +0,0 @@
/*
* 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

@@ -1,66 +0,0 @@
/*
* 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

@@ -1,91 +0,0 @@
/*
* 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

@@ -1,332 +0,0 @@
/*
* 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

@@ -1,242 +0,0 @@
/*
* 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

@@ -1,166 +0,0 @@
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

@@ -1,217 +0,0 @@
/*
* 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

@@ -1,298 +0,0 @@
<?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

@@ -1,94 +0,0 @@
<?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

@@ -1,51 +0,0 @@
/*
* 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

@@ -1,36 +0,0 @@
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

@@ -1,63 +0,0 @@
//------------------------------------------------------------------------------
// <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

@@ -1,117 +0,0 @@
<?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

@@ -1,26 +0,0 @@
//------------------------------------------------------------------------------
// <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

@@ -1,7 +0,0 @@
<?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

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

View File

@@ -1,131 +0,0 @@
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

@@ -1,345 +0,0 @@
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

@@ -1,333 +0,0 @@
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

@@ -1,127 +0,0 @@
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

@@ -1,67 +0,0 @@
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

@@ -1,770 +0,0 @@
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

File diff suppressed because it is too large Load Diff

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