2
* Copyright (c) 2014 VMware, Inc.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at:
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
#ifndef __NETLINK_BUF_H_
18
#define __NETLINK_BUF_H_ 1
20
typedef struct _NL_BUF {
21
PCHAR head; /* start address of the buffer */
22
PCHAR tail; /* first empty byte of the buffer */
23
UINT32 bufLen; /* original length of buffer */
24
UINT32 bufRemLen; /* remaining length of buffer */
25
} NL_BUFFER, *PNL_BUFFER;
27
VOID NlBufInit(PNL_BUFFER nlBuf, PCHAR base, UINT32 size);
28
VOID NlBufDeInit(PNL_BUFFER nlBuf);
30
BOOLEAN NlBufCopyAtTail(PNL_BUFFER nlBuf, PCHAR data, UINT32 len);
31
BOOLEAN NlBufCopyAtHead(PNL_BUFFER nlBuf, PCHAR data, UINT32 len);
32
BOOLEAN NlBufCopyAtOffset(PNL_BUFFER nlBuf, PCHAR data,
33
UINT32 len, UINT32 offset);
35
PCHAR NlBufCopyAtTailUninit(PNL_BUFFER nlBuf, UINT32 len);
36
PCHAR NlBufCopyAtHeadUninit(PNL_BUFFER nlBuf, UINT32 len);
37
PCHAR NlBufCopyAtOffsetUninit(PNL_BUFFER nlBuf, UINT32 len, UINT32 offset);
39
PCHAR NlBufAt(PNL_BUFFER nlBuf, UINT32 offset, UINT32 len);
42
* --------------------------------------------------------------------------
45
* Returns the used size of buffer.
46
* --------------------------------------------------------------------------
48
static __inline UINT32
49
NlBufSize(PNL_BUFFER nlBuf)
52
return (nlBuf->bufLen - nlBuf->bufRemLen);
56
* --------------------------------------------------------------------------
59
* Returns the unused size of buffer.
60
* --------------------------------------------------------------------------
62
static __inline UINT32
63
NlBufRemLen(PNL_BUFFER nlBuf)
66
return (nlBuf->bufRemLen);
69
#endif /* __NETLINK_BUF_H_ */