vfs: check userland buffers before reading them.
[haiku.git] / headers / os / net / NetBuffer.h
blob8a9747e2b79a3d3ba9dbe95a1c24364e7ef1ba16
1 /*
2 * Copyright 2009, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Bruno Albuquerque, bga@bug-br.org.br
7 */
9 #ifndef _NETBUFFER_H
10 #define _NETBUFFER_H
12 #include <Archivable.h>
13 #include <SupportDefs.h>
16 class BMessage;
17 class DynamicBuffer;
20 class BNetBuffer : public BArchivable {
21 public:
22 BNetBuffer(size_t size = 0);
24 virtual ~BNetBuffer();
26 BNetBuffer(const BNetBuffer& buffer);
27 BNetBuffer(BMessage* archive);
29 BNetBuffer& operator=(const BNetBuffer& buffer);
31 virtual status_t Archive(BMessage* into, bool deep = true) const;
32 static BArchivable* Instantiate(BMessage* archive);
34 status_t InitCheck();
36 status_t AppendInt8(int8 data);
37 status_t AppendUint8(uint8 data);
38 status_t AppendInt16(int16 data);
39 status_t AppendUint16(uint16 data);
40 status_t AppendInt32(int32 data);
41 status_t AppendUint32(uint32 data);
42 status_t AppendFloat(float data);
43 status_t AppendDouble(double data);
44 status_t AppendString(const char* data);
45 status_t AppendData(const void* data, size_t size);
46 status_t AppendMessage(const BMessage& data);
47 status_t AppendInt64(int64 data);
48 status_t AppendUint64(uint64 data);
50 status_t RemoveInt8(int8& data);
51 status_t RemoveUint8(uint8& data);
52 status_t RemoveInt16(int16& data);
53 status_t RemoveUint16(uint16& data);
54 status_t RemoveInt32(int32& data);
55 status_t RemoveUint32(uint32& data);
56 status_t RemoveFloat(float& data);
57 status_t RemoveDouble(double& data);
58 status_t RemoveString(char* data, size_t size);
59 status_t RemoveData(void* data, size_t size);
60 status_t RemoveMessage(BMessage& data);
61 status_t RemoveInt64(int64& data);
62 status_t RemoveUint64(uint64& data);
64 unsigned char* Data() const;
65 size_t Size() const;
66 size_t BytesRemaining() const;
68 inline DynamicBuffer* GetImpl() const;
70 protected:
71 status_t fInit;
73 private:
74 virtual void _ReservedBNetBufferFBCCruft1();
75 virtual void _ReservedBNetBufferFBCCruft2();
76 virtual void _ReservedBNetBufferFBCCruft3();
77 virtual void _ReservedBNetBufferFBCCruft4();
78 virtual void _ReservedBNetBufferFBCCruft5();
79 virtual void _ReservedBNetBufferFBCCruft6();
81 DynamicBuffer* fImpl;
82 int32 __ReservedBNetBufferFBCCruftData[8];
87 inline DynamicBuffer*
88 BNetBuffer::GetImpl() const
90 return fImpl;
93 #endif // _NET_BUFFER_H