| 1 | // [License]
|
---|
| 2 | // The Ariba-Underlay Copyright
|
---|
| 3 | //
|
---|
| 4 | // Copyright (c) 2008-2009, Institute of Telematics, UniversitÀt Karlsruhe (TH)
|
---|
| 5 | //
|
---|
| 6 | // Institute of Telematics
|
---|
| 7 | // UniversitÀt Karlsruhe (TH)
|
---|
| 8 | // Zirkel 2, 76128 Karlsruhe
|
---|
| 9 | // Germany
|
---|
| 10 | //
|
---|
| 11 | // Redistribution and use in source and binary forms, with or without
|
---|
| 12 | // modification, are permitted provided that the following conditions are
|
---|
| 13 | // met:
|
---|
| 14 | //
|
---|
| 15 | // 1. Redistributions of source code must retain the above copyright
|
---|
| 16 | // notice, this list of conditions and the following disclaimer.
|
---|
| 17 | // 2. Redistributions in binary form must reproduce the above copyright
|
---|
| 18 | // notice, this list of conditions and the following disclaimer in the
|
---|
| 19 | // documentation and/or other materials provided with the distribution.
|
---|
| 20 | //
|
---|
| 21 | // THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
|
---|
| 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
| 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
---|
| 24 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ARIBA PROJECT OR
|
---|
| 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
---|
| 26 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
---|
| 27 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
---|
| 28 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
---|
| 29 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
---|
| 30 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
---|
| 31 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 32 | //
|
---|
| 33 | // The views and conclusions contained in the software and documentation
|
---|
| 34 | // are those of the authors and should not be interpreted as representing
|
---|
| 35 | // official policies, either expressed or implied, of the Institute of
|
---|
| 36 | // Telematics.
|
---|
| 37 | // [License]
|
---|
| 38 |
|
---|
| 39 | #ifndef OVERLAY_MSG_H__
|
---|
| 40 | #define OVERLAY_MSG_H__
|
---|
| 41 |
|
---|
| 42 | #include <boost/cstdint.hpp>
|
---|
| 43 | #include "ariba/utility/messages.h"
|
---|
| 44 | #include "ariba/utility/serialization.h"
|
---|
| 45 | #include "ariba/utility/types/ServiceID.h"
|
---|
| 46 | #include "ariba/utility/types/NodeID.h"
|
---|
| 47 | #include "ariba/utility/types/LinkID.h"
|
---|
| 48 |
|
---|
| 49 | using ariba::utility::LinkID;
|
---|
| 50 | using ariba::utility::NodeID;
|
---|
| 51 | using ariba::utility::ServiceID;
|
---|
| 52 | using ariba::utility::Message;
|
---|
| 53 |
|
---|
| 54 | namespace ariba {
|
---|
| 55 | namespace overlay {
|
---|
| 56 |
|
---|
| 57 | using_serialization
|
---|
| 58 | ;
|
---|
| 59 |
|
---|
| 60 | class OverlayMsg: public Message {
|
---|
| 61 | VSERIALIZEABLE
|
---|
| 62 | ;
|
---|
| 63 | public:
|
---|
| 64 |
|
---|
| 65 | /// (payload-) message types
|
---|
| 66 | enum type_ {
|
---|
| 67 | typeInvalid = 0, ///< invalid type (no encapsulated messages)
|
---|
| 68 | typeData = 1, ///< message contains data for higher layers
|
---|
| 69 | typeJoinRequest = 2, ///< join request
|
---|
| 70 | typeJoinReply = 3, ///< join reply
|
---|
| 71 | typeUpdate = 4, ///< update message for link association
|
---|
| 72 | typeBye = 5, ///< leave (no encapsulated messages)
|
---|
| 73 | typeLinkRequest = 6, ///< link request (sent over the overlay)
|
---|
| 74 | typeRelay = 7, ///< relay message
|
---|
| 75 | typeKeepAlive = 8, ///< a keep-alive message
|
---|
| 76 | typeDirectLink = 9,
|
---|
| 77 | ///< a direct connection has been established
|
---|
| 78 | };
|
---|
| 79 |
|
---|
| 80 | /// default constructor
|
---|
| 81 | OverlayMsg(type_ type = typeInvalid, const ServiceID _service =
|
---|
| 82 | ServiceID::UNSPECIFIED, const NodeID _sourceNode =
|
---|
| 83 | NodeID::UNSPECIFIED) :
|
---|
| 84 | type((uint8_t) type), service(_service), sourceNode(_sourceNode),
|
---|
| 85 | relayLink(LinkID::UNSPECIFIED), autoLink(false) {
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | OverlayMsg(const OverlayMsg& rhs) :
|
---|
| 89 | type(rhs.type), service(rhs.service), sourceNode(rhs.sourceNode),
|
---|
| 90 | relayLink(rhs.relayLink), autoLink(rhs.autoLink) {
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | /// type and source node constructor
|
---|
| 94 | OverlayMsg(type_ type, const NodeID _sourceNode) :
|
---|
| 95 | type((uint8_t) type), service(ServiceID::UNSPECIFIED), sourceNode(
|
---|
| 96 | _sourceNode), relayLink(LinkID::UNSPECIFIED), autoLink(false) {
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | /// destructor
|
---|
| 100 | ~OverlayMsg();
|
---|
| 101 |
|
---|
| 102 | type_ getType() const {
|
---|
| 103 | return (type_) type;
|
---|
| 104 | }
|
---|
| 105 |
|
---|
| 106 | const ServiceID& getService() const {
|
---|
| 107 | return service;
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | const NodeID& getSourceNode() const {
|
---|
| 111 | return sourceNode;
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 | const LinkID& getRelayLink() const {
|
---|
| 115 | return relayLink;
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | void setRelayLink(const LinkID& relayLink) {
|
---|
| 119 | this->relayLink = relayLink;
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 | const bool isAutoLink() const {
|
---|
| 123 | return autoLink;
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | void setAutoLink(bool autoLink) {
|
---|
| 127 | this->autoLink = autoLink;
|
---|
| 128 | }
|
---|
| 129 | private:
|
---|
| 130 | uint8_t type;
|
---|
| 131 | ServiceID service;
|
---|
| 132 | NodeID sourceNode;
|
---|
| 133 | LinkID relayLink;
|
---|
| 134 | uint8_t autoLink;
|
---|
| 135 | };
|
---|
| 136 |
|
---|
| 137 | }
|
---|
| 138 | } // ariba::overlay
|
---|
| 139 |
|
---|
| 140 | sznBeginDefault( ariba::overlay::OverlayMsg, X ){
|
---|
| 141 | X && type && &service && &sourceNode;
|
---|
| 142 | if (type == typeDirectLink) X && &relayLink;
|
---|
| 143 | if (type == typeUpdate) X && autoLink;
|
---|
| 144 | X && Payload();
|
---|
| 145 | }sznEnd();
|
---|
| 146 |
|
---|
| 147 | #endif // OVERLAY_MSG_H__
|
---|