//Editor-Info: -*- C++ -*-
//
//Subject: TOVE-project / Common 
//
//File: error.h
//
//Version: $Revision: 1.5 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/12/20 15:46:44 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications and Multimedia
//
//Author:
//	Vesa-Matti Puro 
//
//Description:
//	Contains macros that are used to signal error conditions.
//	The macros throw exceptions that are catched in error
//	handling routines. An example of error handling routine
//	is a runCallback and error methods in pfProtocol class
//	in pf module.
//
//Copyright:
//      Copyright 1999 Helsinki University of Technology
//      ALL RIGHTS RESERVED BETWEEN JANUARY 1996 AND JUNE 1999.
//
//Licence:
//
//
//History: 
//
//

#ifndef __PF_ERROR_H__
#define __PF_ERROR_H__

#include "protocol/sig/sigdefs.h"
#include "pf/exception.h"
#include "pf/debug.h"

// Misc macros

#define PF_ERROR_PRINT(x) debugExceptionThrown(x, __FILE__, __LINE__);

// Common events

#define THROW_IF_DYNAMIC_CAST_FAILED(x) \
    if (x == 0) { \
    PF_ERROR_PRINT(sigCauseValue_TemporaryFailure) \
    throw pfException(sigCauseValue_TemporaryFailure); \
    }

// Normal events

#define THROW_UNALLOCATED_UNASSIGNED_NUMBER \
    PF_ERROR_PRINT(sigCauseValue_UnallocatedNumber) \
    throw pfException(sigCauseValue_UnallocatedNumber);

#define THROW_NO_ROUTE_TO_SPECIFIED_TRANSIT_NETWORK \
    PF_ERROR_PRINT(sigCauseValue_NoRouteToSpecifiedTransitNW) \
    throw pfException(sigCauseValue_NoRouteToSpecifiedTransitNW);

#define THROW_NO_ROUTE_TO_DESTINATION \
    PF_ERROR_PRINT(sigCauseValue_NoRouteToDestination) \
    throw pfException(sigCauseValue_NoRouteToDestination);

#define THROW_SEND_SPECIAL_INFORMATION_TONE \
    PF_ERROR_PRINT(sigCauseValue_SendSpecialInformationTone) \
    throw pfException(sigCauseValue_SendSpecialInformationTone);

#define THROW_MISDIALLED_TRUNK_PREFIX \
    PF_ERROR_PRINT(sigCauseValue_MisdialledTrunkPrefix) \
    throw pfException(sigCauseValue_MisdialledTrunkPrefix);

#define THROW_CHANNEL_UNACCEPTABLE \
    PF_ERROR_PRINT(sigCauseValue_ChannelUnacceptable) \
    throw pfException(sigCauseValue_ChannelUnacceptable);

#define THROW_CALL_AWARDED_IN_ESTABLISHED_CHANNEL \
    PF_ERROR_PRINT(sigCauseValue_CallAwardedInEstablishedChannel) \
    throw pfException(sigCauseValue_CallAwardedInEstablishedChannel);

#define THROW_PREEMPTION \
    PF_ERROR_PRINT(sigCauseValue_Preemption) \
    throw pfException(sigCauseValue_Preemption);

#define THROW_PREEMPTION_CIRCUIT_RESERVED_FOR_REUSE \
    PF_ERROR_PRINT(sigCauseValue_PreemptionCircuitReservedForReuse) \
    throw pfException(sigCauseValue_PreemptionCircuitReservedForReuse);

#define THROW_NORMAL_CALL_CLEARING \
    PF_ERROR_PRINT(sigCauseValue_NormalCallClearing) \
    throw pfException(sigCauseValue_NormalCallClearing);

#define THROW_USER_BUSY \
    PF_ERROR_PRINT(sigCauseValue_UserBusy) \
    throw pfException(sigCauseValue_UserBusy);

#define THROW_NO_USER_RESPONDING \
    PF_ERROR_PRINT(sigCauseValue_NoUserResponding) \
    throw pfException(sigCauseValue_NoUserResponding);

#define THROW_NO_ANSWER_FROM_USER_USER_ALERTED \
    PF_ERROR_PRINT(sigCauseValue_NoAnswerFromUserUserAlerted) \
    throw pfException(sigCauseValue_NoAnswerFromUserUserAlerted);

#define THROW_SUBSCRIBER_ABSENT \
    PF_ERROR_PRINT(sigCauseValue_SubscriberAbsent) \
    throw pfException(sigCauseValue_SubscriberAbsent);

#define THROW_CALL_REJECTED \
    PF_ERROR_PRINT(sigCauseValue_CallRejected) \
    throw pfException(sigCauseValue_CallRejected);

#define THROW_NUMBER_CHANGED \
    PF_ERROR_PRINT(sigCauseValue_NumberChanged) \
    throw pfException(sigCauseValue_NumberChanged);

#define THROW_USER_REJECTS__ALL_CALLS_WITH_CALLING_LINE_IDENTIFICATION_RESTRICTION \
    PF_ERROR_PRINT(sigCauseValue_UserRejectsAllCallsWithCLIR) \
    throw pfException(sigCauseValue_UserRejectsAllCallsWithCLIR);

#define THROW_NON_SELECTED_USER_CLEARING \
    PF_ERROR_PRINT(sigCauseValue_NonSelectedUserClearing) \
    throw pfException(sigCauseValue_NonSelectedUserClearing);

#define THROW_DESTINATION_OUT_OF_ORDER \
    PF_ERROR_PRINT(sigCauseValue_DestinationOutOfOrder) \
    throw pfException(sigCauseValue_DestinationOutOfOrder);

#define THROW_INVALID_NUMBER_FORMAT_ADDRESS_INCOMPLETE \
    PF_ERROR_PRINT(sigCauseValue_InvalidNumberFormat) \
    throw pfException(sigCauseValue_InvalidNumberFormat);

#define THROW_RESPONSE_TO_STATUS_ENQUIRY \
    PF_ERROR_PRINT(sigCauseValue_ResponseToSTATUS_ENQUIRY) \
    throw pfException(sigCauseValue_ResponseToSTATUS_ENQUIRY);

#define THROW_NORMAL_UNSPECIFIED \
    PF_ERROR_PRINT(sigCauseValue_NormalUnspecified) \
    throw pfException(sigCauseValue_NormalUnspecified);


// Resource unavailable

#define THROW_NO_CIRCUIT_OR_CHANNEL_AVAILABLE \
    PF_ERROR_PRINT(sigCauseValue_NoCircuitOrChannelAvailable) \
    throw pfException(sigCauseValue_NoCircuitOrChannelAvailable);

#define THROW_REQUESTED_VPCI_VCI_NOT_AVAILABLE \
    PF_ERROR_PRINT(sigCauseValue_RequestedVPCI_VCI_NotAvailable) \
    throw pfException(sigCauseValue_RequestedVPCI_VCI_NotAvailable);

#define THROW_VPCI_VCI_ASSIGNMENT_FAILURE \
    PF_ERROR_PRINT(sigCauseValue_VPCI_VCI_AssignmentFailure) \
    throw pfException(sigCauseValue_VPCI_VCI_AssignmentFailure);

#define THROW_USER_CELL_RATE_NOT_AVAILABLE \
    PF_ERROR_PRINT(sigCauseValue_UserCellRateNotAvailable) \
    throw pfException(sigCauseValue_UserCellRateNotAvailable);

#define THROW_NETWORK_OUT_OF_ORDER \
    PF_ERROR_PRINT(sigCauseValue_NWOutOfOrder) \
    throw pfException(sigCauseValue_NWOutOfOrder);

#define THROW_PERMANENT_FRAME_MODE_CONNECTION_OUT_OF_SERVICE \
    PF_ERROR_PRINT(sigCauseValue_PFMConnectionOutOfService) \
    throw pfException(sigCauseValue_PFMConnectionOutOfService);

#define THROW_PERMANENT_FRAME_MODE_CONNECTION_OPERATIONAL \
    PF_ERROR_PRINT(sigCauseValue_PFMConnectionOperational) \
    throw pfException(sigCauseValue_PFMConnectionOperational);

