Axel Lin
70ebeda7ed
memp: Simplify implementation of memp_overflow_check_all
...
We don't really care the order of overflow/underflow checking because if
any checking fails we got assertion.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-01-15 11:38:02 +01:00
Dirk Ziegelmeier
70487a43d4
Apply patch #8854 : dns: Simplify #ifdef guard around dns_gethostbyname_addrtype from Axel Lin
...
+ Minor compile fix from me
Patch makes the code a tiny bit less lightweight (add a parameter in dns_gethostbyname which is then not used in dns_gethostbyname_addrtype) but it makes the code more readable.
2016-01-13 19:52:08 +01:00
Axel Lin
a93ae2558f
tcp_rexmit_rto: Remove superfluous #if TCP_OVERSIZE guard
...
TCP_OVERSIZE_DBGCHECK already implies TCP_OVERSIZE is set.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-01-13 19:07:08 +01:00
Axel Lin
c2a74b767b
udp_bind: Omit checking for the same port if no port specified
...
No port specified means to use a random port.
udp_new_port() returns a new (free) local UDP port number on success.
So in this case we don't need iterating all lists to test if the port
number is used, udp_new_port() alreay ensures the port is not used.
Move the code checking for double bind and rebind of the same pcb earlier,
as this checking is necessary in all cases.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-01-13 09:05:36 +01:00
Dirk Ziegelmeier
123c8dbd6a
Fix bug #46837 Don't send dhcp_release message in dhcp_release function
2016-01-13 08:54:54 +01:00
Axel Lin
9f3aab6a62
tcp_out: Use LWIP_DBG_LEVEL_SERIOUS instead of hard coded number
...
Trivial clean up to avoid using hard coded number.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-01-11 13:22:51 +01:00
Axel Lin
156ad0dbf5
udp_bind: Fix the logic to check both pcbs have REUSEADDR set
...
The code for #if SO_REUSE case does not match the comment.
By default, we don't allow to bind to a port that any other udp
PCB is already bound to, unless *all* PCBs with that port have tha
REUSEADDR flag set.
Which means we want to omit checking for the same port if both pcbs
have REUSEADDR set. Fix the logic accordingly.
Fixes: d0348e0c60
("task #6995 : Implement SO_REUSEADDR (correctly)")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-01-11 12:19:13 +01:00
Axel Lin
5056d375f2
tcp_bind/tcp_connect: Omit checking for the same port if no port specified
...
No port specified means to use a random port.
tcp_new_port() returns a new (free) local TCP port number on success.
So in this case we don't need iterating all lists to test if the port
number is used, tcp_new_port() alreay ensures the port is not used.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-01-11 12:16:27 +01:00
Axel Lin
708beb4874
udp_bind: Allocate a random port earlier to correctly detect port conflict
...
Current code does not correctly detect port conflict if no port specified
because it checks ipcb->local_port == port before udp_new_port().
Fix it by allocating a random port earlier.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-01-09 10:14:09 +01:00
Joel Cunningham
a82c6122d5
Correct comment word usage in ip4_frag.c
...
This corrects word usage in ip4_frag.c:
* 'On' was used when it should have been 'one'
* 'Whole' was used when it should have 'hole'
2015-12-08 10:13:56 -06:00
Axel Lin
2e56f2d780
igmp: Optimize the implementation of igmp_start_timer
...
When LWIP_RAND is defined, calling LWIP_RAND() is not necessary if max_time <= 2
because group->timer will be set to 1 anyway.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-12-06 21:47:09 +01:00
Axel Lin
2562d637cd
tcp_out: Use LWIP_DBG_LEVEL_SERIOUS instead of magic number
...
Trivial clean up to avoid using magic number.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-12-06 21:38:12 +01:00
Axel Lin
a21144b834
memp: Fixup LWIP_HOOK_MEMP_AVAILABLE() hook
...
I got below build warning if LWIP_HOOK_MEMP_AVAILABLE is defined.
src/core/memp.c: In function 'memp_free_pool':
src/core/memp.c:352:16: warning: variable 'old_first' set but not used [-Wunused-but-set-variable]
struct memp *old_first;
^
src/core/memp.c: In function 'memp_free':
src/core/memp.c:413:6: warning: 'old_first' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (old_first == NULL) {
The LWIP_HOOK_MEMP_AVAILABLE() hook does not work, fix it.
Fixes: c838e1ed5b
("Implement possibility to declare private memory pools")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-12-05 21:32:14 +01:00
Axel Lin
7f92660598
icmp: Fix memory leak in icmp_input() error paths
...
Ensure the newly allocated packet buffer is freed in error paths.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-12-05 21:25:15 +01:00
Axel Lin
a709041b8b
Remove unnecessary p->len checking for pbuf_alloc calls with PBUF_RAM type
...
pbuf_alloc() for PBUF_RAM type always return big enough memory on success.
So checking p->len is not necessary. Testing if p is NULL or not is enough.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-12-05 21:21:59 +01:00
Axel Lin
bd4c4b5959
Use SYS_ARCH_SET macro at appropriate places
...
Use SYS_ARCH_SET to simplify the code a bit.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-12-02 22:51:08 +01:00
Axel Lin
fb6d0f9006
ipaddr_aton: Avoid duplicate code to handle IPv4 address string conversion
...
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-12-02 22:51:00 +01:00
Axel Lin
6e863ecb50
dns: Remove always true test in dns_alloc_random_port
...
The only way to exit the do-while loop is err != ERR_USE.
Thus get rid of the always true test.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-12-02 22:37:26 +01:00
Axel Lin
764bf251cd
igmp: Drop unneeded initialization for *group in igmp_lookup_group()
...
It's assigned to the return value of igmp_lookfor_group() immediately.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-12-02 22:32:50 +01:00
Axel Lin
91586bc6f6
Drop #if TCP_DEBUG guard around tcp_debug_print_state calls
...
The #if TCP_DEBUG guard can be removed because tcp_debug_print_state()
print nothing if !TCP_DEBUG.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-12-02 22:32:42 +01:00
Axel Lin
f971fb921e
Simplify testing minimum priority in tcp_kill_prio()
...
Simplify the code a bit by setting mprio = LWIP_MIN(TCP_PRIO_MAX, prio)
before the for loop.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-11-20 21:41:14 +01:00
Axel Lin
c730e45f0c
Trivial comment fix about calling tcp_slowtmr
...
Trivial typo fix.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-11-20 21:36:38 +01:00
Axel Lin
5c27429958
memp: Fix if MEMP_OVERFLOW_CHECK guard in memp_free_pool
...
Current code already checks memp_overflow_check_all() in memp_free() if
MEMP_OVERFLOW_CHECK >= 2. So in memp_free_pool(), it should use
MEMP_OVERFLOW_CHECK == 1 instead.
Fixes: c838e1ed5b
("Implement possibility to declare private memory pools")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-11-19 22:06:42 +01:00
Axel Lin
9c6708513a
Drop unnecessary NULL test for h->next->next in memp_sanity
...
The h will point to NULL if h->next->next is NULL anyway.
So remove the unnecessary NULL test for h->next->next in each iteration.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-11-19 07:23:55 +01:00
Axel Lin
21b9b5e741
Slightly improve raw_remove()/udp_remove() implementation
...
There should be no duplicate pcb in raw_pcbs/udp_pcbs list.
So the implementation of raw_remove()/udp_remove() can break from the for
loop once the target pcb is found and removed from the list.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-11-19 07:21:00 +01:00
goldsimon
98b9d31f24
Fixed compiling with LWIP_TCP==0
2015-11-16 09:37:56 +01:00
Axel Lin
668d461104
dns: Fix dns_alloc_pcb for reuse an existing one case
...
The logic to use an already existing pcb is wrong because the idx never
advanced in the for loop, so it keep checking the same dns_pcbs[idx] for
each loop iteration. Fix it.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2015-11-16 09:09:31 +01:00
Dirk Ziegelmeier
6203737093
Rename snmp_mib2.h to snmp.h so source compatibility for user netif implementations is preserved
2015-11-12 21:25:42 +01:00
Dirk Ziegelmeier
5f642eb3e3
Completely decouple SNMP stack from lwIP core by using private memory pools;
...
Move SNMP stack to apps;
API breaking change: Users need to call snmp_init() now!
2015-11-12 21:21:14 +01:00
goldsimon
92a241a29e
Fixed bug #46365 : tcp_accept_null() should call tcp_abort()
2015-11-12 10:40:49 +01:00
Dirk Ziegelmeier
c838e1ed5b
Implement possibility to declare private memory pools. This is useful to decouple some apps from the core (SNMP stack) or make contrib app useage simpler (httpserver_raw) .
2015-11-12 08:45:04 +01:00
Dirk Ziegelmeier
d38db89626
Export tcp_pcb_lists from tcp.c - can be used in SNMP code to implement MIB2 tcp connection tables
2015-11-12 08:09:44 +01:00
Dirk Ziegelmeier
3f0b1e2cdc
Remove global variable used in macros, it can be declared locally.
2015-11-12 08:07:22 +01:00
sg
c12fa7b4c4
started to move "private" header files containing implementation details to "lwip/priv/" include directory to seperate the API from the implementation.
2015-10-09 21:58:58 +02:00
sg
b32751a693
moved dhcp.c to src/core/ipv4/ since it is IPv4 only
2015-10-09 21:06:08 +02:00
goldsimon
65efeec4e9
fixed bug #46145 tcp_send_empty_ack() uses wrong netif with LWIP_HOOK_IP4_ROUTE_SRC (patch by Milan Cermak)
2015-10-07 14:56:25 +02:00
goldsimon
15bb334e81
SNMP: use PBUF_RAM for sending, PBUF_POOL is mostly used for RX only (if this isn't followed, tcp can get stuck when ACKs don't come through - unless some PBUF_POOL pbufs are reserved for such RX)
2015-10-07 10:41:03 +02:00
goldsimon
77f906376e
minor: fixed coding style (lwip style)
2015-10-07 10:36:50 +02:00
goldsimon
9b22f167f1
minor: mib2: removed some blocks by defining common variables above the switch
2015-10-07 10:13:20 +02:00
goldsimon
b401f42520
minor: fixed coding style (lwip style)
2015-10-07 10:03:12 +02:00
goldsimon
2949449e25
minor: SNMP: fixed coding style (lwip style)
2015-10-07 10:01:23 +02:00
sg
2b971400fa
minor: coding style
2015-10-06 21:57:40 +02:00
sg
22df34fc70
minor/coding style: removed spaces before line ending (from file header)
2015-10-06 21:13:15 +02:00
sg
490581a0eb
minor/coding style: removed spaces before line ending
2015-10-06 21:08:28 +02:00
goldsimon
0737cfb84e
Fixed bug #46128 (patch by Kerem Hadimli)
2015-10-06 12:42:25 +02:00
Erik Ekman
f80d0dab08
Remove old comments about DHCP setting netif up
2015-10-03 21:31:48 +02:00
sg
fb1ac8d766
snmp mib2: more const
2015-10-03 20:34:56 +02:00
Dirk Ziegelmeier
bc47bd28ab
snmp mib2: more nodes can be const
2015-10-03 20:34:09 +02:00
Dirk Ziegelmeier
5cf4771397
snmp: eliminiate mib_ram_array_node (it is not necessary: to the agent, the nodes may be const since the actual mib implementation knows the structures behind the nodes which do not have to be const)
2015-10-03 20:27:49 +02:00
sg
8891b277c6
snmp: hopefully fixed all alignment warnings introduced today. unfortunately, gcc does not warn about them when compiling for x86
2015-10-02 21:59:40 +02:00
goldsimon
e4abd4234d
removed comma before }
2015-10-02 13:26:11 +02:00
goldsimon
fe33fd6d86
snmp: cleaned up mib_* structs: "base" class 'struct mib_node' only needs the type, get/set functions are not used on array/external nodes (only on scalar/listroot nodes)
2015-10-02 12:33:45 +02:00
goldsimon
bf75ace695
snmp: combine oid and node pointers in array entries
2015-10-02 10:53:17 +02:00
goldsimon
180ed573a5
snmp_trap_dst_ip_set: ip_addr_t pointer can be const
2015-10-02 09:58:31 +02:00
goldsimon
a9b6b5b704
adapt init.c to moved declaration of snmp_init
2015-10-02 09:57:15 +02:00
goldsimon
30445712a5
snmp: make mib_scalar_node a "derived" struct like all other nodes
2015-10-02 09:56:00 +02:00
sg
3312983b27
Make LWIP_DNS_SECURE and its possible values known in opt.h, remove default initialization of DNS server
2015-10-01 21:38:39 +02:00
sg
fecd1bde83
ip4_route: fixed checking twice for a valid default_netif, fixed checking loopback traffic before checking for a valid default netif
2015-10-01 21:17:59 +02:00
goldsimon
0176e03e36
mib2: one more '};' -> '}'
2015-10-01 10:21:52 +02:00
Dirk Ziegelmeier
9957cd4a2a
fixed bug #46089 : snmp: race condition on length change between get_object_def() and get_value()
2015-10-01 10:08:23 +02:00
Dirk Zigelmeier
3f4d75c8d6
netif_get_ip6_addr_match/netif_add_ip6_address must take a const ip6addr to be usable
2015-09-30 20:55:08 +02:00
Dirk Ziegelmeier
7962b21c00
snmp: fixed ugly inheritance implementation by aggregating the "base class" (struct mib_node) in all derived node classes to get more type-safe code
2015-09-30 17:54:25 +02:00
goldsimon
59002d5081
mib2: only export 'internet', all other variables can be static
2015-09-30 17:42:19 +02:00
goldsimon
ce883d2041
minor: mib2.c: sys_tem_* -> system_* for everything but 'sys_tem' (without suffix)
2015-09-30 17:39:32 +02:00
goldsimon
96847c1199
snmp: added helper functions to encode/decode BITS pseudo type, added define for Counter64 type, minor layout changes
2015-09-30 17:24:53 +02:00
goldsimon
df1f12778f
snmp: moved noleafs_get/set functions from mib2.c to mib_structs.c, where they belong
2015-09-30 17:19:08 +02:00
goldsimon
dff234112b
minor: removed superfluous comma after '}' in mib2.c; removed superfluous comment on get-functions that follow a function typedef
2015-09-30 17:13:05 +02:00
goldsimon
e18e08ff08
minor: removed superfluous comma after '}' in msg_out.c
2015-09-30 17:09:04 +02:00
goldsimon
f3ed562983
minor: removed superfluous comma after '}' in dns.c
2015-09-30 17:01:57 +02:00
goldsimon
969fb4c981
minor: removed some trailing spaces in tcp.c
2015-09-30 17:00:57 +02:00
Erik Ekman
82fcc307ef
mld6: Simplify join/leavegroup()
...
Use netif_get_ip6_addr_match() helper to shorten the code.
2015-09-30 16:35:15 +02:00
goldsimon
1fdab5ac0e
Added/changed header of dhcp.c/.h
2015-09-30 16:33:48 +02:00
goldsimon
389831218e
Finished task #13731 : fix usage of "snmp_inc_*"
2015-09-30 15:54:43 +02:00
goldsimon
7b5ef3ae58
implement/remove missing IP counters in stats_mib2 (see task #13731 )
2015-09-30 15:05:52 +02:00
goldsimon
9d28549f32
minor: fixed coding style in mld6.c
2015-09-30 14:48:25 +02:00
Erik Ekman
6cdea62638
Add functions to join/leave v6 multicast group by netif
...
Existing functions are based on IP address, but the address is used
only to look up which netif to act on. The netif-based core code is
extracted to new exported functions.
If you have a netif handle, this makes it easier to join/leave
groups, without the need to convert to IP address first only for the
mld6 code to convert back to netif.
2015-09-30 14:44:45 +02:00
goldsimon
3dd0977635
minor: fixed coding style in igmp.c
2015-09-30 14:37:37 +02:00
Erik Ekman
ba71ac78d9
Add functions to join/leave IGMP group by netif
...
Existing functions are based on IP address, but the address is used
only to look up which netif to act on. The netif-based core code is
extracted to new exported functions.
If you have a netif handle, this makes it easier to join/leave
groups, without the need to convert to IP address first only for the
IGMP code to convert back to netif.
2015-09-30 14:29:37 +02:00
goldsimon
373714c02f
dns: improved handling 2nd server if first failed
2015-09-30 14:22:39 +02:00
goldsimon
927b72abd2
fixed bug #46072 : ip4addr_aton() does not check the number range of all address parts
2015-09-30 14:15:36 +02:00
goldsimon
f89e859415
minor: fixed coding style in ip4addr_aton()
2015-09-30 14:13:05 +02:00
goldsimon
dae73e21b8
minor: fixed coding style in ip4addr_aton()
2015-09-30 14:11:50 +02:00
goldsimon
f950bf4362
ipaddr_aton(): favour ':' over '.' to decide for IPv6 first (since IPv6 mapped IPv4 addresses might contain both ':' and '.')
2015-09-30 14:06:44 +02:00
goldsimon
0621e8d1b1
ip6addr_aton(): fail on three successive colons in an IPv6 address string
2015-09-30 14:05:13 +02:00
goldsimon
5a185a0fbd
minor: fixed coding style in ip6addr_aton()
2015-09-30 13:55:09 +02:00
goldsimon
45fd622491
Fixed bug #46071 Logic error in line 1473 in dns.c
2015-09-30 13:36:13 +02:00
goldsimon
94625a8fa8
MIB2_STATS: moved netif related mib2 counters into a struct (defined in stats.h), added ifInErrors/ifInUnkownProtos (now handled in etharp.c) and ifOutErrors
2015-09-28 08:50:21 +02:00
goldsimon
bc30899168
fixed compiler warnings where passing variable instance to ip_addr_isany
2015-09-28 07:56:52 +02:00
sg
bb91bd2279
fixed coding style: use more ()
2015-09-24 21:04:20 +02:00
Sylvain Rochet
8b2c73de4e
ip4: routing: check peer for point to point interfaces
...
gw netif field for point to point interfaces is the peer IP address.
Check if the destination is equals to the gw field of point to point
interfaces (broadcast flag is not set) when routing an IP packet.
2015-09-24 21:01:52 +02:00
goldsimon
b0917d987a
Cleaned up using struct netif.ip_addr by creating API functions for it
2015-09-24 14:57:16 +02:00
goldsimon
99d2e5233d
struct udp_pcb.multicast_ip must be an ip_addr_t, too, to completely avoid temporary storage
2015-09-24 14:55:55 +02:00
goldsimon
c71723101a
Removed ip_2_ip4/6_c const macros again now that ip_2_ip4/6 macros keep the original const'ness
2015-09-24 14:38:52 +02:00
goldsimon
262a641396
eliminate temporary storage when using netif addresses for ip_addr_t* now that they have the correct type (ATTENTION: ip6_select_source_address() and ip4_netif_get_local_ip() now return ip_addr_t*!)
2015-09-24 14:34:24 +02:00
goldsimon
4d2f4ce78c
udp: don't use ip4_2_ip() where not required
2015-09-24 10:39:13 +02:00
goldsimon
ed4130bd2f
Fixed const errors after changing netif_ip4_addr/netif_ip6_addr to return cont pointers
2015-09-24 08:06:50 +02:00
goldsimon
0fbdd5e56e
fixed compiling LWIP_HAVE_LOOPIF after changing struct netif.ip6_addr to ip_addr_t
2015-09-24 07:58:29 +02:00
sg
db76671d4d
task #13729 : Convert netif addresses (IPv4 & IPv6) to ip_addr_t (so they can be used without conversion/temporary storage)
2015-09-23 22:09:37 +02:00
sg
f36adac8ab
fixed compiling udp.c for IPv6-only
2015-09-23 22:07:14 +02:00
sg
121268d320
Added ip_addr_set_zero_ip4() to explicitly set the type to IPv4 for dual-stack
2015-09-23 21:56:34 +02:00