Skip to content

Commit

Permalink
src: make include guards more library friendly
Browse files Browse the repository at this point in the history
Include guards for libraries should use a prefix that is meaningful for
the library to avoid conflicts with other user code. For Suricata, use
SURICATA.

Additionally, remove the pattern of leading and trailing underscores as
these are reserved for the language implementation per the C and C++
standards.
  • Loading branch information
jasonish authored and victorjulien committed Mar 10, 2024
1 parent 632ca75 commit 44388f1
Show file tree
Hide file tree
Showing 579 changed files with 1,705 additions and 1,856 deletions.
6 changes: 3 additions & 3 deletions src/action-globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
* \author Victor Julien <[email protected]>
*/

#ifndef __ACTION_GLOBALS_H__
#define __ACTION_GLOBALS_H__
#ifndef SURICATA_ACTION_GLOBALS_H
#define SURICATA_ACTION_GLOBALS_H

/* Changing them as flags, so later we can have alerts
* and drop simultaneously */
Expand All @@ -38,4 +38,4 @@

#define ACTION_DROP_REJECT (ACTION_REJECT_ANY | ACTION_DROP)

#endif /* __ACTION_GLOBALS_H__ */
#endif /* SURICATA_ACTION_GLOBALS_H */
7 changes: 3 additions & 4 deletions src/alert-debuglog.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
* \author Victor Julien <[email protected]>
*/

#ifndef __ALERT_DEBUGLOG_H__
#define __ALERT_DEBUGLOG_H__
#ifndef SURICATA_ALERT_DEBUGLOG_H
#define SURICATA_ALERT_DEBUGLOG_H

void AlertDebugLogRegister(void);

#endif /* __ALERT_DEBUGLOG_H__ */

#endif /* SURICATA_ALERT_DEBUGLOG_H */
7 changes: 3 additions & 4 deletions src/alert-fastlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
* \author Victor Julien <[email protected]>
*/

#ifndef __ALERT_FASTLOG_H__
#define __ALERT_FASTLOG_H__
#ifndef SURICATA_ALERT_FASTLOG_H
#define SURICATA_ALERT_FASTLOG_H

void AlertFastLogRegister(void);
OutputInitResult AlertFastLogInitCtx(ConfNode *);

#endif /* __ALERT_FASTLOG_H__ */

#endif /* SURICATA_ALERT_FASTLOG_H */
7 changes: 3 additions & 4 deletions src/alert-syslog.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
*
*/

#ifndef __ALERT_SYSLOG_H__
#define __ALERT_SYSLOG_H__
#ifndef SURICATA_ALERT_SYSLOG_H
#define SURICATA_ALERT_SYSLOG_H

void AlertSyslogRegister(void);

#endif /* __ALERT_SYSLOG_H__ */

#endif /* SURICATA_ALERT_SYSLOG_H */
6 changes: 3 additions & 3 deletions src/app-layer-detect-proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* \author Anoop Saldanha <[email protected]>
*/

#ifndef __APP_LAYER_DETECT_PROTO__H__
#define __APP_LAYER_DETECT_PROTO__H__
#ifndef SURICATA_APP_LAYER_DETECT_PROTO__H
#define SURICATA_APP_LAYER_DETECT_PROTO__H

#include "flow.h"
#include "app-layer-protos.h"
Expand Down Expand Up @@ -228,4 +228,4 @@ void AppLayerProtoDetectUnittestsRegister(void);

#endif /* UNITTESTS */

#endif /* __APP_LAYER_DETECT_PROTO__H__ */
#endif /* SURICATA_APP_LAYER_DETECT_PROTO__H */
6 changes: 3 additions & 3 deletions src/app-layer-dnp3-objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
* This file contains the types (definitions) of the DNP3 objects.
*/

#ifndef __APP_LAYER_DNP3_OBJECTS_H__
#define __APP_LAYER_DNP3_OBJECTS_H__
#ifndef SURICATA_APP_LAYER_DNP3_OBJECTS_H
#define SURICATA_APP_LAYER_DNP3_OBJECTS_H

#define DNP3_OBJECT_CODE(group, variation) (group << 8 | variation)

