_site/cover/msmp_ssl_request.COVER.html

1 %% Copyright (c) 2023 Peter Morgan <peter.james.morgan@gmail.com>
2 %%
3 %% Licensed under the Apache License, Version 2.0 (the "License");
4 %% you may not use this file except in compliance with the License.
5 %% You may obtain a copy of the License at
6 %%
7 %% http://www.apache.org/licenses/LICENSE-2.0
8 %%
9 %% Unless required by applicable law or agreed to in writing, software
10 %% distributed under the License is distributed on an "AS IS" BASIS,
11 %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 %% See the License for the specific language governing permissions and
13 %% limitations under the License.
14
15
16 -module(msmp_ssl_request).
17
18
19 -export([decode/0]).
20 -export([encode/0]).
21
22
23 decode() ->
24 5 fun
25 (Encoded) ->
26 2 (scran_result:into_map(
27 scran_sequence:sequence(
28 [scran_result:kv(
29 client_flags,
30 msmp_capabilities:decode(combined)),
31
32 scran_result:kv(
33 max_packet_size,
34 msmp_integer_fixed:decode(4)),
35
36 scran_result:kv(
37 character_set,
38 msmp_integer_fixed:decode(1)),
39
40 scran_result:kv(
41 filler,
42 scran_bytes:tag(<<0:23/unit:8>>)),
43
44 scran_result:kv(
45 action,
46 scran_combinator:value(
47 ssl_request,
48 scran_combinator:eof()))])))(Encoded)
49 end.
50
51 encode() ->
52 3 fun
53 (#{action := ssl_request, extended_capabilities := _} = Decoded) ->
54
:-(
(narcs_sequence:sequence(
55 [narcs_combinator:v(client_flags, msmp_capabilities:encode(combined)),
56 narcs_combinator:v(max_packet_size, msmp_integer_fixed:encode(4)),
57 narcs_combinator:v(character_set, msmp_integer_fixed:encode(1)),
58 narcs_bytes:tag(<<0:19/unit:8>>),
59 narcs_combinator:v(
60 extended_capabilities,
61 msmp_integer_fixed:encode(4))]))(Decoded);
62
63 (#{action := ssl_request} = Decoded) ->
64 1 (narcs_sequence:sequence(
65 [narcs_combinator:v(client_flags, msmp_capabilities:encode(combined)),
66 narcs_combinator:v(max_packet_size, msmp_integer_fixed:encode(4)),
67 narcs_combinator:v(character_set, msmp_integer_fixed:encode(1)),
68 narcs_bytes:tag(<<0:23/unit:8>>)]))(Decoded)
69 end.
Line Hits Source