The address family of the UDP port listener was not set. This
caused weird debug prints in net-shell. Now the listener will
be registering IPv4 any address as it should.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
When a connection handler was registered, the checker function
introduced in commit 43b37cef ("Check duplicate UDP/TCP connection
handlers") did not check the address family (IPv4 or IPv6) of
the local end point properly. This caused duplicate connection
error to be returned to the caller.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The uncompressed source address in packets was not handled properly if
NET_6LO_CONTEXT was enabled.
This implementation is identical to the contextless case.
Signed-off-by: Piotr Zierhoffer <pzierhoffer@antmicro.com>
If we do not receive last ACK when the connection is tore down,
then do not wait forever as that would eat all the resources in
the network stack. So when we enter the LAST_ACK state, we setup
a timer that will unref the connection if the last ACK is not
received.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Without change to add ACK to FIN, invalid TCP packet is generated,
where ack sequence number is non-zero. Without adjusting sequence
number as done, ACK which we send in response to peer's FIN/ACK is
not recognized by peer, and peer keeps retransmitting its FIN/ACK.
Jira: ZEP-2104
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
When connection handler was unregistered, we did not remove
it from cache. This caused invalid connection to be passed to
net_context after connection unregister if connection caching
was enabled.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
We did not check UDP or TCP checksum to be valid after receiving
the packet. Fix this so that the checksum is validated when
packet is received in connection handler. As the checksum validation
can be resource intensive, do it after we have verified that
there is a connection handler for this connection.
The checksum calculation can be turned OFF if needed, but it is
ON by default.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The commit "net: tcp: Handle retransmitted packets from peer"
introduced over 80 character line that was missed in review.
Fixing it now.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If user has enabled RPL and STATISTICS, then enable RPL
statistics by default as that is probably what user want.
Same thing for MLD statistics.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
When we receive a packet with the sequence we already seen (and
processed), the most likely cause of it is that our ACK was lost,
and peer has to retransmit that packet. Then, we should just ACK
it, because otherwise peer will retransmit it again and again,
falling into exponential backoff and hosing the entire TCP
connection.
This makes changes to send_ack(), adding a flag to force sending
an ACK regardless of its cached status, and remove inline modifier,
as the function is big and called from many places.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
We must check if we receive RST in any of the TCP states.
If we do not do this, then the net_context might leak as it
would never be released in some of the states. Receiving RST
in any TCP state is not described in TCP state diagram but is
described in RFC 793 which says in chapter "Reset Processing"
that system "...aborts the connection and advises the user and
goes to the CLOSED state."
We need to also validate the received RST and accept only those
TCP reset packets that contain valid sequence number.
The validate_state_transitions() function is also changed to
accept CLOSED state transition from various other states.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
With the support for 2M PHY added, the controller can now Rx/Tx
upto 18/19 minimum sized L2CAP packets per 7.5ms connection
intervals.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
net_if_get_default() was documented as returning "Default interface
or NULL if no interfaces are configured.", but actually didn't
return NULL in the latter case. Instead, it effectively returned
a pointer to random area of memory, shared with other system
structures, so calling functions like net_if_ipv4_set_netmask(),
etc. could trash unrelated memory.
Jira: ZEP-2105
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
RFC793, "Transmission Control Protocol", defines sequence numbers
just as 32-bit numbers without a sign. It doesn't specify any adhoc
rules for comparing them, so standard modular arithmetic should be
used.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
To better debug the flow of events into the Host, log the subevent code
whenever processing an LE Meta Event.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
When required Rx MTU is less than configured Rx MPS, the
resultant initial credits was 0 which prevented any L2CAP
packet to be received.
Fixed by ceiling the initial credits count in the credits
calculation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This places a sentinel value at the lowest 4 bytes of a stack
memory region and checks it at various intervals, including when
servicing interrupts or context switching.
This is implemented on all arches except ARC, which supports stack
bounds checking directly in hardware.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Sometime it is observed on the Arduino 101 that when we write more than
4 bytes into TX USB Endpoint, first 4 bytes are getting repeated
(frequency of occurrence ~1/3000).
This patch does following :-
1. In sample application "cdc_acm", it adds capability to
handle partial transfer data incase data is transferred partially
if exceeds maximum data transfer size.
2. It restricts write of more than 4 bytes into TX USB Endpoint.
This is work around to avoid issue occarance.
Jira: ZEP-2074
Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit creates a HTTP server library. So instead of creating
a complex HTTP server application for serving HTTP requests, the
developer can use the HTTP server API to create HTTP server
insteances. This commit also adds support for creating HTTPS servers.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
When a new UDP or TCP connection handler is to be registered,
we need to check if identical handler has already been created.
If a duplicate is found, the registering call will return -EALREADY.
The earlier code did not check this but allowed two identical
handlers to be created. The latter handler was never called in
this case.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This helper copies desired amount of data from network packet
buffer info a user provided linear buffer.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
To be consistent with other subsystem menu, use menu for
Bluetooth support in Kconfig instead of menuconfig which
showed up as checkbox.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
To allow for hci_uart builds that do not include the controller code,
move the UART Kconfig option used by the sample up one level so that it
is shared by all configurations using Bluetooth:
Jira: ZEP-2132
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Since more and more code is going to be reused by both the Host and the
Controller, this commit introduces a common/ folder that will contain
everything that is not tied to one of the two components but shared by
them.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This reverts commit 698de88916 ("Bluetooth: controller:
Cleanup redundant ticker busy loop")
Scan enable asserted in ctrl.c line 3756 due to the fact that a
role event was active and ticker job has hence been disabled.
Add back the busy loop so that scan enable can wait until the
active role event completes gracefully.
The ticker busy loop is mandatory in all ticker interface calls
if a blocking behavior is desired.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The calculation in packet_rx_reserve_get() was already handled by
packet_rx_acquired_count_get(). So, let's use that code instead
and remove the duplication.
Change-Id: Ic76f70f1e78bebc74f5bef36cd92a3c332e489e9
Signed-off-by: Michael Scott <michael.scott@linaro.org>
This calculation can be used in packet_rx_reserve_get() where currently
the code is duplicated from packet_rx_acquired_count_get().
Let's allow use of packet_rx_acquired_count_get() regardless of whether
CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH is enabled.
Change-Id: I613bde0a407f3caccabb22f369098575965e98ad
Signed-off-by: Michael Scott <michael.scott@linaro.org>
During testing, lr->max_rx_octets and lr->max_tx_octets were
at times set to 0. If we use these 0 values, we end up with
very erratic behavior. Best, to check for a sane value and
if invalid, default to the value in _radio.conn_curr->max_*x_octets.
Change-Id: I57c0e3790d988f0de17993cebe5c5c2ab0fc07a6
Signed-off-by: Michael Scott <michael.scott@linaro.org>
When Controller to Host flow control is enabled, output informational
messages for certain operations to help tune and debug the feature.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Since the HCI driver debug option applies to both files in
drivers/bluetooth and subsys/bluetooth, the configuration option itself
now lives in the top-level Kconfig file for consistency.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Added implementation to auto-update Bluetooth PHY to 2Mbps
if the local Controller supports it.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added support for Bluetooth v5.0 PHY Update Procedure in the
Controller.
Asymmetric PHY connections do not work for now due to the
Radio mode not being setup in time in the ISR during tIFS
period and the Radio already ramping up in the cached
previous Radio mode to meet tIFS deadline.
Subsequent commits will add this feature, by either double
buffering the mode in software or using fast radio ramp up
which gives enough time in the ISR to change the mode.
Jira: ZEP-2086
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Scale the ctrl pkt enqueue implementation to allow multiple
ctrl packets to be enqueued. This will aid in the graceful
implementation of parallel control procedure collisions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added HCI macros to check LE Features. Also, added test
macros for 2M and Coded PHY support in HCI Controller.
Earlier a common test macro was used between BR/EDR and LE,
but since LE features do not use pages for feature, an
explicit macro for testing LE feature is added now.
Also, features field in LE device structure is now a single
dimension array of 8 octets.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The APIs for allocating RX buffers were modified recently and hci_raw
had not reflected those changes properly.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>