|
suricata
|

Go to the source code of this file.
Functions | |
| Flow * | TestHelperBuildFlow (int family, const char *src, const char *dst, Port sp, Port dp) |
| int | TestHelperBufferToFile (const char *name, const uint8_t *data, size_t size) |
| writes the contents of a buffer into a file More... | |
| void | UTHSetIPV4Hdr (Packet *p, IPV4Hdr *ip4h) |
| void | UTHSetIPV6Hdr (Packet *p, IPV6Hdr *ip6h) |
| void | UTHSetTCPHdr (Packet *p, TCPHdr *tcph) |
| uint32_t | UTHSetIPv4Address (const char *) |
| return the uint32_t for a ipv4 address string More... | |
| Packet * | UTHBuildPacketReal (uint8_t *, uint16_t, uint8_t ipproto, const char *, const char *, uint16_t, uint16_t) |
| UTHBuildPacketReal is a function that create tcp/udp packets for unittests specifying ip and port sources and destinations. More... | |
| Packet * | UTHBuildPacket (uint8_t *, uint16_t, uint8_t ipproto) |
| UTHBuildPacket is a wrapper that build packets with default ip and port fields. More... | |
| Packet * | UTHBuildPacketSrcDst (uint8_t *, uint16_t, uint8_t ipproto, const char *, const char *) |
| UTHBuildPacketSrcDst is a wrapper that build packets specifying IPs and defaulting ports. More... | |
| Packet * | UTHBuildPacketSrcDstPorts (uint8_t *, uint16_t, uint8_t ipproto, uint16_t, uint16_t) |
| UTHBuildPacketSrcDstPorts is a wrapper that build packets specifying src and dst ports and defaulting IPs. More... | |
| Packet * | UTHBuildPacketIPV6SrcDst (uint8_t *, uint16_t, uint8_t ipproto, const char *, const char *) |
| UTHBuildPacketSrcDst is a wrapper that build packets specifying IPs and defaulting ports (IPV6) More... | |
| int | UTHPacketMatchSigMpm (Packet *, char *, uint16_t) |
| Packet * | UTHBuildPacketFromEth (uint8_t *, uint16_t) |
| UTHBuildPacketFromEth is a wrapper that build a packet for the rawbytes. More... | |
| void | UTHFreePacket (Packet *) |
| UTHFreePacket: function to release the allocated data from UTHBuildPacket and the packet itself. More... | |
| void | UTHFreePackets (Packet **, int) |
| UTHFreePackets: function to release the allocated data from UTHBuildPacket and the packet itself. More... | |
| void | UTHAssignFlow (Packet *p, Flow *f) |
| Flow * | UTHBuildFlow (int family, const char *src, const char *dst, Port sp, Port dp) |
| void | UTHFreeFlow (Flow *flow) |
| int | UTHAddStreamToFlow (Flow *f, int direction, uint8_t *data, uint32_t data_len) |
| int | UTHAddSessionToFlow (Flow *f, uint32_t ts_isn, uint32_t tc_isn) |
| int | UTHRemoveSessionFromFlow (Flow *f) |
| int | UTHAppendSigs (DetectEngineCtx *, const char **, int) |
| int | UTHMatchPackets (DetectEngineCtx *, Packet **, int) |
| int | UTHPacketMatchSig (Packet *p, const char *) |
| int | UTHCheckPacketMatch (Packet *, uint32_t *, uint32_t *, int) |
| int | UTHCheckPacketMatchResults (Packet *, uint32_t *, uint32_t *, int) |
| int | UTHMatchPacketsWithResults (DetectEngineCtx *, Packet **, int, uint32_t *, uint32_t *, int) |
| int | UTHGenericTest (Packet **, int, const char **, uint32_t *, uint32_t *, int) |
| uint32_t | UTHBuildPacketOfFlows (uint32_t, uint32_t, uint8_t) |
| Packet * | UTHBuildPacketIPV6Real (uint8_t *, uint16_t, uint8_t ipproto, const char *, const char *, uint16_t, uint16_t) |
| UTHBuildPacketReal is a function that create tcp/udp packets for unittests specifying ip and port sources and destinations (IPV6) More... | |
| void * | UTHmemsearch (const void *big, size_t big_len, const void *little, size_t little_len) |
| int | UTHParseSignature (const char *str, bool expect) |
| parser a sig and see if the expected result is correct More... | |
| void | UTHRegisterTests (void) |
Definition in file util-unittest-helper.h.
| int TestHelperBufferToFile | ( | const char * | name, |
| const uint8_t * | data, | ||
| size_t | size | ||
| ) |
writes the contents of a buffer into a file
Definition at line 103 of file util-unittest-helper.c.
References name.
Definition at line 52 of file util-unittest-helper.c.
References BUG_ON, dst, FLOW_INITIALIZE, FLOW_IPV4, FLOW_IPV6, SCFree, SCMalloc, src, and unlikely.
Referenced by LLVMFuzzerTestOneInput(), and UTHBuildFlow().