#define THROW_TEMPORARY_FAILURE \
    PF_ERROR_PRINT(sigCauseValue_TemporaryFailure) \
    throw pfException(sigCauseValue_TemporaryFailure);

#define THROW_SWITCHING_EQUIPMENT_CONGESTION \
    PF_ERROR_PRINT(sigCauseValue_SwitchingEquipmentCongestion) \
    throw pfException(sigCauseValue_SwitchingEquipmentCongestion);

#define THROW_ACCESS_INFORMATION_DISCARDED \
    PF_ERROR_PRINT(sigCauseValue_AccessInformationDiscarded) \
    throw pfException(sigCauseValue_AccessInformationDiscarded);

#define THROW_REQUESTED_CIRCUIT_OR_CHANNEL_NOT_AVAILABLE \
    PF_ERROR_PRINT(sigCauseValue_RequestedCircuitOrChannelNotAvailable) \
    throw pfException(sigCauseValue_RequestedCircuitOrChannelNotAvailable);

#define THROW_NO_VPCI_VCI_AVAILABLE \
    PF_ERROR_PRINT(sigCauseValue_NoVPCI_VCI_Available) \
    throw pfException(sigCauseValue_NoVPCI_VCI_Available);

#define THROW_PRECEDENCE_CALL_BLOCKED \
    PF_ERROR_PRINT(sigCauseValue_PrecedenceCallBlocked) \
    throw pfException(sigCauseValue_PrecedenceCallBlocked);

#define THROW_RESOURCE_UNAVAILABILITY_UNSPECIFIED \
    PF_ERROR_PRINT(sigCauseValue_ResourceUnavailable) \
    throw pfException(sigCauseValue_ResourceUnavailable);


// Service or option not available

#define THROW_QUALITY_OF_SERVICE_UNAVAILABLE \
    PF_ERROR_PRINT(sigCauseValue_QoSUnavailable) \
    throw pfException(sigCauseValue_QoSUnavailable);

#define THROW_REQUESTED_FACILITY_NOT_SUBSCRIBED \
    PF_ERROR_PRINT(sigCauseValue_RequestedFacilityNotSubscribed) \
    throw pfException(sigCauseValue_RequestedFacilityNotSubscribed);

#define THROW_OUTGOING_CALLS_BARRED_WITHIN_CUG \
    PF_ERROR_PRINT(sigCauseValue_OutgoingCallsBarredWithinCUG) \
    throw pfException(sigCauseValue_OutgoingCallsBarredWithinCUG);

#define THROW_INCOMING_CALLS_BARRED_WITHIN_CUG \
    PF_ERROR_PRINT(sigCauseValue_IncomingCallsBarredWithinCUG) \
    throw pfException(sigCauseValue_IncomingCallsBarredWithinCUG);

#define THROW_BEARER_CAPABILITY_NOT_AUTHORIZED \
    PF_ERROR_PRINT(sigCauseValue_BearerCapabilityNotAuthorized) \
    throw pfException(sigCauseValue_BearerCapabilityNotAuthorized);

#define THROW_BEARER_CAPABILITY_NOT_PRESENTLY_AVAILABLE \
    PF_ERROR_PRINT(sigCauseValue_BearerCapabilityNotAvailable) \
    throw pfException(sigCauseValue_BearerCapabilityNotAvailable);

#define THROW_INCONSISTENCY_IN_DOAI_AND_SUBSCRIBER_CLASS \
    PF_ERROR_PRINT(sigCauseValue_InconsistencyInDOAIAndSubscriberClass) \
    throw pfException(sigCauseValue_InconsistencyInDOAIAndSubscriberClass);

#define THROW_SERVICE_OPTION_NOT_AVAILABLE_UNSPECIFIED \
    PF_ERROR_PRINT(sigCauseValue_ServiceOrOptionNotAvailable) \
    throw pfException(sigCauseValue_ServiceOrOptionNotAvailable);


// Service or option not implemented

