Webserver+3d print
Embed:
(wiki syntax)
Show/hide line numbers
ip.h
Go to the documentation of this file.
00001 /** 00002 * @file ip.h 00003 * @brief IPv4 and IPv6 common routines 00004 * 00005 * @section License 00006 * 00007 * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved. 00008 * 00009 * This file is part of CycloneTCP Open. 00010 * 00011 * This program is free software; you can redistribute it and/or 00012 * modify it under the terms of the GNU General Public License 00013 * as published by the Free Software Foundation; either version 2 00014 * of the License, or (at your option) any later version. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with this program; if not, write to the Free Software Foundation, 00023 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00024 * 00025 * @author Oryx Embedded SARL (www.oryx-embedded.com) 00026 * @version 1.7.6 00027 **/ 00028 00029 #ifndef _IP_H 00030 #define _IP_H 00031 00032 //Dependencies 00033 #include "ipv4/ipv4.h" 00034 #include "ipv6/ipv6.h" 00035 00036 00037 /** 00038 * @brief IP supported protocols 00039 **/ 00040 00041 typedef enum 00042 { 00043 IP_PROTOCOL_TCP = 6, 00044 IP_PROTOCOL_UDP = 17 00045 } IpProtocol; 00046 00047 00048 /** 00049 * @brief IP network address 00050 **/ 00051 00052 typedef struct 00053 { 00054 size_t length; 00055 union 00056 { 00057 #if (IPV4_SUPPORT == ENABLED) 00058 Ipv4Addr ipv4Addr; 00059 #endif 00060 #if (IPV6_SUPPORT == ENABLED) 00061 Ipv6Addr ipv6Addr; 00062 #endif 00063 }; 00064 } IpAddr; 00065 00066 00067 /** 00068 * @brief IP pseudo header 00069 **/ 00070 00071 typedef struct 00072 { 00073 size_t length; 00074 union 00075 { 00076 #if (IPV4_SUPPORT == ENABLED) 00077 Ipv4PseudoHeader ipv4Data; 00078 #endif 00079 #if (IPV6_SUPPORT == ENABLED) 00080 Ipv6PseudoHeader ipv6Data; 00081 #endif 00082 uint8_t data[4]; 00083 }; 00084 } IpPseudoHeader; 00085 00086 00087 //IP related constants 00088 extern const IpAddr IP_ADDR_ANY; 00089 extern const IpAddr IP_ADDR_UNSPECIFIED; 00090 00091 //IP related functions 00092 error_t ipSendDatagram(NetInterface *interface, IpPseudoHeader *pseudoHeader, 00093 NetBuffer *buffer, size_t offset, uint8_t ttl); 00094 00095 error_t ipSelectSourceAddr(NetInterface **interface, 00096 const IpAddr *destAddr, IpAddr *srcAddr); 00097 00098 uint16_t ipCalcChecksum(const void *data, size_t length); 00099 uint16_t ipCalcChecksumEx(const NetBuffer *buffer, size_t offset, size_t length); 00100 00101 uint16_t ipCalcUpperLayerChecksum(const void *pseudoHeader, 00102 size_t pseudoHeaderLength, const void *data, size_t dataLength); 00103 00104 uint16_t ipCalcUpperLayerChecksumEx(const void *pseudoHeader, 00105 size_t pseudoHeaderLength, const NetBuffer *buffer, size_t offset, size_t length); 00106 00107 NetBuffer *ipAllocBuffer(size_t length, size_t *offset); 00108 00109 error_t ipJoinMulticastGroup(NetInterface *interface, const IpAddr *groupAddr); 00110 error_t ipLeaveMulticastGroup(NetInterface *interface, const IpAddr *groupAddr); 00111 00112 bool_t ipIsUnspecifiedAddr(const IpAddr *ipAddr); 00113 00114 error_t ipStringToAddr(const char_t *str, IpAddr *ipAddr); 00115 char_t *ipAddrToString(const IpAddr *ipAddr, char_t *str); 00116 00117 #endif 00118
Generated on Tue Jul 12 2022 17:10:13 by
