The RecognizeFrame entry point is called to quickly determine if the raw data (starting at lpProtocol passed in) belongs to the protocol the parser understands.
LPBYTE RecognizeFrame(
HFRAME hFrame,
LPBYTE lpFrame,
LPBYTE lpProtocol,
DWORD MacType,
DWORD BytesLeft,
HPROTOCOL hPreviousProtocol,
DWORD nPreviousProtocolOffset,
LPDWORD ProtocolStatusCode,
LPHPROTOCOL hNextProtocol,
LPDWORD lpInstData
);
Note This data is probably somewhere in the middle of the frame, because a previous parser has claimed data before this parser.
MacType | Meaning |
---|---|
MAC_TYPE_ETHERNET | 802.3 |
MAC_TYPE_TOKENRING | 802.5 |
MAC_TYPE_FDDI | ANSI X3T9.5 |
Value | Meaning |
---|---|
PROTOCOL_STATUS_RECOGNIZED | The parser recognized the frame and moved the pointer to the end of its protocol header. Network Monitor uses the protocol's follow set to continue parsing. |
PROTOCOL_STATUS_NOT_RECOGNIZED | The parser did not recognize the frame and did not move the pointer (that is, the start data pointer which was passed in). Network Monitor uses the previous protocol's follow set to continue parsing. |
PROTOCOL_STATUS_CLAIMED | The parser recognized the frame, claimed it all for itself, and parser recognition terminates. |
PROTOCOL_STATUS_NEXT_PROTOCOL | The parser recognized the frame and moved the pointer to the end of its protocol header. The current protocol requests that Network Monitor continue parsing at a known next protocol by returning the next protocol's handle to Network Monitor. In this case, the FollowSet of the current protocol, if any, is not used. |
The return value is a pointer to the next place in the frame. If the parser recognizes the frame, then it should return a pointer to the first byte beyond its recognized data. If the parser does not recognize the frame, then it should return the lpProtocol as passed in. If the parser wishes to claim all of the rest of the data, the parser should return NULL.
The task of RecognizeFrame is to as quickly as possible determine if the raw data (starting at lpProtocol passed in) is pointing to data that the parser recognizes as data belonging to the protocol it understands. It should not attach any properties or do any more processing beyond noting the end point of the data belonging to its protocol, or determining that no such data is present. A parser should not search for data beyond lpProtocol.
Note RecognizeFrame may still be called even if Register has not been called. Thus, RecognizeFrame should not rely on any properties or structures that are created or initialized in the Register entry point.