#define THROW_BEARER_CAPABILITY_NOT_IMPLEMENTED \
    PF_ERROR_PRINT(sigCauseValue_BearerCapabilityNotImplemented) \
    throw pfException(sigCauseValue_BearerCapabilityNotImplemented);

#define THROW_CHANNEL_TYPE_NOT_IMPLEMENTED \
    PF_ERROR_PRINT(sigCauseValue_ChannelTypeNotImplemented) \
    throw pfException(sigCauseValue_ChannelTypeNotImplemented);

#define THROW_REQUESTED_FACILITY_NOT_IMPLEMENTED \
    PF_ERROR_PRINT(sigCauseValue_RequestedFacilityNotImplemented) \
    throw pfException(sigCauseValue_RequestedFacilityNotImplemented);

#define THROW_ONLY_RESTRICTED_DIBC_IS_AVAILABLE \
    PF_ERROR_PRINT(sigCauseValue_OnlyRestrictedDIBCIsAvailable) \
    throw pfException(sigCauseValue_OnlyRestrictedDIBCIsAvailable);

#define THROW_UNSUPPORTED_COMBINATION_OF_TRAFFIC_PARAMETERS \
    PF_ERROR_PRINT(sigCauseValue_UnsupportedCombinationOfTrafficParameters) \
    throw pfException(sigCauseValue_UnsupportedCombinationOfTrafficParameters);

#define THROW_AAL_PARAMETERS_CANNOT_BE_SUPPORTED \
    PF_ERROR_PRINT(sigCauseValue_AALParametersCannotBeSupported) \
    throw pfException(sigCauseValue_AALParametersCannotBeSupported);

#define THROW_SERVICE_OR_OPTION_NOT_IMPLEMENTED_UNSPECIFIED \
    PF_ERROR_PRINT(sigCauseValue_ServiceOrOptionNotImplemented) \
    throw pfException(sigCauseValue_ServiceOrOptionNotImplemented);

// Invalid message

#define THROW_INVALID_CALL_REFERENCE_VALUE \
    PF_ERROR_PRINT(sigCauseValue_InvalidCallReferenceValue) \
    throw pfException(sigCauseValue_InvalidCallReferenceValue);

#define THROW_IDENTIFIED_CHANNEL_DOES_NOT_EXIST \
    PF_ERROR_PRINT(sigCauseValue_IdentifiedChannelDoesNotExist) \
    throw pfException(sigCauseValue_IdentifiedChannelDoesNotExist);

#define THROW_SUSPENDED_CALL_EXISTS_CALL_IDENTITY_NOT \
    PF_ERROR_PRINT(sigCauseValue_SuspendedCallExistsButThisCINot) \
    throw pfException(sigCauseValue_SuspendedCallExistsButThisCINot);

#define THROW_CALL_IDENTITY_IN_USE \
    PF_ERROR_PRINT(sigCauseValue_CallIdentityInUse) \
    throw pfException(sigCauseValue_CallIdentityInUse);

#define THROW_NO_CALL_SUSPENDED \
    PF_ERROR_PRINT(sigCauseValue_NoCallSuspended) \
    throw pfException(sigCauseValue_NoCallSuspended);

#define THROW_CALL_HAVING_REQUESTED_CI_CLEARED \
    PF_ERROR_PRINT(sigCauseValue_CallHavingRequestedCICleared) \
    throw pfException(sigCauseValue_CallHavingRequestedCICleared);

#define THROW_USER_NOT_MEMBER_OF_CUG \
    PF_ERROR_PRINT(sigCauseValue_UserNotMemberOfCUG) \
    throw pfException(sigCauseValue_UserNotMemberOfCUG);

#define THROW_INCOMPATIBLE_DESTINATION \
    PF_ERROR_PRINT(sigCauseValue_IncompatibleDestination) \
    throw pfException(sigCauseValue_IncompatibleDestination);

#define THROW_INVALID_ENDPOINT_REFERENCE \
    PF_ERROR_PRINT(sigCauseValue_InvalidEndpointReference) \
    throw pfException(sigCauseValue_InvalidEndpointReference);

