Webserver+3d print
cyclone_tcp/ipv6/mld.h@0:8918a71cdbe9, 2017-02-04 (annotated)
- Committer:
- Sergunb
- Date:
- Sat Feb 04 18:15:49 2017 +0000
- Revision:
- 0:8918a71cdbe9
nothing else
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sergunb | 0:8918a71cdbe9 | 1 | /** |
Sergunb | 0:8918a71cdbe9 | 2 | * @file mld.h |
Sergunb | 0:8918a71cdbe9 | 3 | * @brief MLD (Multicast Listener Discovery for IPv6) |
Sergunb | 0:8918a71cdbe9 | 4 | * |
Sergunb | 0:8918a71cdbe9 | 5 | * @section License |
Sergunb | 0:8918a71cdbe9 | 6 | * |
Sergunb | 0:8918a71cdbe9 | 7 | * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved. |
Sergunb | 0:8918a71cdbe9 | 8 | * |
Sergunb | 0:8918a71cdbe9 | 9 | * This file is part of CycloneTCP Open. |
Sergunb | 0:8918a71cdbe9 | 10 | * |
Sergunb | 0:8918a71cdbe9 | 11 | * This program is free software; you can redistribute it and/or |
Sergunb | 0:8918a71cdbe9 | 12 | * modify it under the terms of the GNU General Public License |
Sergunb | 0:8918a71cdbe9 | 13 | * as published by the Free Software Foundation; either version 2 |
Sergunb | 0:8918a71cdbe9 | 14 | * of the License, or (at your option) any later version. |
Sergunb | 0:8918a71cdbe9 | 15 | * |
Sergunb | 0:8918a71cdbe9 | 16 | * This program is distributed in the hope that it will be useful, |
Sergunb | 0:8918a71cdbe9 | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
Sergunb | 0:8918a71cdbe9 | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Sergunb | 0:8918a71cdbe9 | 19 | * GNU General Public License for more details. |
Sergunb | 0:8918a71cdbe9 | 20 | * |
Sergunb | 0:8918a71cdbe9 | 21 | * You should have received a copy of the GNU General Public License |
Sergunb | 0:8918a71cdbe9 | 22 | * along with this program; if not, write to the Free Software Foundation, |
Sergunb | 0:8918a71cdbe9 | 23 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
Sergunb | 0:8918a71cdbe9 | 24 | * |
Sergunb | 0:8918a71cdbe9 | 25 | * @author Oryx Embedded SARL (www.oryx-embedded.com) |
Sergunb | 0:8918a71cdbe9 | 26 | * @version 1.7.6 |
Sergunb | 0:8918a71cdbe9 | 27 | **/ |
Sergunb | 0:8918a71cdbe9 | 28 | |
Sergunb | 0:8918a71cdbe9 | 29 | #ifndef _MLD_H |
Sergunb | 0:8918a71cdbe9 | 30 | #define _MLD_H |
Sergunb | 0:8918a71cdbe9 | 31 | |
Sergunb | 0:8918a71cdbe9 | 32 | //Dependencies |
Sergunb | 0:8918a71cdbe9 | 33 | #include "core/net.h" |
Sergunb | 0:8918a71cdbe9 | 34 | |
Sergunb | 0:8918a71cdbe9 | 35 | //MLD support |
Sergunb | 0:8918a71cdbe9 | 36 | #ifndef MLD_SUPPORT |
Sergunb | 0:8918a71cdbe9 | 37 | #define MLD_SUPPORT DISABLED |
Sergunb | 0:8918a71cdbe9 | 38 | #elif (MLD_SUPPORT != ENABLED && MLD_SUPPORT != DISABLED) |
Sergunb | 0:8918a71cdbe9 | 39 | #error MLD_SUPPORT parameter is not valid |
Sergunb | 0:8918a71cdbe9 | 40 | #endif |
Sergunb | 0:8918a71cdbe9 | 41 | |
Sergunb | 0:8918a71cdbe9 | 42 | //MLD tick interval |
Sergunb | 0:8918a71cdbe9 | 43 | #ifndef MLD_TICK_INTERVAL |
Sergunb | 0:8918a71cdbe9 | 44 | #define MLD_TICK_INTERVAL 1000 |
Sergunb | 0:8918a71cdbe9 | 45 | #elif (MLD_TICK_INTERVAL < 10) |
Sergunb | 0:8918a71cdbe9 | 46 | #error MLD_TICK_INTERVAL parameter is not valid |
Sergunb | 0:8918a71cdbe9 | 47 | #endif |
Sergunb | 0:8918a71cdbe9 | 48 | |
Sergunb | 0:8918a71cdbe9 | 49 | //Unsolicited report interval |
Sergunb | 0:8918a71cdbe9 | 50 | #ifndef MLD_UNSOLICITED_REPORT_INTERVAL |
Sergunb | 0:8918a71cdbe9 | 51 | #define MLD_UNSOLICITED_REPORT_INTERVAL 10000 |
Sergunb | 0:8918a71cdbe9 | 52 | #elif (MLD_UNSOLICITED_REPORT_INTERVAL < 1000) |
Sergunb | 0:8918a71cdbe9 | 53 | #error MLD_UNSOLICITED_REPORT_INTERVAL parameter is not valid |
Sergunb | 0:8918a71cdbe9 | 54 | #endif |
Sergunb | 0:8918a71cdbe9 | 55 | |
Sergunb | 0:8918a71cdbe9 | 56 | //Hop Limit used by MLD messages |
Sergunb | 0:8918a71cdbe9 | 57 | #define MLD_HOP_LIMIT 1 |
Sergunb | 0:8918a71cdbe9 | 58 | |
Sergunb | 0:8918a71cdbe9 | 59 | |
Sergunb | 0:8918a71cdbe9 | 60 | /** |
Sergunb | 0:8918a71cdbe9 | 61 | * @brief MLD node states |
Sergunb | 0:8918a71cdbe9 | 62 | **/ |
Sergunb | 0:8918a71cdbe9 | 63 | |
Sergunb | 0:8918a71cdbe9 | 64 | typedef enum |
Sergunb | 0:8918a71cdbe9 | 65 | { |
Sergunb | 0:8918a71cdbe9 | 66 | MLD_STATE_NON_LISTENER = 0, |
Sergunb | 0:8918a71cdbe9 | 67 | MLD_STATE_DELAYING_LISTENER = 1, |
Sergunb | 0:8918a71cdbe9 | 68 | MLD_STATE_IDLE_LISTENER = 2 |
Sergunb | 0:8918a71cdbe9 | 69 | } MldState; |
Sergunb | 0:8918a71cdbe9 | 70 | |
Sergunb | 0:8918a71cdbe9 | 71 | |
Sergunb | 0:8918a71cdbe9 | 72 | //CodeWarrior or Win32 compiler? |
Sergunb | 0:8918a71cdbe9 | 73 | #if defined(__CWCC__) || defined(_WIN32) |
Sergunb | 0:8918a71cdbe9 | 74 | #pragma pack(push, 1) |
Sergunb | 0:8918a71cdbe9 | 75 | #endif |
Sergunb | 0:8918a71cdbe9 | 76 | |
Sergunb | 0:8918a71cdbe9 | 77 | |
Sergunb | 0:8918a71cdbe9 | 78 | /** |
Sergunb | 0:8918a71cdbe9 | 79 | * @brief MLD message |
Sergunb | 0:8918a71cdbe9 | 80 | **/ |
Sergunb | 0:8918a71cdbe9 | 81 | |
Sergunb | 0:8918a71cdbe9 | 82 | typedef __start_packed struct |
Sergunb | 0:8918a71cdbe9 | 83 | { |
Sergunb | 0:8918a71cdbe9 | 84 | uint8_t type; //0 |
Sergunb | 0:8918a71cdbe9 | 85 | uint8_t code; //1 |
Sergunb | 0:8918a71cdbe9 | 86 | uint16_t checksum; //2-3 |
Sergunb | 0:8918a71cdbe9 | 87 | uint16_t maxRespDelay; //4-5 |
Sergunb | 0:8918a71cdbe9 | 88 | uint16_t reserved; //6-7 |
Sergunb | 0:8918a71cdbe9 | 89 | Ipv6Addr multicastAddr; //8-23 |
Sergunb | 0:8918a71cdbe9 | 90 | } __end_packed MldMessage; |
Sergunb | 0:8918a71cdbe9 | 91 | |
Sergunb | 0:8918a71cdbe9 | 92 | |
Sergunb | 0:8918a71cdbe9 | 93 | //CodeWarrior or Win32 compiler? |
Sergunb | 0:8918a71cdbe9 | 94 | #if defined(__CWCC__) || defined(_WIN32) |
Sergunb | 0:8918a71cdbe9 | 95 | #pragma pack(pop) |
Sergunb | 0:8918a71cdbe9 | 96 | #endif |
Sergunb | 0:8918a71cdbe9 | 97 | |
Sergunb | 0:8918a71cdbe9 | 98 | |
Sergunb | 0:8918a71cdbe9 | 99 | //Tick counter to handle periodic operations |
Sergunb | 0:8918a71cdbe9 | 100 | extern systime_t mldTickCounter; |
Sergunb | 0:8918a71cdbe9 | 101 | |
Sergunb | 0:8918a71cdbe9 | 102 | //MLD related functions |
Sergunb | 0:8918a71cdbe9 | 103 | error_t mldInit(NetInterface *interface); |
Sergunb | 0:8918a71cdbe9 | 104 | error_t mldStartListening(NetInterface *interface, Ipv6FilterEntry *entry); |
Sergunb | 0:8918a71cdbe9 | 105 | error_t mldStopListening(NetInterface *interface, Ipv6FilterEntry *entry); |
Sergunb | 0:8918a71cdbe9 | 106 | |
Sergunb | 0:8918a71cdbe9 | 107 | void mldTick(NetInterface *interface); |
Sergunb | 0:8918a71cdbe9 | 108 | void mldLinkChangeEvent(NetInterface *interface); |
Sergunb | 0:8918a71cdbe9 | 109 | |
Sergunb | 0:8918a71cdbe9 | 110 | void mldProcessListenerQuery(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, |
Sergunb | 0:8918a71cdbe9 | 111 | const NetBuffer *buffer, size_t offset, uint8_t hopLimit); |
Sergunb | 0:8918a71cdbe9 | 112 | |
Sergunb | 0:8918a71cdbe9 | 113 | void mldProcessListenerReport(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, |
Sergunb | 0:8918a71cdbe9 | 114 | const NetBuffer *buffer, size_t offset, uint8_t hopLimit); |
Sergunb | 0:8918a71cdbe9 | 115 | |
Sergunb | 0:8918a71cdbe9 | 116 | error_t mldSendListenerReport(NetInterface *interface, Ipv6Addr *ipAddr); |
Sergunb | 0:8918a71cdbe9 | 117 | error_t mldSendListenerDone(NetInterface *interface, Ipv6Addr *ipAddr); |
Sergunb | 0:8918a71cdbe9 | 118 | |
Sergunb | 0:8918a71cdbe9 | 119 | uint32_t mldRand(uint32_t max); |
Sergunb | 0:8918a71cdbe9 | 120 | |
Sergunb | 0:8918a71cdbe9 | 121 | void mldDumpMessage(const MldMessage *message); |
Sergunb | 0:8918a71cdbe9 | 122 | |
Sergunb | 0:8918a71cdbe9 | 123 | #endif |
Sergunb | 0:8918a71cdbe9 | 124 |