3 Written by Saverio Proto <zioproto@gmail.com> and Claudio Pisa <clauz@ninux.org>.
5 This file is part of OLSR MDNS PLUGIN.
7 The OLSR MDNS PLUGIN is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 The OLSR MDNS PLUGIN is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Foobar. If not, see <http://www.gnu.org/licenses/>.
24 #ifndef _MDNS_PACKET_H
25 #define _MDNS_PACKET_H
29 #include <net/if.h> /* IFNAMSIZ, IFHWADDRLEN */
30 #include <sys/types.h> /* u_int8_t, u_int16_t */
32 /* BMF-encapsulated packets are Ethernet-IP-UDP packets, which start
33 * with a 8-bytes BMF header (struct TEncapHeader), followed by the
34 * encapsulated Ethernet-IP packet itself */
38 /* Use a standard Type-Length-Value (TLV) element */
41 u_int16_t reserved; /* Always 0 */
43 } __attribute__((__packed__));
45 #define ENCAP_HDR_LEN ((int)sizeof(struct TEncapHeader))
46 #define BMF_ENCAP_TYPE 1
47 #define BMF_ENCAP_LEN 6
53 } __attribute__((__packed__));
55 int IsIpFragment(unsigned char* ipPacket);
56 u_int16_t GetIpTotalLength(unsigned char* ipPacket);
57 unsigned int GetIpHeaderLength(unsigned char* ipPacket);
58 u_int8_t GetTtl(unsigned char* ipPacket);
59 void SaveTtlAndChecksum(unsigned char* ipPacket, struct TSaveTtl* sttl);
60 void RestoreTtlAndChecksum(unsigned char* ipPacket, struct TSaveTtl* sttl);
61 void DecreaseTtlAndUpdateHeaderChecksum(unsigned char* ipPacket);
62 struct ip* GetIpHeader(unsigned char* encapsulationUdpData);
63 unsigned char* GetIpPacket(unsigned char* encapsulationUdpData);
65 #endif /* _MDNS_PACKET_H */