2016-06-27 17:25:57 +08:00
|
|
|
/** @file
|
|
|
|
@brief IPv4 related functions
|
|
|
|
|
|
|
|
This is not to be included by the application.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Intel Corporation
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-06-27 17:25:57 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __IPV4_H
|
|
|
|
#define __IPV4_H
|
|
|
|
|
Introduce new sized integer typedefs
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t. This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.
We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.
We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.
Jira: ZEP-2051
Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-19 23:32:08 +08:00
|
|
|
#include <zephyr/types.h>
|
2016-06-27 17:25:57 +08:00
|
|
|
|
|
|
|
#include <net/net_ip.h>
|
2017-04-03 23:14:35 +08:00
|
|
|
#include <net/net_pkt.h>
|
2016-06-27 17:25:57 +08:00
|
|
|
#include <net/net_if.h>
|
|
|
|
#include <net/net_context.h>
|
|
|
|
|
|
|
|
#include "ipv4.h"
|
|
|
|
|
2016-11-13 01:53:38 +08:00
|
|
|
/**
|
2017-04-05 14:37:44 +08:00
|
|
|
* @brief Create IPv4 packet in provided net_pkt.
|
2016-11-13 01:53:38 +08:00
|
|
|
*
|
2017-04-05 14:37:44 +08:00
|
|
|
* @param pkt Network packet
|
2016-11-13 01:53:38 +08:00
|
|
|
* @param src Source IPv4 address
|
|
|
|
* @param dst Destination IPv4 address
|
|
|
|
* @param iface Network interface
|
|
|
|
* @param next_header Protocol type of the next header after IPv4 header.
|
|
|
|
*
|
2018-07-25 20:44:30 +08:00
|
|
|
* @return Return network packet that contains the IPv4 packet or NULL if
|
|
|
|
* network packet could not be allocated.
|
2016-11-13 01:53:38 +08:00
|
|
|
*/
|
2018-06-29 16:33:56 +08:00
|
|
|
struct net_pkt *net_ipv4_create(struct net_pkt *pkt,
|
|
|
|
const struct in_addr *src,
|
|
|
|
const struct in_addr *dst,
|
|
|
|
struct net_if *iface,
|
|
|
|
u8_t next_header_proto);
|
2016-11-13 01:53:38 +08:00
|
|
|
|
2016-06-27 17:25:57 +08:00
|
|
|
/**
|
|
|
|
* @brief Finalize IPv4 packet. It should be called right before
|
|
|
|
* sending the packet and after all the data has been added into
|
|
|
|
* the packet. This function will set the length of the
|
|
|
|
* packet and calculate the higher protocol checksum if needed.
|
|
|
|
*
|
2017-04-05 14:37:44 +08:00
|
|
|
* @param pkt Network packet
|
2018-06-29 16:33:56 +08:00
|
|
|
* @param next_header_proto Protocol type of the next header after IPv4 header.
|
2016-06-27 17:25:57 +08:00
|
|
|
*
|
|
|
|
*/
|
2018-07-23 20:34:15 +08:00
|
|
|
void net_ipv4_finalize(struct net_pkt *pkt, u8_t next_header_proto);
|
2016-06-27 17:25:57 +08:00
|
|
|
|
|
|
|
#endif /* __IPV4_H */
|