Adding a wrapper - mushorg/go-dpi GitHub Wiki
Adding a new wrapper for another library is also very straightforward. All wrapper-related files reside in the wrappers directory. A wrapper must implement the Wrapper interface, which contains the following methods:
InitializeWrapper() error
DestroyWrapper() error
ClassifyFlow(*godpi.Flow) (godpi.Protocol, error)
GetWrapperName() godpi.ClassificationSource
The methods have the following purposes:
InitializeWrapperis called once in the initialization of the application and is responsible for initializing the wrapper and library. If it returns an error, the library won’t be used.DestroyWrapperis called when the application is terminating. It is responsible for freeing any resources taken up by the library and the wrapper.ClassifyFlowtakes a pointer to a flow and returns the protocol detected by the wrapper, as well as any error that occurred. If the library could not detect the protocol, it should return theUnknownprotocolGetWrapperNamereturns aClassificationSource, which is a string. This is the name of the library that the wrapper utilizes, and is returned along with the detected protocol when a flow is classified in order to know which module made the classification.