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.
5 *
6 */
7
8
9#include <ByteOrder.h>
10#include "util.h"
11
12
13void
14convertEndian(bool write, uint32 uiByteCount, uint32* buffer)
15{
16	uint32 uiIndex = 0;
17
18	if (write == true) {
19		for (uiIndex = 0; uiIndex < (uiByteCount / sizeof(uint32)); uiIndex++) {
20			buffer[uiIndex] = htonl(buffer[uiIndex]);
21		}
22	} else {
23		for (uiIndex = 0; uiIndex < (uiByteCount / sizeof(uint32)); uiIndex++) {
24			buffer[uiIndex] = ntohl(buffer[uiIndex]);
25		}
26	}
27}
28
29
30uint16_t
31CalculateHWChecksum(uint8_t* pu8Buffer, uint32 u32Size)
32{
33	uint16_t u16CheckSum = 0;
34	while (u32Size--) {
35		u16CheckSum += (uint8_t)~(*pu8Buffer);
36		pu8Buffer++;
37	}
38	return u16CheckSum;
39}
40