int main(int argc, char *argv[]) { if (argc < 2)return -1; if (another_instance()) return -179; #ifndef BGP_GDB_DEBUG_NO_DAEMON // try to daemon if (daemon(0, 1)) return errno; #endif try { // open syslog as BGP for debug openlog("BGP", LOG_CONS, LOG_LOCAL7); std::auto_ptr<BGP> bgp(new BGP); // get 2 byte AS from argv[1] uint16_t AS((uint16_t) atoi(argv[1])); if (AS)bgp->init_BGP(AS); else { syslog(LOG_DEBUG, "Invalid AS=%i", AS); } // catch all system errors } catch (std::system_error &e) { syslog(LOG_CRIT, "fatal error: %s", e.what()); } close(lock_file); remove("/tmp/bgp_lock"); return 0; }
void *start_bgp(void *top) { BGProcess bgp((SkipIndex*)top); bgp.start(); }