- if(req.type == REQ_DUMP_NODES) {
- logger(LOG_NOTICE, _("Got '%s' command"), "dump nodes");
- res.res_errno = dump_nodes(res_data);
- goto respond;
- }
-
- if(req.type == REQ_DUMP_EDGES) {
- logger(LOG_NOTICE, _("Got '%s' command"), "dump edges");
- res.res_errno = dump_edges(res_data);
- goto respond;
- }
-
- if(req.type == REQ_DUMP_SUBNETS) {
- logger(LOG_NOTICE, _("Got '%s' command"), "dump subnets");
- res.res_errno = dump_subnets(res_data);
- goto respond;
- }
-
- if(req.type == REQ_DUMP_CONNECTIONS) {
- logger(LOG_NOTICE, _("Got '%s' command"), "dump connections");
- res.res_errno = dump_connections(res_data);
- goto respond;
- }
-
- if(req.type == REQ_DUMP_GRAPH) {
- logger(LOG_NOTICE, _("Got '%s' command"), "dump graph");
- res.res_errno = dump_graph(res_data);
- goto respond;
- }
-
- if(req.type == REQ_PURGE) {
- logger(LOG_NOTICE, _("Got '%s' command"), "purge");
- purge();
- goto respond;
- }
-
- logger(LOG_DEBUG, _("Malformed control command received"));
- res.res_errno = EINVAL;
-
-respond:
- res.length = (sizeof res)
- + ((res_data == NULL) ? 0 : EVBUFFER_LENGTH(res_data));
- evbuffer_drain(event->input, req.length);
- if(bufferevent_write(event, &res, sizeof res) == -1)
- goto failure;
- if(res_data != NULL) {
- if(bufferevent_write_buffer(event, res_data) == -1)
- goto failure;
- evbuffer_free(res_data);
- }
- return;
-
-failure:
- logger(LOG_INFO, _("Closing control socket on error"));
- evbuffer_free(res_data);
- close(event->ev_read.ev_fd);
- splay_delete(control_socket_tree, event);