static int bgp_dump_set (struct vty *vty, struct bgp_dump *bgp_dump, enum bgp_dump_type type, const char *path, const char *interval_str) { unsigned int interval; if (interval_str) { /* Check interval string. */ interval = bgp_dump_parse_time (interval_str); if (interval == 0) { vty_out (vty, "Malformed interval string%s", VTY_NEWLINE); return CMD_WARNING; } /* Don't schedule duplicate dumps if the dump command is given twice */ if (interval == bgp_dump->interval && type == bgp_dump->type && path && bgp_dump->filename && !strcmp (path, bgp_dump->filename)) { return CMD_SUCCESS; } /* Set interval. */ bgp_dump->interval = interval; if (bgp_dump->interval_str) free (bgp_dump->interval_str); bgp_dump->interval_str = strdup (interval_str); } else { interval = 0; } /* Create interval thread. */ bgp_dump_interval_add (bgp_dump, interval); /* Set type. */ bgp_dump->type = type; /* Set file name. */ if (bgp_dump->filename) free (bgp_dump->filename); bgp_dump->filename = strdup (path); /* This should be called when interval is expired. */ bgp_dump_open_file (bgp_dump); return CMD_SUCCESS; }
int bgp_dump_set (struct vty *vty, struct bgp_dump *bgp_dump, int type, const char *path, const char *interval_str) { unsigned int interval; if (interval_str) { /* Check interval string. */ interval = bgp_dump_parse_time (interval_str); if (interval == 0) { vty_out (vty, "Malformed interval string%s", VTY_NEWLINE); return CMD_WARNING; } /* Set interval. */ bgp_dump->interval = interval; if (bgp_dump->interval_str) free (bgp_dump->interval_str); bgp_dump->interval_str = strdup (interval_str); } else { interval = 0; } /* Create interval thread. */ bgp_dump_interval_add (bgp_dump, interval); /* Set type. */ bgp_dump->type = type; /* Set file name. */ if (bgp_dump->filename) free (bgp_dump->filename); bgp_dump->filename = strdup (path); /* This should be called when interval is expired. */ bgp_dump_open_file (bgp_dump); return CMD_SUCCESS; }