@@ -66,36 +66,33 @@ const char *RunModeAFPGetDefaultMode(void)
66
66
return "workers" ;
67
67
}
68
68
69
- static int AFPRunModeIsIPS (void )
69
+ static bool AFPRunModeIsIPS (void )
70
70
{
71
71
int nlive = LiveGetDeviceCount ();
72
- int ldev ;
73
- ConfNode * if_root ;
74
- ConfNode * if_default = NULL ;
75
- ConfNode * af_packet_node ;
76
- int has_ips = 0 ;
77
- int has_ids = 0 ;
72
+ bool has_ips = false;
73
+ bool has_ids = false;
78
74
79
- /* Find initial node */
80
- af_packet_node = ConfGetNode ("af-packet" );
75
+ ConfNode * af_packet_node = ConfGetNode ("af-packet" );
81
76
if (af_packet_node == NULL ) {
82
- return 0 ;
77
+ SCLogConfig ("no 'af-packet' section in the yaml, default to IDS" );
78
+ return false;
83
79
}
84
80
85
- if_default = ConfNodeLookupKeyValue (af_packet_node , "interface" , "default" );
81
+ ConfNode * if_default = ConfNodeLookupKeyValue (af_packet_node , "interface" , "default" );
86
82
87
- for (ldev = 0 ; ldev < nlive ; ldev ++ ) {
83
+ for (int ldev = 0 ; ldev < nlive ; ldev ++ ) {
88
84
const char * live_dev = LiveGetDeviceName (ldev );
89
85
if (live_dev == NULL ) {
90
- SCLogError ( "Problem with config file" );
91
- return -1 ;
86
+ SCLogConfig ( "no 'af-packet' section for '%s' in the yaml, default to IDS" , live_dev );
87
+ return false ;
92
88
}
93
- if_root = ConfFindDeviceConfig (af_packet_node , live_dev );
94
-
89
+ ConfNode * if_root = ConfFindDeviceConfig (af_packet_node , live_dev );
95
90
if (if_root == NULL ) {
96
91
if (if_default == NULL ) {
97
- SCLogError ("Problem with config file" );
98
- return -1 ;
92
+ SCLogConfig (
93
+ "no 'af-packet' section for '%s' or 'default' in the yaml, default to IDS" ,
94
+ live_dev );
95
+ return false;
99
96
}
100
97
if_root = if_default ;
101
98
}
@@ -105,28 +102,28 @@ static int AFPRunModeIsIPS(void)
105
102
if (ConfGetChildValueWithDefault (if_root , if_default , "copy-mode" , & copymodestr ) == 1 &&
106
103
ConfGetChildValue (if_root , "copy-iface" , & copyifacestr ) == 1 ) {
107
104
if (strcmp (copymodestr , "ips" ) == 0 ) {
108
- has_ips = 1 ;
105
+ has_ips = true ;
109
106
} else {
110
- has_ids = 1 ;
107
+ has_ids = true ;
111
108
}
112
109
} else {
113
- has_ids = 1 ;
110
+ has_ids = true ;
114
111
}
115
112
}
116
113
117
114
if (has_ids && has_ips ) {
118
115
SCLogError ("using both IPS and TAP/IDS mode is not allowed due to undefined behavior. See "
119
116
"ticket #5588." );
120
- return -1 ;
117
+ return false ;
121
118
}
122
119
123
120
return has_ips ;
124
121
}
125
122
126
123
static int AFPRunModeEnableIPS (void )
127
124
{
128
- int r = AFPRunModeIsIPS ();
129
- if (r == 1 ) {
125
+ bool r = AFPRunModeIsIPS ();
126
+ if (r ) {
130
127
SCLogInfo ("Setting IPS mode" );
131
128
EngineModeSetIPS ();
132
129
}
0 commit comments