Apache log4cxx  Version 0.11.0
datagrampacket.h
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _LOG4CXX_HELPERS_DATAGRAM_PACKET
19 #define _LOG4CXX_HELPERS_DATAGRAM_PACKET
20 
21 #include <log4cxx/helpers/objectimpl.h>
22 #include <log4cxx/helpers/objectptr.h>
23 #include <log4cxx/helpers/inetaddress.h>
24 
25 namespace log4cxx
26 {
27 namespace helpers
28 {
29 
37 class LOG4CXX_EXPORT DatagramPacket : public helpers::ObjectImpl
38 {
39  protected:
41  void* buf;
42 
44  int offset;
45 
47  int length;
48 
50  InetAddressPtr address;
51 
53  int port;
54 
55  public:
56  DECLARE_ABSTRACT_LOG4CXX_OBJECT(DatagramPacket)
57  BEGIN_LOG4CXX_CAST_MAP()
58  LOG4CXX_CAST_ENTRY(DatagramPacket)
59  END_LOG4CXX_CAST_MAP()
60 
63  DatagramPacket(void* buf, int length);
64 
68  DatagramPacket(void* buf, int length, InetAddressPtr address, int port);
69 
72  DatagramPacket(void* buf, int offset, int length);
73 
77  DatagramPacket(void* buf, int offset, int length, InetAddressPtr address,
78  int port);
79 
80  ~DatagramPacket();
81 
84  inline InetAddressPtr getAddress() const
85  {
86  return address;
87  }
88 
90  inline void* getData() const
91  {
92  return buf;
93  }
94 
97  inline int getLength() const
98  {
99  return length;
100  }
101 
104  inline int getOffset() const
105  {
106  return offset;
107  }
108 
111  inline int getPort() const
112  {
113  return port;
114  }
115 
116  inline void setAddress(InetAddressPtr address1)
117  {
118  this->address = address1;
119  }
120 
122  inline void setData(void* buf1)
123  {
124  this->buf = buf1;
125  }
126 
128  inline void setData(void* buf1, int offset1, int length1)
129  {
130  this->buf = buf1;
131  this->offset = offset1;
132  this->length = length1;
133  }
134 
136  inline void setLength(int length1)
137  {
138  this->length = length1;
139  }
140 
141  inline void setPort(int port1)
142  {
143  this->port = port1;
144  }
145 
146  private:
147  //
148  // prevent copy and assignment statements
150  DatagramPacket& operator=(const DatagramPacket&);
151 
152 }; // class DatagramPacket
153 LOG4CXX_PTR_DEF(DatagramPacket);
154 } // namespace helpers
155 } // namespace log4cxx
156 
157 #endif // _LOG4CXX_HELPERS_DATAGRAM_PACKET
void * getData() const
Returns the data received or the data to be sent.
Definition: datagrampacket.h:90
int getOffset() const
Returns the offset of the data to be sent or the offset of the data received.
Definition: datagrampacket.h:104
int getLength() const
Returns the length of the data to be sent or the length of the data received.
Definition: datagrampacket.h:97
int port
The UDP port number of the remote host.
Definition: datagrampacket.h:53
int offset
The offset of the data for this packet.
Definition: datagrampacket.h:44
int length
The length of the data for this packet.
Definition: datagrampacket.h:47
void * buf
the data for this packet.
Definition: datagrampacket.h:41
int getPort() const
Returns the port number on the remote host to which this datagram is being sent or from which the dat...
Definition: datagrampacket.h:111
Implementation class for Object.
Definition: objectimpl.h:28
void setLength(int length1)
Set the length for this packet.
Definition: datagrampacket.h:136
void setData(void *buf1)
Set the data buffer for this packet.
Definition: datagrampacket.h:122
This class represents a datagram packet.
Definition: datagrampacket.h:37
Definition: appender.h:33
void setData(void *buf1, int offset1, int length1)
Set the data buffer for this packet.
Definition: datagrampacket.h:128
InetAddressPtr address
The IP address for this packet.
Definition: datagrampacket.h:50