| int UTHAddSessionToFlow | ( | Flow * | f, |
| uint32_t | ts_isn, | ||
| uint32_t | tc_isn | ||
| ) |
Definition at line 526 of file util-unittest-helper.c.
References TcpSession_::client, FAIL_IF_NULL, TcpStream_::isn, Flow_::protoctx, TcpStream_::sb, SCCalloc, TcpSession_::server, and STREAMING_BUFFER_INITIALIZER.
| int UTHAddStreamToFlow | ( | Flow * | f, |
| int | direction, | ||
| uint8_t * | data, | ||
| uint32_t | data_len | ||
| ) |
Definition at line 510 of file util-unittest-helper.c.
References TcpSession_::client, FAIL_IF_NOT, FAIL_IF_NULL, TcpStream_::last_ack, Flow_::proto, Flow_::protoctx, TcpStream_::sb, TcpStreamCnf_::sbcnf, TcpSession_::server, stream_config, and StreamingBufferAppend().

| int UTHAppendSigs | ( | DetectEngineCtx * | , |
| const char ** | , | ||
| int | |||
| ) |
Definition at line 489 of file util-unittest-helper.c.
References Packet_::flags, Packet_::flow, and PKT_HAS_FLOW.
Definition at line 497 of file util-unittest-helper.c.
References dst, src, and TestHelperBuildFlow().

| Packet* UTHBuildPacket | ( | uint8_t * | payload, |
| uint16_t | payload_len, | ||
| uint8_t | ipproto | ||
| ) |
UTHBuildPacket is a wrapper that build packets with default ip and port fields.
| payload | pointer to the payload buffer |
| payload_len | pointer to the length of the payload |
| ipproto | Protocols allowed atm are IPPROTO_TCP and IPPROTO_UDP |
| Packet | pointer to the built in packet |
Definition at line 365 of file util-unittest-helper.c.
References payload_len, and UTHBuildPacketReal().
Referenced by UTHBuildPacketOfFlows().


| Packet* UTHBuildPacketFromEth | ( | uint8_t * | raw_eth, |
| uint16_t | pktsize | ||
| ) |
UTHBuildPacketFromEth is a wrapper that build a packet for the rawbytes.
| raw_eth | pointer to the rawbytes containing an ethernet packet (and any other headers inside) |
| pktsize | pointer to the length of the payload |
| Packet | pointer to the built in packet; NULL if something fail |
Definition at line 382 of file util-unittest-helper.c.
References DecodeEthernet(), dtv, PacketGetFromAlloc(), and unlikely.

| Packet* UTHBuildPacketIPV6Real | ( | uint8_t * | payload, |
| uint16_t | payload_len, | ||
| uint8_t | ipproto, | ||
| const char * | src, | ||
| const char * | dst, | ||
| uint16_t | sport, | ||
| uint16_t | dport | ||
| ) |
UTHBuildPacketReal is a function that create tcp/udp packets for unittests specifying ip and port sources and destinations (IPV6)
| payload | pointer to the payload buffer |
| payload_len | pointer to the length of the payload |
| ipproto | Protocols allowed atm are IPPROTO_TCP and IPPROTO_UDP |
| src | pointer to a string containing the ip source |
| dst | pointer to a string containing the ip destination |
| sport | pointer to a string containing the port source |
| dport | pointer to a string containing the port destination |
| Packet | pointer to the built in packet |
Definition at line 172 of file util-unittest-helper.c.
References Packet_::dp, dst, Packet_::dst, Address_::family, PacketGetFromAlloc(), Packet_::payload, payload_len, Packet_::payload_len, Packet_::proto, SCCalloc, SCFree, SCMalloc, SET_PKT_LEN, Packet_::sp, src, Packet_::src, TCPHdr_::th_dport, TCPHdr_::th_sport, TimeGet(), Packet_::ts, unlikely, UTHSetIPV6Hdr(), and UTHSetTCPHdr().
Referenced by UTHBuildPacketIPV6SrcDst().


| Packet* UTHBuildPacketIPV6SrcDst | ( | uint8_t * | payload, |
| uint16_t | payload_len, | ||
| uint8_t | ipproto, | ||
| const char * | src, | ||
| const char * | dst | ||
| ) |
UTHBuildPacketSrcDst is a wrapper that build packets specifying IPs and defaulting ports (IPV6)
| payload | pointer to the payload buffer |
| payload_len | pointer to the length of the payload |
| ipproto | Protocols allowed atm are IPPROTO_TCP and IPPROTO_UDP |
| Packet | pointer to the built in packet |
Definition at line 424 of file util-unittest-helper.c.
References dst, payload_len, src, and UTHBuildPacketIPV6Real().

