Drop interface from html_open, use global opt_interface.
[darkstat] / graph_db.c
index 63ecc9d..e0daa53 100644 (file)
@@ -28,8 +28,6 @@
 #define GRAPH_WIDTH "320"
 #define GRAPH_HEIGHT "200"
 
-extern const char *interface;
-
 struct graph {
    uint64_t *in, *out;
    unsigned int offset; /* i.e. seconds start at 0, days start at 1 */
@@ -302,12 +300,6 @@ graph_export(const int fd)
    return 1;
 }
 
-static void cb_headers(struct str *buf)
-{
-   str_appendf(buf, "<script src=\"%s%s\" type=\"text/javascript\">"
-      "</script>\n", base_url, "graph.js");
-}
-
 /* ---------------------------------------------------------------------------
  * Web interface: front page!
  */
@@ -319,7 +311,7 @@ html_front_page(void)
    char start_when[100];
 
    buf = str_make();
-   html_open(buf, "Graphs", interface, cb_headers);
+   html_open(buf, "Graphs", /*want_graph_js=*/1);
 
    str_append(buf, "<p>\n");
    str_append(buf, "<b>Running for</b> <span id=\"rf\">");
@@ -333,15 +325,15 @@ html_front_page(void)
       "%Y-%m-%d %H:%M:%S %Z%z", localtime(&start_time)) != 0)
       str_appendf(buf, "<b>, since</b> %s", start_when);
 
-   str_appendf(buf,"<b>.</b><br/>\n"
+   str_appendf(buf,"<b>.</b><br>\n"
       "<b>Total</b> <span id=\"tb\">%'qu</span> <b>bytes, "
       "in</b> <span id=\"tp\">%'qu</span> <b>packets.</b> "
       "(<span id=\"pc\">%'u</span> <b>captured,</b> "
-      "<span id=\"pd\">%'u</span> <b>dropped)</b><br/>\n"
+      "<span id=\"pd\">%'u</span> <b>dropped)</b><br>\n"
       "</p>\n",
-      total_bytes,
-      total_packets,
-      pkts_recv, pkts_drop);
+      acct_total_bytes,
+      acct_total_packets,
+      cap_pkts_recv, cap_pkts_drop);
 
    str_append(buf,
       "<div id=\"graphs\">\n"
@@ -351,7 +343,7 @@ html_front_page(void)
       "var graph_width = " GRAPH_WIDTH ";\n"
       "var graph_height = " GRAPH_HEIGHT ";\n"
       "var bar_gap = 1;\n"
-      "var graphs_uri = \"/graphs.xml\";\n"
+      "var graphs_uri = \"graphs.xml\";\n"
       "var graphs = [\n"
    );
 
@@ -388,7 +380,7 @@ xml_graphs(void)
    struct str *buf = str_make(), *rf;
 
    str_appendf(buf, "<graphs tp=\"%qu\" tb=\"%qu\" pc=\"%u\" pd=\"%u\" rf=\"",
-      total_packets, total_bytes, pkts_recv, pkts_drop);
+      acct_total_packets, acct_total_bytes, cap_pkts_recv, cap_pkts_drop);
    rf = length_of_time(now - start_time);
    str_appendstr(buf, rf);
    str_free(rf);