本文整理汇总了C++中NetworkInterface::set_cpu_affinity方法的典型用法代码示例。如果您正苦于以下问题:C++ NetworkInterface::set_cpu_affinity方法的具体用法?C++ NetworkInterface::set_cpu_affinity怎么用?C++ NetworkInterface::set_cpu_affinity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkInterface
的用法示例。
在下文中一共展示了NetworkInterface::set_cpu_affinity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
#endif
{
HTTPserver *httpd = NULL;
Prefs *prefs = NULL;
char *ifName;
int rc;
#ifdef WIN32
initWinsock32();
#endif
if((ntop = new(std::nothrow) Ntop(argv[0])) == NULL) _exit(0);
if((prefs = new(std::nothrow) Prefs(ntop)) == NULL) _exit(0);
#ifndef WIN32
if((argc == 2) && (argv[1][0] != '-'))
rc = prefs->loadFromFile(argv[1]);
else
#endif
rc = prefs->loadFromCLI(argc, argv);
if(rc < 0) return(-1);
ntop->registerPrefs(prefs);
prefs->registerNetworkInterfaces();
if(prefs->get_num_user_specified_interfaces() == 0) {
/* We add all interfaces available on this host */
prefs->add_default_interfaces();
}
if(prefs->daemonize_ntopng())
ntop->daemonize();
for(int i=0; i<MAX_NUM_INTERFACES; i++) {
NetworkInterface *iface;
if((ifName = ntop->get_if_name(i)) == NULL)
continue;
/* [ [email protected]://127.0.0.1:5556 ] */
if(ifName && (strstr(ifName, "tcp://")
|| strstr(ifName, "ipc://"))
) {
char *at = strchr(ifName, '@');
char *topic = (char*)"flow", *endpoint;
if(at != NULL)
endpoint = &at[1];
else
endpoint = ifName;
iface = new CollectorInterface(endpoint, topic);
} else {
#ifdef HAVE_PF_RING
try {
iface = new PF_RINGInterface(ifName);
} catch (int) {
#endif
iface = new PcapInterface(ifName);
#ifdef HAVE_PF_RING
}
#endif
}
if(prefs->get_cpu_affinity() >= 0)
iface->set_cpu_affinity(prefs->get_cpu_affinity());
if(prefs->get_packet_filter() != NULL)
iface->set_packet_filter(prefs->get_packet_filter());
ntop->registerInterface(iface);
}
ntop->createExportInterface();
if(prefs->do_dump_flows_on_db())
ntop->createHistoricalInterface();
if(ntop->getInterfaceAtId(0) == NULL) {
ntop->getTrace()->traceEvent(TRACE_ERROR, "Startup error: missing super-user privileges ?");
_exit(0);
}
if(prefs->do_change_user())
Utils::dropPrivileges();
#ifndef WIN32
if(prefs->get_pid_path() != NULL) {
FILE *fd;
fd = fopen(prefs->get_pid_path(), "w");
if(fd != NULL) {
fprintf(fd, "%u\n", getpid());
fclose(fd);
chmod(prefs->get_pid_path(), 0777);
ntop->getTrace()->traceEvent(TRACE_NORMAL, "PID stored in file %s",
prefs->get_pid_path());
//.........这里部分代码省略.........