| uint32_t UTHBuildPacketOfFlows | ( | uint32_t | , |
| uint32_t | , | ||
| uint8_t | |||
| ) |
Definition at line 874 of file util-unittest-helper.c.
References Packet_::dst, Packet_::flow, FlowFree(), FlowHandlePacket(), FLOWLOCK_UNLOCK, FlowQueuePrivateGetFromTop(), FlowLookupStruct_::spare_queue, Packet_::src, tv, UTHBuildPacket(), UTHFreePacket(), and FlowLookupStruct_::work_queue.

| Packet* UTHBuildPacketReal | ( | uint8_t * | payload, |
| uint16_t | payload_len, | ||
| uint8_t | ipproto, | ||
| const char * | src, | ||
| const char * | dst, | ||
| uint16_t | sport, | ||
| uint16_t | dport | ||
| ) |
UTHBuildPacketReal is a function that create tcp/udp packets for unittests specifying ip and port sources and destinations.
| payload | pointer to the payload buffer |
| payload_len | pointer to the length of the payload |
| ipproto | Protocols allowed atm are IPPROTO_TCP and IPPROTO_UDP |
| src | pointer to a string containing the ip source |
| dst | pointer to a string containing the ip destination |
| sport | pointer to a string containing the port source |
| dport | pointer to a string containing the port destination |
| Packet | pointer to the built in packet |
Definition at line 260 of file util-unittest-helper.c.
References dst, IPPROTO_SCTP, PacketGetFromAlloc(), payload_len, src, TimeGet(), and unlikely.
Referenced by StreamTcpUTAddPayload(), StreamTcpUTAddSegmentWithByte(), StreamTcpUTAddSegmentWithPayload(), UTHBuildPacket(), UTHBuildPacketSrcDst(), and UTHBuildPacketSrcDstPorts().


| Packet* UTHBuildPacketSrcDst | ( | uint8_t * | payload, |
| uint16_t | payload_len, | ||
| uint8_t | ipproto, | ||
| const char * | src, | ||
| const char * | dst | ||
| ) |
UTHBuildPacketSrcDst is a wrapper that build packets specifying IPs and defaulting ports.
| payload | pointer to the payload buffer |
| payload_len | pointer to the length of the payload |
| ipproto | Protocols allowed atm are IPPROTO_TCP and IPPROTO_UDP |
| Packet | pointer to the built in packet |
Definition at line 406 of file util-unittest-helper.c.
References dst, payload_len, src, and UTHBuildPacketReal().

| Packet* UTHBuildPacketSrcDstPorts | ( | uint8_t * | payload, |
| uint16_t | payload_len, | ||
| uint8_t | ipproto, | ||
| uint16_t | sport, | ||
| uint16_t | dport | ||
| ) |
UTHBuildPacketSrcDstPorts is a wrapper that build packets specifying src and dst ports and defaulting IPs.
| payload | pointer to the payload buffer |
| payload_len | pointer to the length of the payload |
| ipproto | Protocols allowed atm are IPPROTO_TCP and IPPROTO_UDP |
| Packet | pointer to the built in packet |
Definition at line 442 of file util-unittest-helper.c.
References payload_len, and UTHBuildPacketReal().

| int UTHCheckPacketMatch | ( | Packet * | , |
| uint32_t * | , | ||
| uint32_t * | , | ||
| int | |||
| ) |
| int UTHCheckPacketMatchResults | ( | Packet * | , |
| uint32_t * | , | ||
| uint32_t * | , | ||
| int | |||
| ) |
| void UTHFreeFlow | ( | Flow * | flow | ) |
Definition at line 502 of file util-unittest-helper.c.
References FLOW_DESTROY, and SCFree.
| void UTHFreePacket | ( | Packet * | p | ) |
UTHFreePacket: function to release the allocated data from UTHBuildPacket and the packet itself.
| p | pointer to the Packet |
Definition at line 473 of file util-unittest-helper.c.
References PacketL3::hdrs, PacketL4::hdrs, PacketL3::Hdrs::ip6h, Packet_::l3, Packet_::l4, PACKET_L3_IPV6, PACKET_L4_TCP, PacketFree(), SCFree, PacketL4::L4Hdrs::tcph, PacketL3::type, and PacketL4::type.
Referenced by StreamTcpUTAddPayload(), StreamTcpUTAddSegmentWithByte(), StreamTcpUTAddSegmentWithPayload(), UTHBuildPacketOfFlows(), and UTHFreePackets().


