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