As we are removing net_app and net_pkt based libraries and
applications, CoAP legacy based libraries and apps are moved
to socket based implementations. So removing legacy CoAP.
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
In case of Ethernet, if the requested size is larger than MTU and if
AF_UNSPEC is provided, the allocator will need to take into account
the ethernet header size which is not accounted in the MTU.
Other current L2 do not follow that rule as their MTU is based on IP
one (IPv6 most of the time). What they declare as MTU is the full frame
size they handle (minus the FCS for instance in 15.4). So with
AF_UNSPEC, such assumption on L2 header size is unrelevant.
(On 15.4 the header size is variable anyway and cannot be known until
the frame is parsed).
Fixes#12982
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This was forgotten modification as commit 93e5181fbd came in master
though commit 0d519f7bcf was already written.
Thus fixing the missing lock/unlock.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
If status is 0, both ip_hdr and proto_hdr will own a pointer to the
relevant IP and Protocol headers. In order to know which of ipv4/ipv6
and udp/tcp one will need to use respectively net_pkt_family(pkt) and
net_context_get_ip_proto(context).
Having access to those headers directly, many callbacks will not need
to parse the packet again no get the src/dst addresses or the src/dst
ports. This will be change after this commit.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Though these are currently used by the core only, it will be then used
by net_context as well. This one of the steps to get rid of net_pkt's
appdata/appdatalen attributes.
Also normalizing all ip/proto parameters name to ip_hdr and proto_hdr.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Now that net_pkt are accessed through a common r/w API, using below a
net_pkt_cursor, let's have an option that will reset this cursor once
the net_pkt is freed.
Result is instead of segfaulting on r/w access, these operations will
bail out properly. Subsequent, and logical (unless you have a leak
which is another issue) net_pkt_unref will tell you who/where the pkt
was freed. Without it, you will get a segfault for instance, but that
won't tell you the exact reason. This options can help you then.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Only next to be removed functions like net_tcp_set_checksum() are left
untouched. All the rest is switched.
Adding net_tcp_finalize() to follow the same logic as for UDP and else.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This proovse to drastically reduce runtime overhead as it does not need
to parse IP nor TCP header all over again in a lot of places.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
As these were parsed already by IPv4/6 input functions let's use them.
Applying the change on trivial UDP usage. TCP usage will have its own
commit.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
These will be specifically needed in TCP, as well as being used in
context internally.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Since the rework of L2/L3 split, only L2 has access to its header. Thus
up to Ethernet one to set LLDP PTYPE.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This optimizes the memory quite a bit since we do not need to clone nor
split the original packet at any time.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Most of the code had to be reworked due to the new API: it's more
logical to do everything sequentially (first headers, then MLD part)
than the contrary with inserting headers at the end.
Using get_data/set_data as well it makes the code clearer.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Also, return a verdict instead of a pointer to net_pkt. It's simpler as
it will be up to net_send_data()'s caller to unref the net_pkt in case
of NET_DROP: less places where net_pkt can be unref.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Reworking the logic to reduce the amount of variables.
Introducing a generic struct to acces the common part of MLD queries,
instead of accessing part by part.
Also, returning NET_OK in case parsing went fine. We send an MLD report
anyway, so it's not a good idea to count the message as being dropped in
statistics.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Reworking the logic to reduce the amount of variables.
This part was heavier to change as it was not accessing the headers
directly but instead was read parts by parts.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Reworking the logic to reduce the amount of variables.
Also taking the opportunity to normalize drop messages.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
In nbr part, this is a useful information. Since net_icmpv6_input has
already parsed the icmpv6 header, let's get pass it, instead of
retrieving/parsing it again in various handler functions.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
And let's use net_ipv6_create, net_icmpv6_create, net_ipv6_finalize to
factorize the code better.
Removing useless setup_headers private function now.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
And let's use net_ipv6_create, net_icmpv6_create, net_ipv6_finalize to
factorize the code better.
De-clutter the code by reordering where src/dst are evaluated.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
And let's use net_ipv6_create, net_icmpv6_create, net_ipv6_finalize to
factorize the code better.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Unlike before, we allocate a new packet for the reply which is a
modified clone of the request.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This is meant to remove the need for macro NET_IPV6_HDR(), since we
don't know in future if accessing the header that way will be valid.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Use the new net_pkt API to proceed through IPv6 header and all the
extension header as well.
Use udp/tcp input functions relevantly, and call net_conn_input
afterwards.
Note: This commit temporarly disable IPv6 fragmentation support
in the code directly. Which support will be re-enabled afterwards.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This is pretty much the same as in ICMPv4. Actually, when it comes to
the ICMP header, it could probably be put in a common places for both
ICMPv4 and ICMPv6.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Extension headers are specific and use nexthdr attribute from net_pkt.
next_header_proto is the user protocol (if any) that might require
finalization too (calculating the checksum).
However, if there are extension header, we need to skip those and jump
to the position where the user protocol starts.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Also, store the actual next_hdr value and not it's position.
This permits to reduce net_pkt from some bytes.
Such field was unused until now, but it will be soon.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This API is meant to work with pre-allocated net_pkt.
It assumes net_pkt's buffer cursor is at the right position where to
create the IPv6 header. Once done, the cursor will be placed right
after the newly created IPv6 header.
Finalizing assumes the same.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Function names will be normalized then by the couple create/finalize.
This one only sets the checksum.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Verifying udp/tcp checksum should be done before calling this function.
Also, up to ipv4 and ipv6 to provide a pointer to their respective
header.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>