| void UTHFreePackets | ( | Packet ** | p, |
| int | numpkts | ||
| ) |
UTHFreePackets: function to release the allocated data from UTHBuildPacket and the packet itself.
| p | pointer to the Packet |
Definition at line 456 of file util-unittest-helper.c.
References UTHFreePacket().

| int UTHGenericTest | ( | Packet ** | , |
| int | , | ||
| const char ** | , | ||
| uint32_t * | , | ||
| uint32_t * | , | ||
| int | |||
| ) |
| int UTHMatchPackets | ( | DetectEngineCtx * | de_ctx, |
| Packet ** | p, | ||
| int | num_packets | ||
| ) |
| de_ctx | pointer with the signatures loaded |
| p | pointer to the array of packets |
| num_packets | number of packets in the array |
| return | 1 if all goes well |
| return | 0 if something fail |
Definition at line 729 of file util-unittest-helper.c.
References BUG_ON, de_ctx, DetectEngineThreadCtxDeinit(), DetectEngineThreadCtxInit(), dtv, SCSigOrderSignatures(), SCSigRegisterSignatureOrderingFuncs(), SCSigSignatureOrderingModuleCleanup(), SigGroupBuild(), SigMatchSignatures(), and StatsThreadCleanup().

| int UTHMatchPacketsWithResults | ( | DetectEngineCtx * | , |
| Packet ** | , | ||
| int | , | ||
| uint32_t * | , | ||
| uint32_t * | , | ||
| int | |||
| ) |
| void* UTHmemsearch | ( | const void * | big, |
| size_t | big_len, | ||
| const void * | little, | ||
| size_t | little_len | ||
| ) |
Definition at line 992 of file util-unittest-helper.c.
References BasicSearch().

| int UTHPacketMatchSig | ( | Packet * | p, |
| const char * | sig | ||
| ) |
| sig | pointer to the string signature to test |
| sid | sid number of the signature |
| return | 1 if match |
| return | 0 if not |
Definition at line 831 of file util-unittest-helper.c.
References de_ctx, DE_QUIET, DetectEngineAppendSig(), DetectEngineCtxFree(), DetectEngineCtxInit(), DetectEngineThreadCtxDeinit(), DetectEngineThreadCtxInit(), dtv, DetectEngineCtx_::flags, Signature_::id, PacketAlertCheck(), SigGroupBuild(), SigMatchSignatures(), and StatsThreadCleanup().

| int UTHPacketMatchSigMpm | ( | Packet * | p, |
| char * | sig, | ||
| uint16_t | mpm_type | ||
| ) |
| sig | pointer to the string signature to test |
| sid | sid number of the signature |
| return | 1 if match |
| return | 0 if not |
Definition at line 767 of file util-unittest-helper.c.
References BUG_ON, de_ctx, DE_QUIET, DetectEngineAppendSig(), DetectEngineCtxFree(), DetectEngineCtxInit(), DetectEngineThreadCtxDeinit(), DetectEngineThreadCtxInit(), dtv, DetectEngineCtx_::flags, Signature_::id, MPM_AC, MPM_HS, PacketAlertCheck(), SCConfSet(), SCEnter, SCReturnInt, SigGroupBuild(), SigMatchSignatures(), and StatsThreadCleanup().

| int UTHParseSignature | ( | const char * | str, |
| bool | expect | ||
| ) |
parser a sig and see if the expected result is correct
Definition at line 913 of file util-unittest-helper.c.
References de_ctx, DE_QUIET, DetectEngineAppendSig(), DetectEngineCtxFree(), DetectEngineCtxInit(), FAIL_IF_NOT_NULL, FAIL_IF_NULL, DetectEngineCtx_::flags, PASS, and str.

| void UTHRegisterTests | ( | void | ) |
Definition at line 1146 of file util-unittest-helper.c.
References UtRegisterTest().

| int UTHRemoveSessionFromFlow | ( | Flow * | f | ) |
Definition at line 546 of file util-unittest-helper.c.
References FAIL_IF_NOT, FAIL_IF_NULL, Flow_::proto, Flow_::protoctx, SCFree, and StreamTcpSessionCleanup().

| uint32_t UTHSetIPv4Address | ( | const char * | str | ) |
return the uint32_t for a ipv4 address string
| str | Valid ipaddress in string form (e.g. 1.2.3.4) |
| uint | the uin32_t representation |
Definition at line 148 of file util-unittest-helper.c.
References str.
Definition at line 126 of file util-unittest-helper.c.
Definition at line 131 of file util-unittest-helper.c.
Referenced by UTHBuildPacketIPV6Real().

Definition at line 136 of file util-unittest-helper.c.
Referenced by UTHBuildPacketIPV6Real().
