• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
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 #include "softbus_datahead_transform.h"
16 #include <sys/types.h>
17 #include "softbus_log.h"
18 #include "softbus_adapter_socket.h"
19 
PackConnPktHead(ConnPktHead * data)20 void PackConnPktHead(ConnPktHead *data)
21 {
22     if (data == NULL) {
23         return;
24     }
25     data->magic = (int32_t)SoftBusHtoLl((uint32_t)data->magic);
26     data->flag = (int32_t)SoftBusHtoLl((uint32_t)data->flag);
27     data->module = (int32_t)SoftBusHtoLl((uint32_t)data->module);
28     data->len = SoftBusHtoLl(data->len);
29     data->seq = (int64_t)SoftBusHtoLll((uint64_t)data->seq);
30 }
31 
UnpackConnPktHead(ConnPktHead * data)32 void UnpackConnPktHead(ConnPktHead *data)
33 {
34     if (data == NULL) {
35         return;
36     }
37     data->magic = (int32_t)SoftBusLtoHl((uint32_t)data->magic);
38     data->flag = (int32_t)SoftBusLtoHl((uint32_t)data->flag);
39     data->module = (int32_t)SoftBusLtoHl((uint32_t)data->module);
40     data->len = SoftBusLtoHl(data->len);
41     data->seq = (int64_t)SoftBusLtoHll((uint64_t)data->seq);
42 }
43 
PackProxyMessageHead(ProxyMessageHead * msg)44 void PackProxyMessageHead(ProxyMessageHead *msg)
45 {
46     if (msg == NULL) {
47         return;
48     }
49     msg->myId = (int16_t)SoftBusLEtoBEs((uint16_t)msg->myId);
50     msg->peerId = (int16_t)SoftBusLEtoBEs((uint16_t)msg->peerId);
51     msg->reserved = (int16_t)SoftBusLEtoBEs((uint16_t)msg->reserved);
52 }
53 
UnpackProxyMessageHead(ProxyMessageHead * msg)54 void UnpackProxyMessageHead(ProxyMessageHead *msg)
55 {
56     if (msg == NULL) {
57         return;
58     }
59     msg->peerId = (int16_t)SoftBusLtoHs((uint16_t)msg->peerId);
60     msg->myId = (int16_t)SoftBusLtoHs((uint16_t)msg->myId);
61     msg->reserved = (int16_t)SoftBusLtoHs((uint16_t)msg->reserved);
62 }