source: source/ariba/utility/transport/tcpip/protlib/tperror.h@ 5686

Last change on this file since 5686 was 5284, checked in by mies, 15 years ago

+ added new transport modules and adapted ariba to them
+ exchange endpoint descriptors an link establishment
+ clean up of base communication
+ link establishment with in the presence of multiple endpoints
+ local discovery for ipv6, ipv4 and bluetooth mac addresses

File size: 5.1 KB
RevLine 
[5284]1/// ----------------------------------------*- mode: C++; -*--
2/// @file tperror.h
3/// Errors from TP module
4/// ----------------------------------------------------------
5/// $Id: tperror.h 2794 2007-09-05 12:01:22Z bless $
6/// $HeadURL: https://svn.ipv6.tm.uka.de/nsis/protlib/trunk/include/tperror.h $
7// ===========================================================
8//
9// Copyright (C) 2005-2007, all rights reserved by
10// - Institute of Telematics, Universitaet Karlsruhe (TH)
11//
12// More information and contact:
13// https://projekte.tm.uka.de/trac/NSIS
14//
15// This program is free software; you can redistribute it and/or modify
16// it under the terms of the GNU General Public License as published by
17// the Free Software Foundation; version 2 of the License
18//
19// This program is distributed in the hope that it will be useful,
20// but WITHOUT ANY WARRANTY; without even the implied warranty of
21// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22// GNU General Public License for more details.
23//
24// You should have received a copy of the GNU General Public License along
25// with this program; if not, write to the Free Software Foundation, Inc.,
26// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27//
28// ===========================================================
29/** @ingroup transport
30 * This is the interface for sending network messages over a transport
31 * protocol. You can receive messages through queues.
32 */
33
34#ifndef _PROTLIB__TP_ERROR_H_
35#define _PROTLIB__TP_ERROR_H_
36
37#include <string.h>
38
39#include "protlib_types.h"
40
41namespace protlib {
42
43/** @addtogroup transport Transport Protocol
44 * @ingroup network
45 * @{
46 */
47
48/// Transport Protocol Error
49/** Reports a TP error while connection setup, sending a network message or initialization. */
50class TPError : public ProtLibException {
51public:
52 /// TP error codes
53 enum tp_error_t {
54 TPERR_OK, // everything ok
55 TPERR_BAD_ADDRESS, // Bad destination address
56 TPERR_BAD_NETMSG, // not used
57 TPERR_ARGS_NOT_INIT,// arguments not initialized
58 TPERR_UNREACHABLE, // destination unreachable
59 TPERR_INTERNAL, // any other internal error
60 TPERR_PAYLOAD, // maximum payload
61 TPERR_INITFAILED, // Initialization failed, e.g. during socket setup
62 TPERR_SENDFAILED, // send failure
63 TPERR_CONNSETUPFAIL, // connection setup failed
64 TPERR_CLOSEIND, // close indication (other side closed connection)
65 TPERR_ABORTIND // abort indication (transport protocol)
66 }; // end tp_error_t
67
68 /// constructor
69 TPError(tp_error_t e) : errtype(e) {};
70
71 /// get error string
72 virtual const char* getstr() const= 0;
73 virtual const char *what() const throw() { return getstr(); }
74 /// error code
75 const tp_error_t errtype;
76}; // end class TPError
77
78
79/***** class TPError *****/
80
81class TPErrorBadDestAddress : public TPError
82{
83public:
84 TPErrorBadDestAddress() : TPError(TPError::TPERR_BAD_ADDRESS) {}
85 virtual const char* getstr() const { return "Bad Destination Address"; }
86};
87
88
89class TPErrorArgsNotInit : public TPError
90{
91public:
92 TPErrorArgsNotInit() : TPError(TPError::TPERR_ARGS_NOT_INIT) {}
93 virtual const char* getstr() const { return "arguments of TPMsg not initialized"; }
94};
95
96class TPErrorUnreachable : public TPError
97{
98public:
99 TPErrorUnreachable() : TPError(TPError::TPERR_UNREACHABLE) {}
100 virtual const char* getstr() const { return "Destination unreachable"; }
101};
102
103class TPErrorInternal : public TPError
104{
105public:
106 TPErrorInternal() : TPError(TPError::TPERR_INTERNAL) {}
107 virtual const char* getstr() const { return "Internal Transport Protocol Error"; }
108};
109
110
111class TPErrorPayload : public TPError
112{
113public:
114 TPErrorPayload() : TPError(TPError::TPERR_PAYLOAD) {}
115 virtual const char* getstr() const { return "Payload exceeds maximum transmission unit or empty payload given"; }
116};
117
118class TPErrorInitFailed : public TPError
119{
120public:
121 TPErrorInitFailed() : TPError(TPError::TPERR_INITFAILED) {}
122 virtual const char* getstr() const { return "Initialization of protocol failed"; }
123};
124
125class TPErrorSendFailed : public TPError
126{
127 int saved_errno; ///< value of errno from send call
128public:
129 TPErrorSendFailed(int current_errno= 0) : TPError(TPError::TPERR_SENDFAILED), saved_errno(current_errno) {}
130 virtual const char* getstr() const { return "Failure while trying to send a protocol data unit"; }
131 int get_reason() const { return saved_errno; } ///< returns saved value of errno from send call
132};
133
134class TPErrorConnectSetupFail : public TPError
135{
136public:
137 TPErrorConnectSetupFail() : TPError(TPError::TPERR_CONNSETUPFAIL) {}
138 virtual const char* getstr() const { return "Connection Setup Failure"; }
139};
140
141class TPErrorCloseInd : public TPError
142{
143public:
144 TPErrorCloseInd() : TPError(TPError::TPERR_CLOSEIND) {}
145 virtual const char* getstr() const { return "Other side closed connection"; }
146};
147
148class TPErrorAbortInd : public TPError
149{
150public:
151 TPErrorAbortInd() : TPError(TPError::TPERR_ABORTIND) {}
152 virtual const char* getstr() const { return "Abort indication, transport protocol indicated failure/abort"; }
153};
154
155} // end namespace protlib
156
157#endif // _PROTLIB__TP_ERROR_H_
Note: See TracBrowser for help on using the repository browser.