管理设备
pre_live_devices:临时存储device
live_devices:存储最终的device
添加设备
添加设备有两种方法:
- 命令参数
每个模式参数选项不一样
pcap模式:
-i <dev or ip> : run in pcap live mode
--pcap[=<dev>] : run in pcap mode, no value select interfaces from suricata.yaml
suricata从启动参数读取的设备先添加到pre_live_devices,再添加到live_devices
main(int argc, char ** argv) (main.c:26)
SuricataMain(int argc, char ** argv) (suricata.c:2944)
ParseCommandLine(int argc, char ** argv, SCInstance * suri) (suricata.c:1851)
ParseCommandLinePcapLive(SCInstance * suri, const char * in_arg) (suricata.c:1254)
//LiveRegisterDeviceName将设备添加到pre_live_devices
LiveRegisterDeviceName(const char * dev) (util-device.c:110)
main(int argc, char ** argv) (main.c:26)
SuricataMain(int argc, char ** argv) (suricata.c:3001)
PostConfLoadedSetup(SCInstance * suri) (suricata.c:2824)
//遍历pre_live_devices,调用LiveRegisterDevice
LiveDeviceFinalize() (util-device.c:523)
//将device添加到live_devices
LiveRegisterDevice(const char * dev) (util-device.c:146)
- 读取配置文件
suricata从命令行获取runmode,然后调用ParseInterfacesList来解析对应runmode的设备列表
suricata从配置文件读取的设备先添加到pre_live_devices,再添加到live_devices
pcap模式:
main(int argc, char ** argv) (main.c:26)
SuricataMain(int argc, char ** argv) (suricata.c:2997)
ParseInterfacesList(const int runmode, char * pcap_dev) (suricata.c:970)
LiveBuildDeviceList(const char * runmode) (util-device.c:310)
LiveBuildDeviceListCustom(const char * runmode, const char * itemname) (util-device.c:330)
LiveRegisterDeviceName(const char * dev) (util-device.c:97)
- 注册runmode时添加
注册runmode时,通过LiveRegisterDevice添加,比如dpdk模式