2017-04-02 22:45:14 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* net/utils/net_udpchksum.c
|
|
|
|
*
|
2021-02-19 12:45:37 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2017-04-02 22:45:14 +02:00
|
|
|
*
|
2021-02-19 12:45:37 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2017-04-02 22:45:14 +02:00
|
|
|
*
|
2021-02-19 12:45:37 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2017-04-02 22:45:14 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
#include <nuttx/net/netdev.h>
|
|
|
|
|
|
|
|
#include "utils/utils.h"
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_UDP
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: udp_ipv4_chksum
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Calculate the UDP/IPv4 checksum of the packet in d_buf and d_appdata.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#if defined(CONFIG_NET_UDP_CHECKSUMS) && defined(CONFIG_NET_IPv4)
|
|
|
|
uint16_t udp_ipv4_chksum(FAR struct net_driver_s *dev)
|
|
|
|
{
|
|
|
|
return ipv4_upperlayer_chksum(dev, IP_PROTO_UDP);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: udp_ipv6_chksum
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Calculate the UDP/IPv6 checksum of the packet in d_buf and d_appdata.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#if defined(CONFIG_NET_UDP_CHECKSUMS) && defined(CONFIG_NET_IPv6)
|
|
|
|
uint16_t udp_ipv6_chksum(FAR struct net_driver_s *dev)
|
|
|
|
{
|
2018-11-05 15:56:07 +01:00
|
|
|
return ipv6_upperlayer_chksum(dev, IP_PROTO_UDP, IPv6_HDRLEN);
|
2017-04-02 22:45:14 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* CONFIG_NET_UDP */
|