Protocol++® (Protocolpp®)
v5.6.2
|
#include "include/jprotocol.h"
This class is the base class for all other protocols. Many of the methods are pure virtual and must be implemented in the inherited class. In addition, the class comtains helper functions for use in the various protocols
Constructors are provided for differnt kinds of protocols. Some protocols may be opening a file, some may need a random data generator, some protocols may require a file input and a random number generator
Two different types of encap and decap virtual functions are provided. For protocols that have a file input, encapsulation only requires a pointer to the output data. Input data will be retrieved from the input file, in chunks the size of the current MTU untill the EOF is reached. For decapsulation with a file output will write the data into the file in append mode until the last packet is processed
For the typical type, and input pointer and output pointer must be provided to process the plaintext and ciphertext
Set and get functions must be implemented in the protocols. Various fields can be retrieved as well as the whole header for the protocol
Following the virtual functions, there are several helper functions for use by the protocols. The function currentDateTime() returns a string representation of the date and time useful for the AUDIT fuction in IPsec. It can be used any time the date or time is needed
The functions has_file() provides a convenient method to check if the file is present and it's open for reading or writing
The next two functions provide methods to retrieve the status get_status() which returns an encoded status that contains the protocols generating the status, the error type, and the line number in the code where the error occurred. For printing purposes, the function str_status(status) returns a printable string describing the protocol
to_xml() prints the security association as XML output to the XMLPrint object
To help in converting data from unsigned types to arrays and back with the correct endianess, the following helper functions are provided:
The final two functions provide common functionality that is used across multiple protocols so are provided in the base class. The checksum() function calculates the IPsec checksum calculation also used in TCP and UDP. Input data is padded to two byte length. The checksum field for the protocol is set to zero, and the checksum is calculated across the data two bytes at a time. The calculated checksum is returned as a two-byte array ready for insertion into the packet. If the checksum is being validated (DECAP direction), the checksum is calculated without setting the checksum field to zero. If the calculated checksum results in a value of zero, the checksum is correct
pad(pad_t padtype, uint32_t len) generates padding material to be appended to the packet if needed. Supports either ZERO, INCREMENTING, SIZE, or RANDOM padding to support the different protocol formats
There are several protected helper functions for use by the protocols during or after construction of the protocol object. This includes functions to setup the anti-replay window from the security association, the ability to update the status, functions to read and write the input and output files, and function to roundup() values
For API Documentation:
For Additional Documentation:
The source code contained or described herein and all documents related to the source code (herein called "Material") are owned by John Peter Greninger and Sheila Rocha Greninger. Title to the Material remains with John Peter Greninger and Sheila Rocha Greninger. The Material contains trade secrets and proprietary and confidential information of John Peter Greninger and Sheila Rocha Greninger. The Material is protected by worldwide copyright and trade secret laws and treaty provisions. No part of the Material may be used, copied, reproduced, modified, published, uploaded, posted, transmitted, distributed, or disclosed in any way without prior express written consent of John Peter Greninger and Sheila Rocha Greninger (both are required)
No license under any patent, copyright, trade secret, or other intellectual property right is granted to or conferred upon you by disclosure or delivery of the Materials, either expressly, by implication, inducement, estoppel, or otherwise. Any license under such intellectual property rights must be express and approved by John Peter Greninger and Sheila Rocha Greninger in writing
Licensing information can be found at www.protocolpp.com/license with use of the binary forms permitted provided that the following conditions are met:
Use of the source code requires purchase of the source code. Source code can be purchased at www.protocolpp.com/shop
The name of its contributor may not be used to endorse or promote products derived from this software without specific prior written permission and licensing
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTOR "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE