Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
72cca4ae
Commit
72cca4ae
authored
Dec 08, 2008
by
Steven Murray
Browse files
Added marshaling and unmarshalling of RTCP acknowledge message
parent
58f93dff
Changes
18
Expand all
Hide whitespace changes
Inline
Side-by-side
castor/tape/aggregator/AggregatorDlfMessageConstants.hpp
View file @
72cca4ae
/* This file was generated by ./AggregatorDlfMessagesCodeGenerator on
Fri
Dec
5 16:58:03
CET 2008
/* This file was generated by ./AggregatorDlfMessagesCodeGenerator on
Sun
Dec
7 22:33:56
CET 2008
*/
/******************************************************************************
...
...
@@ -39,27 +39,27 @@ AGGREGATOR_FAILED_TO_PARSE_COMMAND_LINE=2, /* "Failed to parse the command line"
AGGREGATOR_FAILED_TO_INIT_DB_SERVICE
=
3
,
/* "Failed to initialise database service" */
AGGREGATOR_VDQM_REQUEST_HANDLER_SOCKET_IS_NULL
=
4
,
/* "The VdqmRequestHandlerThread has been passed a NULL socket pointer" */
AGGREGATOR_HANDLE_VDQM_REQUEST_EXCEPT
=
5
,
/* "Exception raised when handling a request from the VDQM" */
AGGREGATOR_FAILED_TO_READ_M
AGIC
=
6
,
/* "Failed to read m
agic number from socket
" */
AGGREGATOR_
UNKNOWN_MAGIC
=
7
,
/* "Unknown magic numb
er" */
AGGREGATOR_
FAILED_TO_READ_REQUEST_TYPE
=
8
,
/* "Failed to read request type from socket
" */
AGGREGATOR_FAILED_TO_READ_M
ESSAGE_HEADER
=
6
,
/* "Failed to read m
essage header
" */
AGGREGATOR_
FAILED_TO_UNMARSHALL_MESSAGE_HEADER
=
7
,
/* "Failed to unmarshall message head
er" */
AGGREGATOR_
UNKNOWN_MAGIC
=
8
,
/* "Unknown magic number
" */
AGGREGATOR_UNKNOWN_REQUEST_TYPE
=
9
,
/* "Unknown request type" */
AGGREGATOR_
FAILED_TO_READ_
MESSAGE_BODY_LENGTH
=
10
,
/* "Failed to read l
ength of message body" */
AGGREGATOR_MESSAGE_BODY_LENGTH_TOO_
LARGE
=
11
,
/* "Length of message body is too
large
" */
AGGREGATOR_
JOB_MESSAGE_BODY_LENGTH_TOO_SHORT
=
12
,
/* "Length of job submission message body is too short
" */
AGGREGATOR_
FAILED_TO_READ
_MESSAGE
_BODY
=
13
,
/* "
Failed to read message body
" */
AGGREGATOR_
HANDLE_JOB_MESSAGE
=
14
,
/* "Handle job submission message VDQM_CLIENTINFO:RTCOPY_MAGIC_OLD0
" */
AGGREGATOR_SUBMIT
TING
_JOB_TO_RTCPD
=
15
,
/* "
S
ubmit
ting
remote copy job to RTCPD" */
AGGREGATOR_FAILED_TO_
SUBMIT_JOB_TO_RTCPD
=
16
,
/* "Failed to submit remote copy job to RTCPD
" */
AGGREGATOR_FAILED_TO_
MARSHALL
_R
T
CP_
ACKN
=
17
,
/* "Failed to
marshall
R
T
CP
acknowledge message
" */
AGGREGATOR_
FAILED_TO_SEND_RTCP_ACKN_TO_VDQM
=
18
,
/* "Failed to send RTCP acknowledge to VDQM
" */
AGGREGATOR_RECEIVED_RCP
_JOB_FROM_UNAUTHORIZED_HOST
=
19
,
/* "Received a remote copy job from an unauthorized host
" */
AGGREGATOR_R
ECEIVED_RTCPD_ERROR_MESSAGE
=
20
,
/* "Received error message from RTCPD
" */
AGGREGATOR_RTCPD_
HANDLER_SOCKET_IS_NULL
=
21
,
/* "The RtcpdHandlerThread has been passed a NULL socket pointer
" */
AGGREGATOR_RTCPD_CONNECTION_WITH_INFO
=
22
,
/* "Received a connection from RTCPD" */
AGGREGATOR_R
TCPD_CONNECTION_WITHOUT_INFO
=
23
,
/* "Received a connection from RTCPD without peer host and port information
" */
AGGREGATOR_RECEIVE
D
_TAPE_REQUEST
=
24
,
/* "
R
eceive
d
RTCP tape request
message
from RTCPD" */
AGGREGATOR_FAILED_TO_
RECEIVE_TAPE_REQUEST
=
25
,
/* "Failed to receive RTCP tape request from RTCPD
" */
AGGREGATOR_FAILED_TO_
UN
MARSHALL_MESSAGE
_BODY
=
26
/* "Failed to
un
marshall message
body
" */
AGGREGATOR_MESSAGE_BODY_LENGTH
_TOO_LARGE
=
10
,
/* "L
ength of message body
is too large
" */
AGGREGATOR_
JOB_
MESSAGE_BODY_LENGTH_TOO_
SHORT
=
11
,
/* "Length of
job submission
message body is too
short
" */
AGGREGATOR_
FAILED_TO_READ_MESSAGE_BODY
=
12
,
/* "Failed to read message body
" */
AGGREGATOR_
HANDLE_JOB
_MESSAGE
=
13
,
/* "
Handle job submission message VDQM_CLIENTINFO:RTCOPY_MAGIC_OLD0
" */
AGGREGATOR_
SUBMITTING_JOB_TO_RTCPD
=
14
,
/* "Submitting remote copy job to RTCPD
" */
AGGREGATOR_
FAILED_TO_
SUBMIT_JOB_TO_RTCPD
=
15
,
/* "
Failed to s
ubmit remote copy job to RTCPD" */
AGGREGATOR_FAILED_TO_
MARSHALL_RTCP_ACKN
=
16
,
/* "Failed to marshall RTCP acknowledge message
" */
AGGREGATOR_FAILED_TO_
SEND
_RCP_
JOB_REPLY_TO_VDQM
=
17
,
/* "Failed to
send
RCP
job reply to VDQM
" */
AGGREGATOR_
RECEIVED_RCP_JOB_FROM_UNAUTHORIZED_HOST
=
18
,
/* "Received a remote copy job from an unauthorized host
" */
AGGREGATOR_RECEIVED_R
T
CP
D_ERROR_MESSAGE
=
19
,
/* "Received error message from RTCPD
" */
AGGREGATOR_R
TCPD_HANDLER_SOCKET_IS_NULL
=
20
,
/* "The RtcpdHandlerThread has been passed a NULL socket pointer
" */
AGGREGATOR_RTCPD_
CONNECTION_WITH_INFO
=
21
,
/* "Received a connection from RTCPD
" */
AGGREGATOR_RTCPD_CONNECTION_WITH
OUT
_INFO
=
22
,
/* "Received a connection from RTCPD
without peer host and port information
" */
AGGREGATOR_R
ECEIVED_TAPE_REQUEST
=
23
,
/* "Received RTCP tape request message from RTCPD
" */
AGGREGATOR_
FAILED_TO_
RECEIVE_TAPE_REQUEST
=
24
,
/* "
Failed to r
eceive RTCP tape request from RTCPD" */
AGGREGATOR_FAILED_TO_
UNMARSHALL_MESSAGE_BODY
=
25
,
/* "Failed to unmarshall message body
" */
AGGREGATOR_FAILED_TO_MARSHALL_
RCP_JOB_REPLY_
MESSAGE
=
26
/* "Failed to marshall
RCP job reply
message" */
};
// enum AggregatorDlfMessages
}
// namespace aggregator
}
// namespace tape
...
...
castor/tape/aggregator/AggregatorDlfMessageStrings.cpp
View file @
72cca4ae
/* This file was generated by ./AggregatorDlfMessagesCodeGenerator on
Fri
Dec
5 16:58:03
CET 2008
/* This file was generated by ./AggregatorDlfMessagesCodeGenerator on
Sun
Dec
7 22:33:56
CET 2008
*/
/******************************************************************************
...
...
@@ -35,11 +35,10 @@ castor::dlf::Message castor::tape::aggregator::AggregatorDaemon::s_dlfMessages[]
{
AGGREGATOR_FAILED_TO_INIT_DB_SERVICE
,
"Failed to initialise database service"
},
{
AGGREGATOR_VDQM_REQUEST_HANDLER_SOCKET_IS_NULL
,
"The VdqmRequestHandlerThread has been passed a NULL socket pointer"
},
{
AGGREGATOR_HANDLE_VDQM_REQUEST_EXCEPT
,
"Exception raised when handling a request from the VDQM"
},
{
AGGREGATOR_FAILED_TO_READ_MAGIC
,
"Failed to read magic number from socket"
},
{
AGGREGATOR_FAILED_TO_READ_MESSAGE_HEADER
,
"Failed to read message header"
},
{
AGGREGATOR_FAILED_TO_UNMARSHALL_MESSAGE_HEADER
,
"Failed to unmarshall message header"
},
{
AGGREGATOR_UNKNOWN_MAGIC
,
"Unknown magic number"
},
{
AGGREGATOR_FAILED_TO_READ_REQUEST_TYPE
,
"Failed to read request type from socket"
},
{
AGGREGATOR_UNKNOWN_REQUEST_TYPE
,
"Unknown request type"
},
{
AGGREGATOR_FAILED_TO_READ_MESSAGE_BODY_LENGTH
,
"Failed to read length of message body"
},
{
AGGREGATOR_MESSAGE_BODY_LENGTH_TOO_LARGE
,
"Length of message body is too large"
},
{
AGGREGATOR_JOB_MESSAGE_BODY_LENGTH_TOO_SHORT
,
"Length of job submission message body is too short"
},
{
AGGREGATOR_FAILED_TO_READ_MESSAGE_BODY
,
"Failed to read message body"
},
...
...
@@ -47,7 +46,7 @@ castor::dlf::Message castor::tape::aggregator::AggregatorDaemon::s_dlfMessages[]
{
AGGREGATOR_SUBMITTING_JOB_TO_RTCPD
,
"Submitting remote copy job to RTCPD"
},
{
AGGREGATOR_FAILED_TO_SUBMIT_JOB_TO_RTCPD
,
"Failed to submit remote copy job to RTCPD"
},
{
AGGREGATOR_FAILED_TO_MARSHALL_RTCP_ACKN
,
"Failed to marshall RTCP acknowledge message"
},
{
AGGREGATOR_FAILED_TO_SEND_R
T
CP_
ACKN
_TO_VDQM
,
"Failed to send R
T
CP
acknowledge
to VDQM"
},
{
AGGREGATOR_FAILED_TO_SEND_RCP_
JOB_REPLY
_TO_VDQM
,
"Failed to send RCP
job reply
to VDQM"
},
{
AGGREGATOR_RECEIVED_RCP_JOB_FROM_UNAUTHORIZED_HOST
,
"Received a remote copy job from an unauthorized host"
},
{
AGGREGATOR_RECEIVED_RTCPD_ERROR_MESSAGE
,
"Received error message from RTCPD"
},
{
AGGREGATOR_RTCPD_HANDLER_SOCKET_IS_NULL
,
"The RtcpdHandlerThread has been passed a NULL socket pointer"
},
...
...
@@ -56,4 +55,5 @@ castor::dlf::Message castor::tape::aggregator::AggregatorDaemon::s_dlfMessages[]
{
AGGREGATOR_RECEIVED_TAPE_REQUEST
,
"Received RTCP tape request message from RTCPD"
},
{
AGGREGATOR_FAILED_TO_RECEIVE_TAPE_REQUEST
,
"Failed to receive RTCP tape request from RTCPD"
},
{
AGGREGATOR_FAILED_TO_UNMARSHALL_MESSAGE_BODY
,
"Failed to unmarshall message body"
},
{
AGGREGATOR_FAILED_TO_MARSHALL_RCP_JOB_REPLY_MESSAGE
,
"Failed to marshall RCP job reply message"
},
{
-
1
,
""
}};
castor/tape/aggregator/AggregatorDlfMessages.csv
View file @
72cca4ae
AGGREGATOR_NULL,
0,
" - "
AGGREGATOR_STARTED,
1,
"aggregatord started"
AGGREGATOR_FAILED_TO_PARSE_COMMAND_LINE,
2,
"Failed to parse the command line"
AGGREGATOR_FAILED_TO_INIT_DB_SERVICE,
3,
"Failed to initialise database service"
AGGREGATOR_VDQM_REQUEST_HANDLER_SOCKET_IS_NULL,
4,
"The VdqmRequestHandlerThread has been passed a NULL socket pointer"
AGGREGATOR_HANDLE_VDQM_REQUEST_EXCEPT,
5,
"Exception raised when handling a request from the VDQM"
AGGREGATOR_FAILED_TO_READ_M
AGIC,6
,"Failed to read m
agic number from socket
"
AGGREGATOR_
UNKNOWN_MAGIC,7,"Unknown magic numb
er"
AGGREGATOR_
FAILED_TO_READ_REQUEST_TYPE,8,"Failed to read request type from socket
"
AGGREGATOR_UNKNOWN_REQUEST_TYPE,
9,
"Unknown request type"
AGGREGATOR_
FAILED_TO_READ_
MESSAGE_BODY_LENGTH
,10,"Failed to read l
ength of message body"
AGGREGATOR_MESSAGE_BODY_LENGTH_TOO_
LARGE,11
,"Length of message body is too
large
"
AGGREGATOR_
JOB_MESSAGE_BODY_LENGTH_TOO_SHORT,12,"Length of job submission message body is too short
"
AGGREGATOR_
FAILED_TO_READ_MESSAGE_BODY,13,"Failed to read message body
"
AGGREGATOR_
HANDLE_JOB_MESSAGE,14,"Handle job submission message VDQM_CLIENTINFO:RTCOPY_MAGIC_OLD0
"
AGGREGATOR_SUBMIT
TING
_JOB_TO_RTCPD,
15,"S
ubmit
ting
remote copy job to RTCPD"
AGGREGATOR_FAILED_TO_
SUBMIT_JOB_TO_RTCPD,16,"Failed to submit remote copy job to RTCPD
"
AGGREGATOR_FAILED_TO_
MARSHALL
_R
T
CP_
ACKN,17
,"Failed to
marshall
R
T
CP
acknowledge message
"
AGGREGATOR_
FAILED_TO_SEN
D_R
T
CP_
ACKN_TO_VDQM,18,"Failed to send RTCP acknowledge to VDQM
"
AGGREGATOR_RECEIVED_RCP
_JOB_FROM_UNAUTHORIZED_HOST,19,"Received a remote copy job from an unauthorized host
"
AGGREGATOR_R
ECEIVED_RTCPD_ERROR_MESSAGE,20,"Received error message from RTCPD
"
AGGREGATOR_RTCPD_
HANDLER_SOCKET_IS_NULL,21,"The RtcpdHandlerThread has been passed a NULL socket pointer
"
AGGREGATOR_RTCPD_CONNECTION_WITH_INFO,
22,
"Received a connection from RTCPD"
AGGREGATOR_R
TCPD_CONNECTION_WITHOUT_INFO,23,"Received a connection from RTCPD without peer host and port information
"
AGGREGATOR_RECEIVE
D
_TAPE_REQUEST,
24,"R
eceive
d
RTCP tape request
message
from RTCPD"
AGGREGATOR_FAILED_TO_
RECEIVE_TAPE_REQUEST,25,"Failed to receive RTCP tape request from RTCPD
"
AGGREGATOR_FAILED_TO_
UN
MARSHALL_
MESSAGE_BODY,26
,"Failed to
un
marshall message
body
"
0,
AGGREGATOR_NULL," - "
1,
AGGREGATOR_STARTED,"aggregatord started"
2,
AGGREGATOR_FAILED_TO_PARSE_COMMAND_LINE,"Failed to parse the command line"
3,
AGGREGATOR_FAILED_TO_INIT_DB_SERVICE,"Failed to initialise database service"
4,
AGGREGATOR_VDQM_REQUEST_HANDLER_SOCKET_IS_NULL,"The VdqmRequestHandlerThread has been passed a NULL socket pointer"
5,
AGGREGATOR_HANDLE_VDQM_REQUEST_EXCEPT,"Exception raised when handling a request from the VDQM"
6,
AGGREGATOR_FAILED_TO_READ_M
ESSAGE_HEADER
,"Failed to read m
essage header
"
7,
AGGREGATOR_
FAILED_TO_UNMARSHALL_MESSAGE_HEADER,"Failed to unmarshall message head
er"
8,
AGGREGATOR_
UNKNOWN_MAGIC,"Unknown magic number
"
9,
AGGREGATOR_UNKNOWN_REQUEST_TYPE,"Unknown request type"
10,
AGGREGATOR_MESSAGE_BODY_LENGTH
_TOO_LARGE,"L
ength of message body
is too large
"
11,
AGGREGATOR_
JOB_
MESSAGE_BODY_LENGTH_TOO_
SHORT
,"Length of
job submission
message body is too
short
"
12,
AGGREGATOR_
FAILED_TO_READ_MESSAGE_BODY,"Failed to read message body
"
13,
AGGREGATOR_
HANDLE_JOB_MESSAGE,"Handle job submission message VDQM_CLIENTINFO:RTCOPY_MAGIC_OLD0
"
14,
AGGREGATOR_
SUBMITTING_JOB_TO_RTCPD,"Submitting remote copy job to RTCPD
"
15,
AGGREGATOR_
FAILED_TO_
SUBMIT_JOB_TO_RTCPD,
"Failed to s
ubmit remote copy job to RTCPD"
16,
AGGREGATOR_FAILED_TO_
MARSHALL_RTCP_ACKN,"Failed to marshall RTCP acknowledge message
"
17,
AGGREGATOR_FAILED_TO_
SEND
_RCP_
JOB_REPLY_TO_VDQM
,"Failed to
send
RCP
job reply to VDQM
"
18,
AGGREGATOR_
RECEIVE
D_RCP_
JOB_FROM_UNAUTHORIZED_HOST,"Received a remote copy job from an unauthorized host
"
19,
AGGREGATOR_RECEIVED_R
T
CP
D_ERROR_MESSAGE,"Received error message from RTCPD
"
20,
AGGREGATOR_R
TCPD_HANDLER_SOCKET_IS_NULL,"The RtcpdHandlerThread has been passed a NULL socket pointer
"
21,
AGGREGATOR_RTCPD_
CONNECTION_WITH_INFO,"Received a connection from RTCPD
"
22,
AGGREGATOR_RTCPD_CONNECTION_WITH
OUT
_INFO,"Received a connection from RTCPD
without peer host and port information
"
23,
AGGREGATOR_R
ECEIVED_TAPE_REQUEST,"Received RTCP tape request message from RTCPD
"
24,
AGGREGATOR_
FAILED_TO_
RECEIVE_TAPE_REQUEST,
"Failed to r
eceive RTCP tape request from RTCPD"
25,
AGGREGATOR_FAILED_TO_
UNMARSHALL_MESSAGE_BODY,"Failed to unmarshall message body
"
26,
AGGREGATOR_FAILED_TO_MARSHALL_
RCP_JOB_REPLY_MESSAGE
,"Failed to marshall
RCP job reply
message"
castor/tape/aggregator/AggregatorDlfMessagesCodeGenerator
View file @
72cca4ae
...
...
@@ -45,9 +45,9 @@ sub writeConstantsFile {
my
$currentMessageNb
=
0
;
while
(
<
MESSAGES
>
)
{
$currentMessageNb
=
$currentMessageNb
+
1
;
m/^([A-Z0-9_]*),(
\d*),(
.*)/
;
$const_
name
=
$
1
;
$const_
val
=
$
2
;
m/^(
\d*),(
[A-Z0-9_]*),(.*)/
;
$const_
val
=
$
1
;
$const_
name
=
$
2
;
$msg
=
$
3
;
# If this is not the last message
...
...
@@ -98,9 +98,9 @@ sub writeStringsFile {
my
$const_val
;
my
$msg
;
while
(
<
MESSAGES
>
)
{
m/^([A-Z0-9_]*),(
\d*),(.*)
/
;
$const_
name
=
$
1
;
$const_
val
=
$
2
;
m/^(
\d*),(
[A-Z0-9_]*),(
".*")$
/
;
$const_
val
=
$
1
;
$const_
name
=
$
2
;
$msg
=
$
3
;
print
(
STRINGS
"
{
${const_name}
,
${msg}
},
\n
");
...
...
castor/tape/aggregator/Imakefile
View file @
72cca4ae
...
...
@@ -39,8 +39,7 @@ AGGREGATORBIN_SRCS = \
RcpJobSubmitter.cpp \
RtcpdHandlerThread.cpp \
SocketHelper.cpp \
VdqmRequestHandlerThread.cpp \
exception/RTCPDErrorMessage.cpp
VdqmRequestHandlerThread.cpp
AGGREGATORBIN_OBJS = $(AGGREGATORBIN_SRCS:.cpp=.Osuf)
NormalProgramTarget(aggregatord,$(AGGREGATORBIN_OBJS),$(DEPLIB),$(LIBS),root,bin,750)
...
...
castor/tape/aggregator/Marshaller.cpp
View file @
72cca4ae
...
...
@@ -211,10 +211,78 @@ void castor::tape::aggregator::Marshaller::unmarshallString(const char * &src,
//-----------------------------------------------------------------------------
// marshall
RcpJobRequest
// marshall
MessageHeader
//-----------------------------------------------------------------------------
size_t
castor
::
tape
::
aggregator
::
Marshaller
::
marshallRcpJobRequest
(
char
*
const
dst
,
const
size_t
dstLen
,
const
RcpJobRequest
&
src
)
size_t
castor
::
tape
::
aggregator
::
Marshaller
::
marshallMessageHeader
(
char
*
const
dst
,
const
size_t
dstLen
,
const
MessageHeader
&
src
)
throw
(
castor
::
exception
::
Exception
)
{
if
(
dst
==
NULL
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Pointer to destination buffer is NULL"
;
throw
ex
;
}
// Calculate the length of the message header
const
uint32_t
totalLen
=
3
*
sizeof
(
uint32_t
);
// magic + reqtype + len
// Check that the message header buffer is big enough
if
(
totalLen
>
dstLen
)
{
castor
::
exception
::
Exception
ex
(
EMSGSIZE
);
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Buffer too small for message header: "
"Required size: "
<<
totalLen
<<
" Actual size: "
<<
dstLen
;
throw
ex
;
}
// Marshall the message header
char
*
p
=
dst
;
marshallUint32
(
src
.
magic
,
p
);
marshallUint32
(
src
.
reqtype
,
p
);
marshallUint32
(
src
.
len
,
p
);
// Calculate the number of bytes actually marshalled
const
size_t
nbBytesMarshalled
=
p
-
dst
;
// Check that the number of bytes marshalled was what was expected
if
(
totalLen
!=
nbBytesMarshalled
)
{
castor
::
exception
::
Internal
ie
;
ie
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Mismatch between the expected total length of the "
"message header and the actual number of bytes marshalled"
": Expected: "
<<
totalLen
<<
": Marshalled: "
<<
nbBytesMarshalled
;
throw
ie
;
}
return
totalLen
;
}
//-----------------------------------------------------------------------------
// unmarshallMessageHeader
//-----------------------------------------------------------------------------
void
castor
::
tape
::
aggregator
::
Marshaller
::
unmarshallMessageHeader
(
const
char
*
&
src
,
size_t
&
srcLen
,
MessageHeader
&
dst
)
throw
(
castor
::
exception
::
Exception
)
{
unmarshallUint32
(
src
,
srcLen
,
dst
.
magic
);
unmarshallUint32
(
src
,
srcLen
,
dst
.
reqtype
);
unmarshallUint32
(
src
,
srcLen
,
dst
.
len
);
}
//-----------------------------------------------------------------------------
// marshallRcpJobRequestMessage
//-----------------------------------------------------------------------------
size_t
castor
::
tape
::
aggregator
::
Marshaller
::
marshallRcpJobRequestMessage
(
char
*
const
dst
,
const
size_t
dstLen
,
const
RcpJobRequestMessage
&
src
)
throw
(
castor
::
exception
::
Exception
)
{
if
(
dst
==
NULL
)
{
...
...
@@ -243,8 +311,9 @@ size_t castor::tape::aggregator::Marshaller::marshallRcpJobRequest(
castor
::
exception
::
Exception
ex
(
EMSGSIZE
);
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Buffer too small for job submission request message: "
"Required size: "
<<
totalLen
<<
" Actual size: "
<<
dstLen
;
<<
": Buffer too small for job submission request message"
": Required size: "
<<
totalLen
<<
": Actual size: "
<<
dstLen
;
throw
ex
;
}
...
...
@@ -272,9 +341,10 @@ size_t castor::tape::aggregator::Marshaller::marshallRcpJobRequest(
ie
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Mismatch between the expected total length of the "
"RCP job submission request message and the actual number of bytes "
"marshalled: Expected length: "
<<
totalLen
<<
" Marshalled: "
<<
nbBytesMarshalled
;
"RCP job submission request message and the actual number of bytes "
"marshalled"
": Expected: "
<<
totalLen
<<
": Marshalled: "
<<
nbBytesMarshalled
;
throw
ie
;
}
...
...
@@ -284,58 +354,30 @@ size_t castor::tape::aggregator::Marshaller::marshallRcpJobRequest(
//-----------------------------------------------------------------------------
// unmarshallRcpJobRequest
// unmarshallRcpJobRequest
Message
//-----------------------------------------------------------------------------
void
castor
::
tape
::
aggregator
::
Marshaller
::
unmarshallRcpJobRequest
(
const
char
*
&
src
,
size_t
&
srcLen
,
RcpJobRequest
&
dst
)
void
castor
::
tape
::
aggregator
::
Marshaller
::
unmarshallRcpJobRequest
Message
(
const
char
*
&
src
,
size_t
&
srcLen
,
RcpJobRequest
Message
&
dst
)
throw
(
castor
::
exception
::
Exception
)
{
unmarshallUint32
(
src
,
srcLen
,
dst
.
tapeRequestID
);
unmarshallUint32
(
src
,
srcLen
,
dst
.
clientPort
);
unmarshallUint32
(
src
,
srcLen
,
dst
.
clientEuid
);
unmarshallUint32
(
src
,
srcLen
,
dst
.
clientEgid
);
unmarshallString
(
src
,
srcLen
,
dst
.
clientHost
,
sizeof
(
dst
.
clientHost
));
unmarshallString
(
src
,
srcLen
,
dst
.
deviceGroupName
,
sizeof
(
dst
.
deviceGroupName
));
unmarshallString
(
src
,
srcLen
,
dst
.
driveName
,
sizeof
(
dst
.
driveName
));
unmarshallString
(
src
,
srcLen
,
dst
.
clientUserName
,
sizeof
(
dst
.
clientUserName
));
unmarshallString
(
src
,
srcLen
,
dst
.
clientHost
);
unmarshallString
(
src
,
srcLen
,
dst
.
deviceGroupName
);
unmarshallString
(
src
,
srcLen
,
dst
.
driveName
);
unmarshallString
(
src
,
srcLen
,
dst
.
clientUserName
);
}
//-----------------------------------------------------------------------------
//
un
marshallRcpJobReply
// marshallRcpJobReply
Message
//-----------------------------------------------------------------------------
void
castor
::
tape
::
aggregator
::
Marshaller
::
un
marshallRcpJobReply
(
c
onst
char
*
&
src
,
size_t
&
srcLen
,
RcpJobReply
&
dst
)
size_t
castor
::
tape
::
aggregator
::
Marshaller
::
marshallRcpJobReply
Message
(
c
har
*
const
dst
,
const
size_t
dstLen
,
const
RcpJobReplyMessage
&
src
)
throw
(
castor
::
exception
::
Exception
)
{
// Unmarshall the status number
Marshaller
::
unmarshallUint32
(
src
,
srcLen
,
dst
.
status
);
// The error message will be right trimmed if it is too large
const
size_t
maxBytesToUnmarshall
=
srcLen
<
sizeof
(
dst
.
errorMessage
)
?
srcLen
:
sizeof
(
dst
.
errorMessage
);
// Unmarshall the error message
if
(
maxBytesToUnmarshall
>
0
)
{
strncpy
(
dst
.
errorMessage
,
src
,
maxBytesToUnmarshall
);
dst
.
errorMessage
[
maxBytesToUnmarshall
-
1
]
=
'\0'
;
src
=
src
+
strlen
(
dst
.
errorMessage
)
+
1
;
srcLen
=
srcLen
-
strlen
(
dst
.
errorMessage
)
-
1
;
}
else
{
dst
.
errorMessage
[
0
]
=
'\0'
;
// No need to update src or srcLen
}
}
//-----------------------------------------------------------------------------
// marshallRtcpAckn
//-----------------------------------------------------------------------------
size_t
castor
::
tape
::
aggregator
::
Marshaller
::
marshallRtcpAckn
(
char
*
const
dst
,
const
size_t
dstLen
,
const
uint32_t
status
,
const
char
*
errorMsg
)
throw
(
castor
::
exception
::
Exception
)
{
if
(
dst
==
NULL
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
...
...
@@ -345,64 +387,56 @@ size_t castor::tape::aggregator::Marshaller::marshallRtcpAckn(char *const dst,
}
// Minimum buffer length = magic number + request type + length + status code
// + the string termination character '\0'
if
(
dstLen
<
4
*
sizeof
(
uint32_t
)
+
1
)
{
// + terminating null character
const
size_t
minimumLen
=
4
*
sizeof
(
uint32_t
)
+
1
;
if
(
dstLen
<
minimumLen
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Destination buffer length is too small
:
"
"
Expected minimum
length: "
<<
(
4
*
sizeof
(
uint32_t
)
+
1
)
<<
": Actual
length
: "
<<
dstLen
;
<<
": Destination buffer length is too small"
":
Expected minimum
: "
<<
minimumLen
<<
": Actual: "
<<
dstLen
;
throw
ex
;
}
if
(
errorMsg
==
NULL
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
// Calculate the length of the error message to be sent taking into account
// the fact that the error message should be right trimmed if it is too large
// to fit in the destination buffer.
const
size_t
headerLen
=
3
*
sizeof
(
uint32_t
);
// magic + reqtype + len
// free space = total - header - status - terminating null character
const
size_t
freeSpace
=
dstLen
-
headerLen
-
sizeof
(
uint32_t
)
-
1
;
const
size_t
errLenToSend
=
strlen
(
src
.
errorMessage
)
<
freeSpace
?
strlen
(
src
.
errorMessage
)
:
freeSpace
;
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Pointer to error message is NULL"
;
throw
ex
;
}
// Calculate the length of the message body
// Message body = status + error message + terminating null character
const
uint32_t
len
=
sizeof
(
src
.
status
)
+
errLenToSend
+
1
;
const
size_t
errorMsgLen
=
strlen
(
errorMsg
);
const
size_t
maxErrorMsgLen
=
dstLen
-
4
*
sizeof
(
uint32_t
)
-
1
;
const
size_t
errorMsg2SendLen
=
errorMsgLen
>
maxErrorMsgLen
?
maxErrorMsgLen
:
errorMsgLen
;
// Calculate the total length of the message (header + body)
const
size_t
totalLen
=
headerLen
+
len
;
// Length of message body equals the size fo the status code plus the length
// of the error message string plus the size of the string termination
// characater '\0'
const
uint32_t
len
=
sizeof
(
uint32_t
)
+
errorMsg2SendLen
+
1
;
char
*
p
=
dst
;
marshallUint32
(
RTCOPY_MAGIC_OLD0
,
p
);
// Magic number
marshallUint32
(
VDQM_CLIENTINFO
,
p
);
// Request type
marshallUint32
(
len
,
p
);
// Length
marshallUint32
(
status
,
p
);
// status code
// Marshall the error message without the terminatiing null byte
memcpy
(
p
,
errorMsg
,
errorMsg2SendLen
);
p
+=
errorMsg2SendLen
;
marshallUint32
(
src
.
status
,
p
);
// status code
// Marshall the terminatiing null byte of the
error
m
essage
*
p
=
'
\
0'
;
p
+
=
1
;
strncpy
(
p
,
src
.
error
M
essage
,
errLenToSend
);
*
(
p
+
errLenToSend
)
=
'0'
;
p
=
p
+
errLenToSend
+
1
;
// Calculate the number of bytes actually marshalled
const
size_t
nbBytesMarshalled
=
p
-
dst
;
// Calculate the total length of the message (header + body)
// Message header = magic + reqtype + len = 3 * sizeof(uint32_t)
const
size_t
totalLen
=
3
*
sizeof
(
uint32_t
)
+
len
;
// Check that the number of bytes marshalled was what was expected
if
(
totalLen
!=
nbBytesMarshalled
)
{
castor
::
exception
::
Internal
ie
;
ie
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Mismatch between the expected total length of the "
"RTCP acknowledge message and the actual number of bytes marshalled: "
"Expected length: "
<<
totalLen
<<
" Marshalled: "
<<
nbBytesMarshalled
;
"RCP job reply message and the actual number of bytes marshalled"
": Expected: "
<<
totalLen
<<
": Marshalled: "
<<
nbBytesMarshalled
;
throw
ie
;
}
...
...
@@ -412,10 +446,37 @@ size_t castor::tape::aggregator::Marshaller::marshallRtcpAckn(char *const dst,
//-----------------------------------------------------------------------------
// marshallR
t
cp
TapeRequest
//
un
marshallRcp
JobReplyMessage
//-----------------------------------------------------------------------------
size_t
castor
::
tape
::
aggregator
::
Marshaller
::
marshallRtcpTapeRequest
(
char
*
dst
,
const
size_t
dstLen
,
const
RtcpTapeRequest
&
src
)
void
castor
::
tape
::
aggregator
::
Marshaller
::
unmarshallRcpJobReplyMessage
(
const
char
*
&
src
,
size_t
&
srcLen
,
RcpJobReplyMessage
&
dst
)
throw
(
castor
::
exception
::
Exception
)
{
// Unmarshall the status number
Marshaller
::
unmarshallUint32
(
src
,
srcLen
,
dst
.
status
);
// The error message will be right trimmed if it is too large
const
size_t
maxBytesToUnmarshall
=
srcLen
<
sizeof
(
dst
.
errorMessage
)
?
srcLen
:
sizeof
(
dst
.
errorMessage
);
// Unmarshall the error message
if
(
maxBytesToUnmarshall
>
0
)
{
strncpy
(
dst
.
errorMessage
,
src
,
maxBytesToUnmarshall
);
dst
.
errorMessage
[
maxBytesToUnmarshall
-
1
]
=
'\0'
;
src
=
src
+
strlen
(
dst
.
errorMessage
)
+
1
;
srcLen
=
srcLen
-
strlen
(
dst
.
errorMessage
)
-
1
;
}
else
{
dst
.
errorMessage
[
0
]
=
'\0'
;
// No need to update src or srcLen
}
}
//-----------------------------------------------------------------------------
// marshallRtcpTapeRequestMessage
//-----------------------------------------------------------------------------
size_t
castor
::
tape
::
aggregator
::
Marshaller
::
marshallRtcpTapeRequestMessage
(
char
*
dst
,
const
size_t
dstLen
,
const
RtcpTapeRequestMessage
&
src
)
throw
(
castor
::
exception
::
Exception
)
{
// Calculate the length of the message body
...
...
@@ -498,8 +559,9 @@ size_t castor::tape::aggregator::Marshaller::marshallRtcpTapeRequest(char *dst,
ie
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Mismatch between the expected total length of the "
"RTCP tape request message and the actual number of bytes marshalled: "
"Expected length: "
<<
totalLen
<<
" Marshalled: "
<<
nbBytesMarshalled
;
"RTCP tape request message and the actual number of bytes marshalled"
": Expected: "
<<
totalLen
<<
": Marshalled: "
<<
nbBytesMarshalled
;
throw
ie
;
}
...
...
@@ -509,10 +571,10 @@ size_t castor::tape::aggregator::Marshaller::marshallRtcpTapeRequest(char *dst,
//-----------------------------------------------------------------------------
// unmarshallRtcpTapeRequest
// unmarshallRtcpTapeRequest
Message
//-----------------------------------------------------------------------------
void
castor
::
tape
::
aggregator
::
Marshaller
::
unmarshallRtcpTapeRequest
(
const
char
*
&
src
,
size_t
&
srcLen
,
RtcpTapeRequest
&
dst
)
void
castor
::
tape
::
aggregator
::
Marshaller
::
unmarshallRtcpTapeRequest
Message
(
const
char
*
&
src
,
size_t
&
srcLen
,
RtcpTapeRequest
Message
&
dst
)
throw
(
castor
::
exception
::
Exception
)
{
unmarshallString
(
src
,
srcLen
,
dst
.
vid
);
...
...
@@ -552,3 +614,75 @@ void castor::tape::aggregator::Marshaller::unmarshallRtcpTapeRequest(
unmarshallUint32
(
src
,
srcLen
,
dst
.
err
.
max_tpretry
);
unmarshallUint32
(
src
,
srcLen
,
dst
.
err
.
max_cpretry
);
}
//-----------------------------------------------------------------------------
// marshallRtcpAcknowledgeMessage
//-----------------------------------------------------------------------------
size_t
castor
::
tape
::
aggregator
::
Marshaller
::
marshallRtcpAcknowledgeMessage
(
char
*
const
dst
,
const
size_t
dstLen
,
const
RtcpAcknowledgeMessage
&
src
)
throw
(
castor
::
exception
::
Exception
)
{
castor
::
exception
::
Internal
ie
;
if
(
dst
==
NULL
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Pointer to destination buffer is NULL"
;
throw
ex
;
}
// Calculate the total length of the message (there is no separate header and
// body)
const
uint32_t
totalLen
=
3
*
sizeof
(
uint32_t
);
// magic + reqtype + status
// Check that the message buffer is big enough
if
(
totalLen
>
dstLen
)
{
castor
::
exception
::
Exception
ex
(
EMSGSIZE
);
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Buffer too small for RTCP acknowledge message"
": Required size: "
<<
totalLen
<<
": Actual size: "
<<
dstLen
;
throw
ex
;
}
// Marshall the message
char
*
p
=
dst
;
marshallUint32
(
src
.
magic
,
p
);
marshallUint32
(
src
.
reqtype
,
p
);
marshallUint32
(
src
.
status
,
p
);
// Calculate the number of bytes actually marshalled
const
size_t
nbBytesMarshalled
=
p
-
dst
;
// Check that the number of bytes marshalled was what was expected
if
(
totalLen
!=
nbBytesMarshalled
)
{
castor
::
exception
::
Internal
ie
;
ie
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Mismatch between the expected total length of the "
"RTCP acknowledge message and the actual number of bytes "
"marshalled"
": Expected: "
<<
totalLen
<<
": Marshalled: "
<<
nbBytesMarshalled
;
throw
ie
;
}
return
totalLen
;
}
//-----------------------------------------------------------------------------
// unmarshallRtcpAcknowledgeMessage
//-----------------------------------------------------------------------------
void
castor
::
tape
::
aggregator
::
Marshaller
::
unmarshallRtcpAcknowledgeMessage
(
const
char
*
&
src
,
size_t
&
srcLen
,
RtcpAcknowledgeMessage
&
dst
)
throw
(
castor
::
exception
::
Exception
)
{
unmarshallUint32
(
src
,
srcLen
,
dst
.
magic
);
unmarshallUint32
(
src
,
srcLen
,
dst
.
reqtype
);
unmarshallUint32
(
src
,
srcLen
,
dst
.
status
);
}