proxygen
LengthFieldBasedFrameDecoder.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017-present Facebook, Inc.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 
17 #pragma once
18 
19 #include <folly/io/Cursor.h>
21 
22 namespace wangle {
23 
184  public:
185  explicit LengthFieldBasedFrameDecoder(uint32_t lengthFieldLength = 4,
186  uint32_t maxFrameLength = UINT_MAX,
187  uint32_t lengthFieldOffset = 0,
188  int32_t lengthAdjustment = 0,
189  uint32_t initialBytesToStrip = 4,
190  bool networkByteOrder = true);
191 
192  bool decode(Context* ctx,
193  folly::IOBufQueue& buf,
194  std::unique_ptr<folly::IOBuf>& result,
195  size_t&) override;
196 
197  private:
198 
200  folly::IOBufQueue& buf, int offset, int length, bool networkByteOrder);
201 
208 
210 };
211 
212 } // namespace wangle
bool decode(Context *ctx, folly::IOBufQueue &buf, std::unique_ptr< folly::IOBuf > &result, size_t &) override
LengthFieldBasedFrameDecoder(uint32_t lengthFieldLength=4, uint32_t maxFrameLength=UINT_MAX, uint32_t lengthFieldOffset=0, int32_t lengthAdjustment=0, uint32_t initialBytesToStrip=4, bool networkByteOrder=true)
InboundHandler< folly::IOBufQueue &, M >::Context Context
uint64_t getUnadjustedFrameLength(folly::IOBufQueue &buf, int offset, int length, bool networkByteOrder)