3rdparty/licenseReport: Add seperate LGPL checks
[haiku.git] / src / add-ons / kernel / drivers / network / wwan / usb_beceemwmx / util.cpp
blob95f401fdd033001bfc4faf315ab1fb7f56a26695
1 /*
2 * Beceem WiMax USB Driver.
3 * Copyright (c) 2010 Alexander von Gluck <kallisti5@unixzen.com>
4 * Distributed under the terms of the MIT license.
6 */
9 #include <ByteOrder.h>
10 #include "util.h"
13 void
14 convertEndian(bool write, uint32 uiByteCount, uint32* buffer)
16 uint32 uiIndex = 0;
18 if (write == true) {
19 for (uiIndex = 0; uiIndex < (uiByteCount / sizeof(uint32)); uiIndex++) {
20 buffer[uiIndex] = htonl(buffer[uiIndex]);
22 } else {
23 for (uiIndex = 0; uiIndex < (uiByteCount / sizeof(uint32)); uiIndex++) {
24 buffer[uiIndex] = ntohl(buffer[uiIndex]);
30 uint16_t
31 CalculateHWChecksum(uint8_t* pu8Buffer, uint32 u32Size)
33 uint16_t u16CheckSum = 0;
34 while (u32Size--) {
35 u16CheckSum += (uint8_t)~(*pu8Buffer);
36 pu8Buffer++;
38 return u16CheckSum;