1 /* Copyright (c) 2016, 2021, Oracle and/or its affiliates.
2 
3    This program is free software; you can redistribute it and/or modify
4    it under the terms of the GNU General Public License, version 2.0,
5    as published by the Free Software Foundation.
6 
7    This program is also distributed with certain software (including
8    but not limited to OpenSSL) that is licensed under separate terms,
9    as designated in a particular file or component or in included license
10    documentation.  The authors of MySQL hereby grant you an additional
11    permission to link the program and your derivative works with the
12    separately licensed software that they have included with MySQL.
13 
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License, version 2.0, for more details.
18 
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software Foundation,
21    51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
22 
23 #include "single_primary_message.h"
24 
Single_primary_message(Single_primary_message_type type)25 Single_primary_message::Single_primary_message(Single_primary_message_type type)
26     : Plugin_gcs_message(CT_SINGLE_PRIMARY_MESSAGE),
27       single_primary_message_type(type)
28 {
29 }
30 
~Single_primary_message()31 Single_primary_message::~Single_primary_message()
32 {
33 }
34 
Single_primary_message(const uchar * buf,uint64 len)35 Single_primary_message::Single_primary_message(const uchar* buf, uint64 len)
36     : Plugin_gcs_message(CT_SINGLE_PRIMARY_MESSAGE)
37 {
38   decode(buf, len);
39 }
40 
decode_payload(const unsigned char * buffer,const unsigned char * end)41 void Single_primary_message::decode_payload(const unsigned char* buffer,
42                                             const unsigned char* end)
43 {
44   DBUG_ENTER("Single_primary_message::decode_payload");
45   const unsigned char *slider= buffer;
46   uint16 payload_item_type= 0;
47 
48   uint16 single_primary_message_type_aux= 0;
49   decode_payload_item_int2(&slider,
50                            &payload_item_type,
51                            &single_primary_message_type_aux);
52   single_primary_message_type= (Single_primary_message_type)single_primary_message_type_aux;
53 
54   DBUG_VOID_RETURN;
55 }
56 
encode_payload(std::vector<unsigned char> * buffer) const57 void Single_primary_message::encode_payload(std::vector<unsigned char>* buffer) const
58 {
59   DBUG_ENTER("Single_primary_message::encode_payload");
60 
61   uint16 single_primary_message_type_aux= (uint16)single_primary_message_type;
62   encode_payload_item_int2(buffer, PIT_SINGLE_PRIMARY_MESSAGE_TYPE,
63                            single_primary_message_type_aux);
64 
65   DBUG_VOID_RETURN;
66 }
67