Expand Down Expand Up @@ -1461,4 +1461,4 @@ int DNP3DecodeObject(int group, int variation, const uint8_t **buf,
DNP3PointList *DNP3PointListAlloc(void);
void DNP3FreeObjectPointList(int group, int variation, DNP3PointList *);

#endif /* __APP_LAYER_DNP3_OBJECTS_H__ */
#endif /* SURICATA_APP_LAYER_DNP3_OBJECTS_H */
6 changes: 3 additions & 3 deletions src/app-layer-dnp3.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
* DNP3 application layer protocol header file
*/

#ifndef __APP_LAYER_DNP3_H__
#define __APP_LAYER_DNP3_H__
#ifndef SURICATA_APP_LAYER_DNP3_H
#define SURICATA_APP_LAYER_DNP3_H

#include "rust.h"
#if __BYTE_ORDER == __BIG_ENDIAN
Expand Down Expand Up @@ -257,4 +257,4 @@ void RegisterDNP3Parsers(void);
void DNP3ParserRegisterTests(void);
int DNP3PrefixIsSize(uint8_t);

#endif /* __APP_LAYER_DNP3_H__ */
#endif /* SURICATA_APP_LAYER_DNP3_H */
6 changes: 3 additions & 3 deletions src/app-layer-enip-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
* \author Kevin Wong <[email protected]>
*/

#ifndef __APP_LAYER_ENIP_COMMON_H__
#define __APP_LAYER_ENIP_COMMON_H__
#ifndef SURICATA_APP_LAYER_ENIP_COMMON_H
#define SURICATA_APP_LAYER_ENIP_COMMON_H

#include "rust.h"

Expand Down Expand Up @@ -242,4 +242,4 @@ int DecodeCIPRequestMSPPDU(const uint8_t *input, uint32_t input_len,
int DecodeCIPResponseMSPPDU(const uint8_t *input, uint32_t input_len,
ENIPTransaction *enip_data, uint16_t offset);

#endif /* __APP_LAYER_ENIP_COMMON_H__ */
#endif /* SURICATA_APP_LAYER_ENIP_COMMON_H */
7 changes: 3 additions & 4 deletions src/app-layer-enip.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
* \author Kevin Wong <[email protected]>
*/

#ifndef __APP_LAYER_ENIP_H__
#define __APP_LAYER_ENIP_H__

#ifndef SURICATA_APP_LAYER_ENIP_H
#define SURICATA_APP_LAYER_ENIP_H

void RegisterENIPUDPParsers(void);
void RegisterENIPTCPParsers(void);
void ENIPParserRegisterTests(void);

#endif /* __APP_LAYER_ENIP_H__ */
#endif /* SURICATA_APP_LAYER_ENIP_H */
7 changes: 3 additions & 4 deletions src/app-layer-events.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* \author Anoop Saldanha <[email protected]>
*/

#ifndef __APP_LAYER_EVENTS_H__
#define __APP_LAYER_EVENTS_H__
#ifndef SURICATA_APP_LAYER_EVENTS_H
#define SURICATA_APP_LAYER_EVENTS_H

/* contains fwd declaration of AppLayerDecoderEvents_ */
#include "decode.h"
Expand Down Expand Up @@ -78,5 +78,4 @@ void AppLayerDecoderEventsResetEvents(AppLayerDecoderEvents *events);
void AppLayerDecoderEventsFreeEvents(AppLayerDecoderEvents **events);
int DetectEngineGetEventInfo(const char *event_name, int *event_id, AppLayerEventType *event_type);

#endif /* __APP_LAYER_EVENTS_H__ */

#endif /* SURICATA_APP_LAYER_EVENTS_H */
6 changes: 3 additions & 3 deletions src/app-layer-expectation.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
* \author Eric Leblond <[email protected]>
*/

#ifndef __APP_LAYER_EXPECTATION__H__
#define __APP_LAYER_EXPECTATION__H__
#ifndef SURICATA_APP_LAYER_EXPECTATION__H
#define SURICATA_APP_LAYER_EXPECTATION__H

#include "flow-storage.h"

Expand All @@ -36,4 +36,4 @@ void AppLayerExpectationClean(Flow *f);

uint64_t ExpectationGetCounter(void);

#endif /* __APP_LAYER_EXPECTATION__H__ */
#endif /* SURICATA_APP_LAYER_EXPECTATION__H */
4 changes: 2 additions & 2 deletions src/app-layer-frames.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
* \author Victor Julien <[email protected]>
*/

#ifndef __APP_LAYER_FRAMES_H__
#define __APP_LAYER_FRAMES_H__
#ifndef SURICATA_APP_LAYER_FRAMES_H
#define SURICATA_APP_LAYER_FRAMES_H

#include "rust.h"

Expand Down
7 changes: 3 additions & 4 deletions src/app-layer-ftp.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* \author Jeff Lucovsky <[email protected]>
*/

#ifndef __APP_LAYER_FTP_H__
#define __APP_LAYER_FTP_H__
#ifndef SURICATA_APP_LAYER_FTP_H
#define SURICATA_APP_LAYER_FTP_H

#include "rust.h"

Expand Down Expand Up @@ -192,5 +192,4 @@ uint64_t FTPMemcapGlobalCounter(void);
uint16_t JsonGetNextLineFromBuffer(const char *buffer, const uint16_t len);
bool EveFTPDataAddMetadata(void *vtx, JsonBuilder *jb);

#endif /* __APP_LAYER_FTP_H__ */

#endif /* SURICATA_APP_LAYER_FTP_H */
6 changes: 3 additions & 3 deletions src/app-layer-htp-body.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
* This file provides a HTTP protocol support for the engine using HTP library.
*/

#ifndef __APP_LAYER_HTP_BODY_H__
#define __APP_LAYER_HTP_BODY_H__
#ifndef SURICATA_APP_LAYER_HTP_BODY_H
#define SURICATA_APP_LAYER_HTP_BODY_H

int HtpBodyAppendChunk(const HTPCfgDir *, HtpBody *, const uint8_t *, uint32_t);
void HtpBodyPrint(HtpBody *);
void HtpBodyFree(const HTPCfgDir *, HtpBody *);
void HtpBodyPrune(HtpState *, HtpBody *, int);

#endif /* __APP_LAYER_HTP_BODY_H__ */
#endif /* SURICATA_APP_LAYER_HTP_BODY_H */
6 changes: 3 additions & 3 deletions src/app-layer-htp-file.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
*
*/

#ifndef __APP_LAYER_HTP_FILE_H__
#define __APP_LAYER_HTP_FILE_H__
#ifndef SURICATA_APP_LAYER_HTP_FILE_H
#define SURICATA_APP_LAYER_HTP_FILE_H

#include "app-layer-htp.h"

Expand All @@ -41,4 +41,4 @@ int HTPFileClose(HtpState *, HtpTxUserData *tx, const uint8_t *data, uint32_t da

void HTPFileParserRegisterTests(void);

#endif /* __APP_LAYER_HTP_FILE_H__ */
#endif /* SURICATA_APP_LAYER_HTP_FILE_H */
6 changes: 3 additions & 3 deletions src/app-layer-htp-libhtp.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
* APIs from libhtp 0.5.x.
*/

#ifndef __APP_LAYER_HTP_LIBHTP__H__
#define __APP_LAYER_HTP_LIBHTP__H__
#ifndef SURICATA_APP_LAYER_HTP_LIBHTP__H
#define SURICATA_APP_LAYER_HTP_LIBHTP__H

#include "suricata-common.h"

bstr *SCHTPGenerateNormalizedUri(htp_tx_t *tx, htp_uri_t *uri, bool uri_include_all);

#endif /* __APP_LAYER_HTP_LIBHTP__H__ */
#endif /* SURICATA_APP_LAYER_HTP_LIBHTP__H */
6 changes: 3 additions & 3 deletions src/app-layer-htp-range.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* 02110-1301, USA.
*/

#ifndef __APP_LAYER_HTP_RANGE_H__
#define __APP_LAYER_HTP_RANGE_H__
#ifndef SURICATA_APP_LAYER_HTP_RANGE_H
#define SURICATA_APP_LAYER_HTP_RANGE_H

#include "suricata-common.h"

Expand Down Expand Up @@ -111,4 +111,4 @@ HttpRangeContainerBlock *HttpRangeContainerOpenFile(const unsigned char *key, ui

void HttpRangeFreeBlock(HttpRangeContainerBlock *b);

#endif /* __APP_LAYER_HTP_RANGE_H__ */
#endif /* SURICATA_APP_LAYER_HTP_RANGE_H */
6 changes: 3 additions & 3 deletions src/app-layer-htp-xff.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* \author Duarte Silva <[email protected]>
*/

#ifndef __APP_LAYER_HTP_XFF_H__
#define __APP_LAYER_HTP_XFF_H__
#ifndef SURICATA_APP_LAYER_HTP_XFF_H
#define SURICATA_APP_LAYER_HTP_XFF_H

/** XFF is disabled */
#define XFF_DISABLED 1
Expand Down Expand Up @@ -51,4 +51,4 @@ int HttpXFFGetIP(const Flow *f, HttpXFFCfg *xff_cfg, char *dstbuf, int dstbuflen

void HTPXFFParserRegisterTests(void);

#endif /* __APP_LAYER_HTP_XFF_H__ */
#endif /* SURICATA_APP_LAYER_HTP_XFF_H */
6 changes: 3 additions & 3 deletions src/app-layer-htp.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
* This file provides a HTTP protocol support for the engine using HTP library.
*/

#ifndef __APP_LAYER_HTP_H__
#define __APP_LAYER_HTP_H__
#ifndef SURICATA_APP_LAYER_HTP_H
#define SURICATA_APP_LAYER_HTP_H

#include "rust.h"
#include "app-layer-frames.h"
Expand Down Expand Up @@ -297,7 +297,7 @@ void HtpConfigRestoreBackup(void);

void *HtpGetTxForH2(void *);

#endif /* __APP_LAYER_HTP_H__ */
#endif /* SURICATA_APP_LAYER_HTP_H */

/**
* @}
Expand Down
6 changes: 3 additions & 3 deletions src/app-layer-http2.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
* \author Philippe Antoine <[email protected]>
*/

#ifndef __APP_LAYER_HTTP2_H__
#define __APP_LAYER_HTTP2_H__
#ifndef SURICATA_APP_LAYER_HTTP2_H
#define SURICATA_APP_LAYER_HTTP2_H

void RegisterHTTP2Parsers(void);

void HTTP2MimicHttp1Request(void *, void *);

#endif /* __APP_LAYER_HTTP2_H__ */
#endif /* SURICATA_APP_LAYER_HTTP2_H */
6 changes: 3 additions & 3 deletions src/app-layer-ike.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* \author Frank Honza <[email protected]>
*/

#ifndef __APP_LAYER_IKE_H__
#define __APP_LAYER_IKE_H__
#ifndef SURICATA_APP_LAYER_IKE_H
#define SURICATA_APP_LAYER_IKE_H

void RegisterIKEParsers(void);
void IKEParserRegisterTests(void);
Expand All @@ -32,4 +32,4 @@ void IKEParserRegisterTests(void);
typedef struct IKEState_ IKEState;
typedef struct IKETransaction_ IKETransaction;

#endif /* __APP_LAYER_IKE_H__ */
#endif /* SURICATA_APP_LAYER_IKE_H */
6 changes: 3 additions & 3 deletions src/app-layer-krb5.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
* \author Pierre Chifflier <[email protected]>
*/

#ifndef __APP_LAYER_KRB5_H__
#define __APP_LAYER_KRB5_H__
#ifndef SURICATA_APP_LAYER_KRB5_H
#define SURICATA_APP_LAYER_KRB5_H

void RegisterKRB5Parsers(void);
void KRB5ParserRegisterTests(void);
Expand All @@ -31,4 +31,4 @@ void KRB5ParserRegisterTests(void);
typedef struct KRB5State_ KRB5State;
typedef struct KRB5Transaction_ KRB5Transaction;

#endif /* __APP_LAYER_KRB5_H__ */
#endif /* SURICATA_APP_LAYER_KRB5_H */
6 changes: 3 additions & 3 deletions src/app-layer-modbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
* \author David DIALLO <[email protected]>
*/

#ifndef __APP_LAYER_MODBUS_H__
#define __APP_LAYER_MODBUS_H__
#ifndef SURICATA_APP_LAYER_MODBUS_H
#define SURICATA_APP_LAYER_MODBUS_H

void RegisterModbusParsers(void);

#endif /* __APP_LAYER_MODBUS_H__ */
#endif /* SURICATA_APP_LAYER_MODBUS_H */
6 changes: 3 additions & 3 deletions src/app-layer-nfs-tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
* \author Victor Julien <[email protected]>
*/

#ifndef __APP_LAYER_NFS_TCP_H__
#define __APP_LAYER_NFS_TCP_H__
#ifndef SURICATA_APP_LAYER_NFS_TCP_H
#define SURICATA_APP_LAYER_NFS_TCP_H

void RegisterNFSTCPParsers(void);

#endif /* __APP_LAYER_NFS_TCP_H__ */
#endif /* SURICATA_APP_LAYER_NFS_TCP_H */
6 changes: 3 additions & 3 deletions src/app-layer-nfs-udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
* \author Victor Julien <[email protected]>
*/

#ifndef __APP_LAYER_NFS_UDP_H__
#define __APP_LAYER_NFS_UDP_H__
#ifndef SURICATA_APP_LAYER_NFS_UDP_H
#define SURICATA_APP_LAYER_NFS_UDP_H

void RegisterNFSUDPParsers(void);
void NFSUDPParserRegisterTests(void);

#endif /* __APP_LAYER_NFS_UDP_H__ */
#endif /* SURICATA_APP_LAYER_NFS_UDP_H */
Loading

0 comments on commit 44388f1

Please sign in to comment.