#define THROW_NONEXISTENT_CUG \
    PF_ERROR_PRINT(sigCauseValue_NonexistentCUG) \
    throw pfException(sigCauseValue_NonexistentCUG);

#define THROW_INVALID_TRANSIT_NETWORK_SELECTION \
    PF_ERROR_PRINT(sigCauseValue_InvalidTransitNWSelection) \
    throw pfException(sigCauseValue_InvalidTransitNWSelection);

#define THROW_TOO_MANY_PENDING_ADD_PARTY_REQUESTS \
    PF_ERROR_PRINT(sigCauseValue_TooManyPendingAddPartyRequests) \
    throw pfException(sigCauseValue_TooManyPendingAddPartyRequests);

#define THROW_INVALID_MESSAGE \
    PF_ERROR_PRINT(sigCauseValue_InvalidMessage) \
    throw pfException(sigCauseValue_InvalidMessage);

// Protocol error

#define THROW_MANDATORY_INFORMATION_ELEMENT_IS_MISSING \
    PF_ERROR_PRINT(sigCauseValue_MandatoryIEIsMissing) \
    throw pfException(sigCauseValue_MandatoryIEIsMissing);

#define THROW_MESSAGE_TYPE_NON_EXISTENT_OR_NOT_IMPLEMENTED \
    PF_ERROR_PRINT(sigCauseValue_MessageTypeNonexistent) \
    throw pfException(sigCauseValue_MessageTypeNonexistent);

#define THROW_MESSAGE_NOT_COMPATIBLE_WITH_CALL_STATE_OR_TYPE_NONEXISTENT \
    PF_ERROR_PRINT(sigCauseValue_MessageNotCompatibleWithCSOrTypeNonexistent) \
    throw pfException(sigCauseValue_MessageNotCompatibleWithCSOrTypeNonexistent);

#define THROW_INFORMATION_ELEMENT_NON_EXISTENT_OR_NOT_IMPLEMENTED \
    PF_ERROR_PRINT(sigCauseValue_IENonexistent) \
    throw pfException(sigCauseValue_IENonexistent);

#define THROW_INVALID_INFORMATION_ELEMENT_CONTENTS \
    PF_ERROR_PRINT(sigCauseValue_InvalidIEContents) \
    throw pfException(sigCauseValue_InvalidIEContents);

#define THROW_MESSAGE_NOT_COMPATIBLE_WITH CALL_STATE \
    PF_ERROR_PRINT(sigCauseValue_MessageNotCompatibleWithCallState) \
    throw pfException(sigCauseValue_MessageNotCompatibleWithCallState);

#define THROW_RECOVERY_ON_TIMER_EXPIRY \
    PF_ERROR_PRINT(sigCauseValue_RecoveryOnTimerExpiry) \
    throw pfException(sigCauseValue_RecoveryOnTimerExpiry);

#define THROW_PARAMETER_NONEXISTENT_OR_NOT_IMPLEMENTED \
    PF_ERROR_PRINT(sigCauseValue_ParameterNonexistentOrNotImplemented) \
    throw pfException(sigCauseValue_ParameterNonexistentOrNotImplemented);

#define THROW_INCORRECT_MESSAGE_LENGTH \
    PF_ERROR_PRINT(sigCauseValue_IncorrectMessageLength) \
    throw pfException(sigCauseValue_IncorrectMessageLength);

#define THROW_MESSAGE_WITH_UNRECOGNIZED_PARAMETER \
    PF_ERROR_PRINT(sigCauseValue_MessageWithUnrecognizedParameter) \
    throw pfException(sigCauseValue_MessageWithUnrecognizedParameter);

#define THROW_PROTOCOL_ERROR_UNSPECIFIED \
    PF_ERROR_PRINT(sigCauseValue_ProtocolError) \
    throw pfException(sigCauseValue_ProtocolError);

#define THROW_INTERWORKING \
    PF_ERROR_PRINT(sigCauseValue_Interworking) \
    throw pfException(sigCauseValue_Interworking);

#endif // __PF_ERROR_H__

