use
constant
LEGACY_PAYLOAD_MAX
=> 262120;
CALL
=> 0,
REPLY
=> 1,
MESSAGE
=> 2,
STREAM
=> 3,
CALL_WITH_FDS
=> 4,
REPLY_WITH_FDS
=> 5,
STREAM_HOLE
=> 6,
};
sub
deserialize_Type {
my
$input_length
=
length
$_
[3];
die
"Input buffer too short"
if
(
$input_length
-
$_
[2]) < 4;
$_
[1] =
unpack
(
"l>"
,
substr
(
$_
[3],
$_
[2] ) );
die
"Out of range enum value supplied: $_[1]"
unless
vec
(state
$m
=
pack
(
'H*'
,
'7f'
),
$_
[1], 1);
$_
[2] += 4;
}
sub
serialize_Type {
croak
"Missing required input 'enum' value"
unless
defined
$_
[1];
die
"Out of range enum value: $_[1]"
unless
vec
(state
$m
=
pack
(
'H*'
,
'7f'
),
$_
[1], 1);
substr
(
$_
[3],
$_
[2] ) =
pack
(
"l>"
,
$_
[1]);
$_
[2] += 4;
}
OK
=> 0,
ERROR
=> 1,
CONTINUE
=> 2,
};
sub
deserialize_Status {
my
$input_length
=
length
$_
[3];
die
"Input buffer too short"
if
(
$input_length
-
$_
[2]) < 4;
$_
[1] =
unpack
(
"l>"
,
substr
(
$_
[3],
$_
[2] ) );
die
"Out of range enum value supplied: $_[1]"
unless
vec
(state
$m
=
pack
(
'H*'
,
'07'
),
$_
[1], 1);
$_
[2] += 4;
}
sub
serialize_Status {
croak
"Missing required input 'enum' value"
unless
defined
$_
[1];
die
"Out of range enum value: $_[1]"
unless
vec
(state
$m
=
pack
(
'H*'
,
'07'
),
$_
[1], 1);
substr
(
$_
[3],
$_
[2] ) =
pack
(
"l>"
,
$_
[1]);
$_
[2] += 4;
}
sub
deserialize_Header {
my
$input_length
=
length
$_
[3];
$_
[1] = {};
die
"Input buffer too short"
if
(
$input_length
-
$_
[2]) < 4;
$_
[1]->{prog} =
unpack
(
"L>"
,
substr
(
$_
[3],
$_
[2] ));
$_
[2] += 4;
die
"Out of bounds 'unsigned int': $_[1]->{prog}"
unless
(0 <=
$_
[1]->{prog} and
$_
[1]->{prog} <= 4294967295);
die
"Input buffer too short"
if
(
$input_length
-
$_
[2]) < 4;
$_
[1]->{vers} =
unpack
(
"L>"
,
substr
(
$_
[3],
$_
[2] ));
$_
[2] += 4;
die
"Out of bounds 'unsigned int': $_[1]->{vers}"
unless
(0 <=
$_
[1]->{vers} and
$_
[1]->{vers} <= 4294967295);
die
"Input buffer too short"
if
(
$input_length
-
$_
[2]) < 4;
$_
[1]->{proc} =
unpack
(
"l>"
,
substr
(
$_
[3],
$_
[2] ));
$_
[2] += 4;
die
"Out of bounds 'int': $_[1]->{proc}"
unless
(-2147483648 <=
$_
[1]->{proc} and
$_
[1]->{proc} < 2147483648);
$_
[0]->deserialize_Type(
$_
[1]->{type},
$_
[2],
$_
[3] );
die
"Input buffer too short"
if
(
$input_length
-
$_
[2]) < 4;
$_
[1]->{serial} =
unpack
(
"L>"
,
substr
(
$_
[3],
$_
[2] ));
$_
[2] += 4;
die
"Out of bounds 'unsigned int': $_[1]->{serial}"
unless
(0 <=
$_
[1]->{serial} and
$_
[1]->{serial} <= 4294967295);
$_
[0]->deserialize_Status(
$_
[1]->{status},
$_
[2],
$_
[3] );
}
sub
serialize_Header {
croak
"Missing required input 'struct' value"
unless
defined
$_
[1];
croak
"Missing required input value 'prog'"
unless
exists
$_
[1]->{prog};
croak
"Missing required input 'unsigned int' value"
unless
defined
$_
[1]->{prog};
die
"Out of bounds 'unsigned int': $_[1]->{prog}"
unless
(0 <=
$_
[1]->{prog} and
$_
[1]->{prog} <= 4294967295);
die
"Non-integer 'int' value given: $_[1]->{prog}"
unless
int
(
$_
[1]->{prog}) ==
$_
[1]->{prog};
substr
(
$_
[3],
$_
[2] ) =
pack
(
"L>"
,
$_
[1]->{prog});
$_
[2] += 4;
croak
"Missing required input value 'vers'"
unless
exists
$_
[1]->{vers};
croak
"Missing required input 'unsigned int' value"
unless
defined
$_
[1]->{vers};
die
"Out of bounds 'unsigned int': $_[1]->{vers}"
unless
(0 <=
$_
[1]->{vers} and
$_
[1]->{vers} <= 4294967295);
die
"Non-integer 'int' value given: $_[1]->{vers}"
unless
int
(
$_
[1]->{vers}) ==
$_
[1]->{vers};
substr
(
$_
[3],
$_
[2] ) =
pack
(
"L>"
,
$_
[1]->{vers});
$_
[2] += 4;
croak
"Missing required input value 'proc'"
unless
exists
$_
[1]->{proc};
croak
"Missing required input 'int' value"
unless
defined
$_
[1]->{proc};
die
"Out of bounds 'int': $_[1]->{proc}"
unless
(-2147483648 <=
$_
[1]->{proc} and
$_
[1]->{proc} < 2147483648);
die
"Non-integer 'int' value given: $_[1]->{proc}"
unless
int
(
$_
[1]->{proc}) ==
$_
[1]->{proc};
substr
(
$_
[3],
$_
[2] ) =
pack
(
"l>"
,
$_
[1]->{proc});
$_
[2] += 4;
croak
"Missing required input value 'type'"
unless
exists
$_
[1]->{type};
$_
[0]->serialize_Type(
$_
[1]->{type},
$_
[2],
$_
[3] );
croak
"Missing required input value 'serial'"
unless
exists
$_
[1]->{serial};
croak
"Missing required input 'unsigned int' value"
unless
defined
$_
[1]->{serial};
die
"Out of bounds 'unsigned int': $_[1]->{serial}"
unless
(0 <=
$_
[1]->{serial} and
$_
[1]->{serial} <= 4294967295);
die
"Non-integer 'int' value given: $_[1]->{serial}"
unless
int
(
$_
[1]->{serial}) ==
$_
[1]->{serial};
substr
(
$_
[3],
$_
[2] ) =
pack
(
"L>"
,
$_
[1]->{serial});
$_
[2] += 4;
croak
"Missing required input value 'status'"
unless
exists
$_
[1]->{status};
$_
[0]->serialize_Status(
$_
[1]->{status},
$_
[2],
$_
[3] );
}
sub
deserialize_UUID {
my
$input_length
=
length
$_
[3];
die
"Input buffer too short"
if
(
$input_length
-
$_
[2]) < 16;
$_
[1] =
substr
(
$_
[3],
$_
[2], 16 );
$_
[2] += 16;
}
sub
serialize_UUID {
croak
"Missing required input 'opaque' value"
unless
defined
$_
[1];
do
{
my
$len
=
length
$_
[1];
die
"Opaque value length mismatch (defined: 16): $len"
if
not
$len
== 16;
substr
(
$_
[3],
$_
[2] ) =
$_
[1];
$_
[2] +=
$len
;
};
}
sub
deserialize_NonnullString {
my
$input_length
=
length
$_
[3];
do
{
die
"Input buffer too short"
if
(
$input_length
-
$_
[2]) < 4;
my
$len
=
unpack
(
"L>"
,
substr
(
$_
[3],
$_
[2] ));
$_
[2] += 4;
die
"String too long (max: 4194304): $len"
unless
(
$len
<= 4194304);
die
"Input buffer too short"
if
(
$input_length
-
$_
[2]) <
$len
;
$_
[1] =
substr
(
$_
[3],
$_
[2],
$len
);
$_
[2] +=
$len
+ ((4 - (
$len
% 4)) % 4);
};
}
sub
serialize_NonnullString {
do
{
my
$len
=
length
$_
[1];
croak
"Missing required input 'string' value"
unless
defined
$_
[1];
die
"String too long (max: 4194304): $len"
unless
(
$len
<= 4194304);
substr
(
$_
[3],
$_
[2] ) =
pack
(
"L>"
,
$len
);
$_
[2] += 4;
substr
(
$_
[3],
$_
[2] ) =
$_
[1];
$_
[2] +=
$len
;
if
(
my
$pad
= ((4 - (
$len
% 4)) % 4)) {
substr
(
$_
[3],
$_
[2] ) = (
"\0"
x
$pad
);
$_
[2] +=
$pad
;
}
};
}
sub
deserialize_String {
my
$input_length
=
length
$_
[3];
do
{
my
$b
;
die
"Input buffer too short"
if
(
$input_length
-
$_
[2]) < 4;
$b
=
unpack
(
"L>"
,
substr
(
$_
[3],
$_
[2] ));
die
"Incorrect bool value $b (must be 0 or 1)"
unless
$b
== 0 or
$b
== 1;
$_
[2] += 4;
if
(
$b
) {
$_
[0]->deserialize_NonnullString(
$_
[1],
$_
[2],
$_
[3] );
}
else
{
$_
[1] =
undef
;
}
};
}
sub
serialize_String {
if
(
defined
$_
[1]) {
substr
(
$_
[3],
$_
[2] ) =
pack
(
"L>"
, 1);
$_
[2] += 4;
$_
[0]->serialize_NonnullString(
$_
[1],
$_
[2],
$_
[3] );
}
else
{
substr
(
$_
[3],
$_
[2] ) =
pack
(
"L>"
, 0);
$_
[2] += 4;
}
}
sub
deserialize_NonnullDomain {
my
$input_length
=
length
$_
[3];
$_
[1] = {};
$_
[0]->deserialize_NonnullString(
$_
[1]->{name},
$_
[2],
$_
[3] );
$_
[0]->deserialize_UUID(
$_
[1]->{uuid},
$_
[2],
$_
[3] );
die
"Input buffer too short"
if
(
$input_length
-
$_
[2]) < 4;
$_
[1]->{id} =
unpack
(
"l>"
,
substr
(
$_
[3],
$_
[2] ));
$_
[2] += 4;
die
"Out of bounds 'int': $_[1]->{id}"
unless
(-2147483648 <=
$_
[1]->{id} and
$_
[1]->{id} < 2147483648);
}
sub
serialize_NonnullDomain {
croak
"Missing required input 'struct' value"
unless
defined
$_
[1];
croak
"Missing required input value 'name'"
unless
exists
$_
[1]->{name};
$_
[0]->serialize_NonnullString(
$_
[1]->{name},
$_
[2],
$_
[3] );
croak
"Missing required input value 'uuid'"
unless
exists
$_
[1]->{uuid};
$_
[0]->serialize_UUID(
$_
[1]->{uuid},
$_
[2],
$_
[3] );
croak
"Missing required input value 'id'"
unless
exists
$_
[1]->{id};
croak
"Missing required input 'int' value"
unless
defined
$_
[1]->{id};
die
"Out of bounds 'int': $_[1]->{id}"
unless
(-2147483648 <=
$_
[1]->{id} and
$_
[1]->{id} < 2147483648);
die
"Non-integer 'int' value given: $_[1]->{id}"
unless
int
(
$_
[1]->{id}) ==
$_
[1]->{id};
substr
(
$_
[3],
$_
[2] ) =
pack
(
"l>"
,
$_
[1]->{id});
$_
[2] += 4;
}
sub
deserialize_NonnullNetwork {
my
$input_length
=
length
$_
[3];
$_
[1] = {};
$_
[0]->deserialize_NonnullString(
$_
[1]->{name},
$_
[2],
$_
[3] );
$_
[0]->deserialize_UUID(
$_
[1]->{uuid},
$_
[2],
$_
[3] );
}
sub
serialize_NonnullNetwork {
croak
"Missing required input 'struct' value"
unless
defined
$_
[1];
croak
"Missing required input value 'name'"
unless
exists
$_
[1]->{name};
$_
[0]->serialize_NonnullString(
$_
[1]->{name},
$_
[2],
$_
[3] );
croak
"Missing required input value 'uuid'"
unless
exists
$_
[1]->{uuid};
$_
[0]->serialize_UUID(
$_
[1]->{uuid},
$_
[2],
$_
[3] );
}
sub
deserialize_Domain {
my
$input_length
=
length
$_
[3];
do
{
my
$b
;
die
"Input buffer too short"
if
(
$input_length
-
$_
[2]) < 4;
$b
=
unpack
(
"L>"
,
substr
(
$_
[3],
$_
[2] ));
die
"Incorrect bool value $b (must be 0 or 1)"
unless
$b
== 0 or
$b
== 1;
$_
[2] += 4;
if
(
$b
) {
$_
[0]->deserialize_NonnullDomain(
$_
[1],
$_
[2],
$_
[3] );
}
else
{
$_
[1] =
undef
;
}
};
}
sub
serialize_Domain {
if
(
defined
$_
[1]) {
substr
(
$_
[3],
$_
[2] ) =
pack
(
"L>"
, 1);
$_
[2] += 4;
$_
[0]->serialize_NonnullDomain(
$_
[1],
$_
[2],
$_
[3] );
}
else
{
substr
(
$_
[3],
$_
[2] ) =
pack
(
"L>"
, 0);
$_
[2] += 4;
}
}
sub
deserialize_Network {
my
$input_length
=
length
$_
[3];
do
{
my
$b
;
die
"Input buffer too short"
if
(
$input_length
-
$_
[2]) < 4;
$b
=
unpack
(
"L>"
,
substr
(
$_
[3],
$_
[2] ));
die
"Incorrect bool value $b (must be 0 or 1)"
unless
$b
== 0 or
$b
== 1;
$_
[2] += 4;
if
(
$b
) {
$_
[0]->deserialize_NonnullNetwork(
$_
[1],
$_
[2],
$_
[3] );
}
else
{
$_
[1] =
undef
;
}
};
}
sub
serialize_Network {
if
(
defined
$_
[1]) {
substr
(
$_
[3],
$_
[2] ) =
pack
(
"L>"
, 1);
$_
[2] += 4;
$_
[0]->serialize_NonnullNetwork(
$_
[1],
$_
[2],
$_
[3] );
}
else
{
substr
(
$_
[3],
$_
[2] ) =
pack
(
"L>"
, 0);
$_
[2] += 4;
}
}
sub
deserialize_Error {
my
$input_length
=
length
$_
[3];
$_
[1] = {};
die
"Input buffer too short"
if
(
$input_length
-
$_
[2]) < 4;
$_
[1]->{code} =
unpack
(
"l>"
,
substr
(
$_
[3],
$_
[2] ));
$_
[2] += 4;
die
"Out of bounds 'int': $_[1]->{code}"
unless
(-2147483648 <=
$_
[1]->{code} and
$_
[1]->{code} < 2147483648);
die
"Input buffer too short"
if
(
$input_length
-
$_
[2]) < 4;
$_
[1]->{domain} =
unpack
(
"l>"
,
substr
(
$_
[3],
$_
[2] ));
$_
[2] += 4;
die
"Out of bounds 'int': $_[1]->{domain}"
unless
(-2147483648 <=
$_
[1]->{domain} and
$_
[1]->{domain} < 2147483648);
$_
[0]->deserialize_String(
$_
[1]->{message},
$_
[2],
$_
[3] );
die
"Input buffer too short"
if
(
$input_length
-
$_
[2]) < 4;
$_
[1]->{level} =
unpack
(
"l>"
,
substr
(
$_
[3],
$_
[2] ));
$_
[2] += 4;
die
"Out of bounds 'int': $_[1]->{level}"
unless
(-2147483648 <=
$_
[1]->{level} and
$_
[1]->{level} < 2147483648);
$_
[0]->deserialize_Domain(
$_
[1]->{dom},
$_
[2],
$_
[3] );
$_
[0]->deserialize_String(
$_
[1]->{str1},
$_
[2],
$_
[3] );
$_
[0]->deserialize_String(
$_
[1]->{str2},
$_
[2],
$_
[3] );
$_
[0]->deserialize_String(
$_
[1]->{str3},
$_
[2],
$_
[3] );
die
"Input buffer too short"
if
(
$input_length
-
$_
[2]) < 4;
$_
[1]->{int1} =
unpack
(
"l>"
,
substr
(
$_
[3],
$_
[2] ));
$_
[2] += 4;
die
"Out of bounds 'int': $_[1]->{int1}"
unless
(-2147483648 <=
$_
[1]->{int1} and
$_
[1]->{int1} < 2147483648);
die
"Input buffer too short"
if
(
$input_length
-
$_
[2]) < 4;
$_
[1]->{int2} =
unpack
(
"l>"
,
substr
(
$_
[3],
$_
[2] ));
$_
[2] += 4;
die
"Out of bounds 'int': $_[1]->{int2}"
unless
(-2147483648 <=
$_
[1]->{int2} and
$_
[1]->{int2} < 2147483648);
$_
[0]->deserialize_Network(
$_
[1]->{net},
$_
[2],
$_
[3] );
}
sub
serialize_Error {
croak
"Missing required input 'struct' value"
unless
defined
$_
[1];
croak
"Missing required input value 'code'"
unless
exists
$_
[1]->{code};
croak
"Missing required input 'int' value"
unless
defined
$_
[1]->{code};
die
"Out of bounds 'int': $_[1]->{code}"
unless
(-2147483648 <=
$_
[1]->{code} and
$_
[1]->{code} < 2147483648);
die
"Non-integer 'int' value given: $_[1]->{code}"
unless
int
(
$_
[1]->{code}) ==
$_
[1]->{code};
substr
(
$_
[3],
$_
[2] ) =
pack
(
"l>"
,
$_
[1]->{code});
$_
[2] += 4;
croak
"Missing required input value 'domain'"
unless
exists
$_
[1]->{domain};
croak
"Missing required input 'int' value"
unless
defined
$_
[1]->{domain};
die
"Out of bounds 'int': $_[1]->{domain}"
unless
(-2147483648 <=
$_
[1]->{domain} and
$_
[1]->{domain} < 2147483648);
die
"Non-integer 'int' value given: $_[1]->{domain}"
unless
int
(
$_
[1]->{domain}) ==
$_
[1]->{domain};
substr
(
$_
[3],
$_
[2] ) =
pack
(
"l>"
,
$_
[1]->{domain});
$_
[2] += 4;
croak
"Missing required input value 'message'"
unless
exists
$_
[1]->{message};
$_
[0]->serialize_String(
$_
[1]->{message},
$_
[2],
$_
[3] );
croak
"Missing required input value 'level'"
unless
exists
$_
[1]->{level};
croak
"Missing required input 'int' value"
unless
defined
$_
[1]->{level};
die
"Out of bounds 'int': $_[1]->{level}"
unless
(-2147483648 <=
$_
[1]->{level} and
$_
[1]->{level} < 2147483648);
die
"Non-integer 'int' value given: $_[1]->{level}"
unless
int
(
$_
[1]->{level}) ==
$_
[1]->{level};
substr
(
$_
[3],
$_
[2] ) =
pack
(
"l>"
,
$_
[1]->{level});
$_
[2] += 4;
croak
"Missing required input value 'dom'"
unless
exists
$_
[1]->{dom};
$_
[0]->serialize_Domain(
$_
[1]->{dom},
$_
[2],
$_
[3] );
croak
"Missing required input value 'str1'"
unless
exists
$_
[1]->{str1};
$_
[0]->serialize_String(
$_
[1]->{str1},
$_
[2],
$_
[3] );
croak
"Missing required input value 'str2'"
unless
exists
$_
[1]->{str2};
$_
[0]->serialize_String(
$_
[1]->{str2},
$_
[2],
$_
[3] );
croak
"Missing required input value 'str3'"
unless
exists
$_
[1]->{str3};
$_
[0]->serialize_String(
$_
[1]->{str3},
$_
[2],
$_
[3] );
croak
"Missing required input value 'int1'"
unless
exists
$_
[1]->{int1};
croak
"Missing required input 'int' value"
unless
defined
$_
[1]->{int1};
die
"Out of bounds 'int': $_[1]->{int1}"
unless
(-2147483648 <=
$_
[1]->{int1} and
$_
[1]->{int1} < 2147483648);
die
"Non-integer 'int' value given: $_[1]->{int1}"
unless
int
(
$_
[1]->{int1}) ==
$_
[1]->{int1};
substr
(
$_
[3],
$_
[2] ) =
pack
(
"l>"
,
$_
[1]->{int1});
$_
[2] += 4;
croak
"Missing required input value 'int2'"
unless
exists
$_
[1]->{int2};
croak
"Missing required input 'int' value"
unless
defined
$_
[1]->{int2};
die
"Out of bounds 'int': $_[1]->{int2}"
unless
(-2147483648 <=
$_
[1]->{int2} and
$_
[1]->{int2} < 2147483648);
die
"Non-integer 'int' value given: $_[1]->{int2}"
unless
int
(
$_
[1]->{int2}) ==
$_
[1]->{int2};
substr
(
$_
[3],
$_
[2] ) =
pack
(
"l>"
,
$_
[1]->{int2});
$_
[2] += 4;
croak
"Missing required input value 'net'"
unless
exists
$_
[1]->{net};
$_
[0]->serialize_Network(
$_
[1]->{net},
$_
[2],
$_
[3] );
}
sub
deserialize_StreamHole {
my
$input_length
=
length
$_
[3];
$_
[1] = {};
die
"Input buffer too short"
if
(
$input_length
-
$_
[2]) < 8;
$_
[1]->{
length
} =
unpack
(
"q>"
,
substr
(
$_
[3],
$_
[2] ));
$_
[2] += 8;
die
"Out of bounds 'hyper': $_[1]->{length}"
unless
(-9223372036854775808 <=
$_
[1]->{
length
}
and
$_
[1]->{
length
} < 9223372036854775808);
die
"Input buffer too short"
if
(
$input_length
-
$_
[2]) < 4;
$_
[1]->{flags} =
unpack
(
"L>"
,
substr
(
$_
[3],
$_
[2] ));
$_
[2] += 4;
die
"Out of bounds 'unsigned int': $_[1]->{flags}"
unless
(0 <=
$_
[1]->{flags} and
$_
[1]->{flags} <= 4294967295);
}
sub
serialize_StreamHole {
croak
"Missing required input 'struct' value"
unless
defined
$_
[1];
croak
"Missing required input value 'length'"
unless
exists
$_
[1]->{
length
};
croak
"Missing required input 'long' value"
unless
defined
$_
[1]->{
length
};
die
"Out of bounds 'hyper': $_[1]->{length}"
unless
(-9223372036854775808 <=
$_
[1]->{
length
}
and
$_
[1]->{
length
} < 9223372036854775808);
die
"Non-integer 'long' value given: $_[1]->{length}"
unless
int
(
$_
[1]->{
length
}) ==
$_
[1]->{
length
};
substr
(
$_
[3],
$_
[2] ) =
pack
(
"q>"
,
$_
[1]->{
length
});
$_
[2] += 8;
croak
"Missing required input value 'flags'"
unless
exists
$_
[1]->{flags};
croak
"Missing required input 'unsigned int' value"
unless
defined
$_
[1]->{flags};
die
"Out of bounds 'unsigned int': $_[1]->{flags}"
unless
(0 <=
$_
[1]->{flags} and
$_
[1]->{flags} <= 4294967295);
die
"Non-integer 'int' value given: $_[1]->{flags}"
unless
int
(
$_
[1]->{flags}) ==
$_
[1]->{flags};
substr
(
$_
[3],
$_
[2] ) =
pack
(
"L>"
,
$_
[1]->{flags});
$_
[2] += 4;
}
1;