* to the project. For more information see the website or contact
* the copyright holders.
*
- * $Id: admin_html.h,v 1.4 2005/02/28 20:28:59 kattemat Exp $
+ * $Id: admin_html.h,v 1.5 2007/10/20 20:41:04 bernd67 Exp $
*/
/*
#ifndef ADMIN_HTML_H
#define ADMIN_HTML_H
-static const char *admin_frame[] =
- {
- "<b>Administrator interface</b><hr>\n"
- "<h2>Change basic settings</h2>\n",
- "<form action=\"set_values\" method=\"post\">\n",
- "<table width=\"100%%\">\n",
- "<!-- BASICSETTINGS -->\n",
- "</table>\n<br>\n",
- "<center><input type=\"submit\" value=\"Submit\" class=\"input_button\">\n",
- "<input type=\"reset\" value=\"Reset\" class=\"input_button\"></center>\n",
- "</form>\n",
- "<h2>Add/remove local HNA entries</h2>\n",
- "<form action=\"set_values\" method=\"post\">\n",
- "<table width=\"100%%\"><tr><td><b>Network:</b></td>\n",
- "<td><input type=\"text\" name=\"hna_new_net\" maxlength=\"16\" class=\"input_text\" value=\"0.0.0.0\"></td>\n",
- "<td><b>Netmask/Prefix:</b></td>\n",
- "<td><input type=\"text\" name=\"hna_new_netmask\" maxlength=\"16\" class=\"input_text\" value=\"0.0.0.0\"></td>\n",
- "<td><input type=\"submit\" value=\"Add entry\" class=\"input_button\"></td></form>\n",
- "</table><hr>\n",
- "<form action=\"set_values\" method=\"post\">\n",
- "<table width=\"100%%\">\n",
- "<tr><th width=50 halign=\"middle\">Delete</th><th>Network</th><th>Netmask</th></tr>\n",
- "<!-- HNAENTRIES -->\n",
- "<tr><td halign=\"middle\"><input type=\"checkbox\" name=\"del_hna%s*%s\" class=\"input_checkbox\"></td><td>%s</td><td>%s</td></tr>\n",
- "</table>\n<br>\n",
- "<center><input type=\"submit\" value=\"Delete selected\" class=\"input_button\"></center>\n",
- "</form>\n",
+static const char admin_frame_prolog[] =
+ "<strong>Administrator interface</strong><hr>\n"
+ "<h2>Change basic settings</h2>\n"
+ "<form action=\"set_values\" method=\"post\">\n"
+ "<table width=\"100%%\">\n";
- NULL
-};
+static const char admin_frame_mid[] =
+ "</table>\n<br>\n"
+ "<center><input type=\"submit\" value=\"Submit\" class=\"input_button\">\n"
+ "<input type=\"reset\" value=\"Reset\" class=\"input_button\"></center>\n"
+ "</form>\n"
+ "<h2>Add/remove local HNA entries</h2>\n"
+ "<form action=\"set_values\" method=\"post\">\n"
+ "<table width=\"100%%\"><tr><td><strong>Network:</strong></td>\n"
+ "<td><input type=\"text\" name=\"hna_new_net\" maxlength=\"16\" class=\"input_text\" value=\"0.0.0.0\"></td>\n"
+ "<td><strong>Netmask/Prefix:</strong></td>\n"
+ "<td><input type=\"text\" name=\"hna_new_netmask\" maxlength=\"16\" class=\"input_text\" value=\"0.0.0.0\"></td>\n"
+ "<td><input type=\"submit\" value=\"Add entry\" class=\"input_button\"></td></form>\n"
+ "</table><hr>\n"
+ "<form action=\"set_values\" method=\"post\">\n"
+ "<table width=\"100%%\">\n"
+ "<tr><th width=50 halign=\"middle\">Delete</th><th>Network</th><th>Netmask</th></tr>\n";
+static const char admin_frame_epilog[] =
+ "</table>\n<br>\n"
+ "<center><input type=\"submit\" value=\"Delete selected\" class=\"input_button\"></center>\n"
+ "</form>\n";
-static char admin_basic_setting_int[] = "<td><b>%s</b></td>\n<td> <input type=\"text\" name=\"%s\" maxlength=\"%d\" class=\"input_text\" value=\"%d\"></td>\n";
-static char admin_basic_setting_float[] = "<td><b>%s</b></td>\n<td> <input type=\"text\" name=\"%s\" maxlength=\"%d\" class=\"input_text\" value=\"%0.2f\"></td>\n";
-static char admin_basic_setting_string[] = "<td><b>%s</b></td>\n<td> <input type=\"text\" name=\"%s\" maxlength=\"%d\" class=\"input_text\" value=\"%s\"></td>\n";
+static const char admin_basic_setting_int[] = "<td><strong>%s</strong></td>\n<td> <input type=\"text\" name=\"%s\" maxlength=\"%d\" class=\"input_text\" value=\"%d\"></td>\n";
+static const char admin_basic_setting_float[] = "<td><strong>%s</strong></td>\n<td> <input type=\"text\" name=\"%s\" maxlength=\"%d\" class=\"input_text\" value=\"%0.2f\"></td>\n";
+static const char admin_basic_setting_string[] = "<td><strong>%s</strong></td>\n<td> <input type=\"text\" name=\"%s\" maxlength=\"%d\" class=\"input_text\" value=\"%s\"></td>\n";
#endif
* to the project. For more information see the website or contact
* the copyright holders.
*
- * $Id: admin_interface.c,v 1.9 2007/08/19 23:00:22 bernd67 Exp $
+ * $Id: admin_interface.c,v 1.10 2007/10/20 20:41:04 bernd67 Exp $
*/
/*
int
build_admin_body(char *buf, olsr_u32_t bufsize __attribute__((unused)))
{
- int size = 0, i = 0;
-
- while(admin_frame[i] && strcmp(admin_frame[i], "<!-- BASICSETTINGS -->\n"))
- {
- size += snprintf(&buf[size], bufsize-size, admin_frame[i]);
- i++;
- }
-
- if(!admin_frame[i])
- return size;
-
+ int size = 0;
+ size += snprintf(&buf[size], bufsize-size, admin_frame_prolog);
size += snprintf(&buf[size], bufsize-size, "<tr>\n");
size += snprintf(&buf[size], bufsize-size, admin_basic_setting_int,
"Willingness:", "willingness", 1, olsr_cnf->willingness);
- size += snprintf(&buf[size], bufsize-size, "</tr>\n");
- size += snprintf(&buf[size], bufsize-size, "<tr>\n");
+ size += snprintf(&buf[size], bufsize-size, "</tr>\n"
+ "<tr>\n");
- if(olsr_cnf->use_hysteresis)
- {
- size += snprintf(&buf[size], bufsize-size, admin_basic_setting_float,
- "Hyst scaling:", "hyst_scaling", 4, olsr_cnf->hysteresis_param.scaling);
+ if(olsr_cnf->use_hysteresis) {
+ size += snprintf(&buf[size], bufsize-size, admin_basic_setting_float,
+ "Hyst scaling:", "hyst_scaling", 4, olsr_cnf->hysteresis_param.scaling);
- size += snprintf(&buf[size], bufsize-size, admin_basic_setting_float,
- "Lower thr:", "hyst_lower", 4, olsr_cnf->hysteresis_param.thr_low);
- size += snprintf(&buf[size], bufsize-size, admin_basic_setting_float,
- "Upper thr:", "hyst_upper", 4, olsr_cnf->hysteresis_param.thr_high);
- }
- else
- {
- size += snprintf(&buf[size], bufsize-size, "<td>Hysteresis disabled</td>\n");
- }
+ size += snprintf(&buf[size], bufsize-size, admin_basic_setting_float,
+ "Lower thr:", "hyst_lower", 4, olsr_cnf->hysteresis_param.thr_low);
+ size += snprintf(&buf[size], bufsize-size, admin_basic_setting_float,
+ "Upper thr:", "hyst_upper", 4, olsr_cnf->hysteresis_param.thr_high);
+ } else {
+ size += snprintf(&buf[size], bufsize-size, "<td>Hysteresis disabled</td>\n");
+ }
- size += snprintf(&buf[size], bufsize-size, "</tr>\n");
- size += snprintf(&buf[size], bufsize-size, "<tr>\n");
+ size += snprintf(&buf[size], bufsize-size, "</tr>\n"
+ "<tr>\n");
- if(olsr_cnf->lq_level)
- {
- size += snprintf(&buf[size], bufsize-size, admin_basic_setting_int,
- "LQ level:", "lq_level", 1, olsr_cnf->lq_level);
- size += snprintf(&buf[size], bufsize-size, admin_basic_setting_int,
- "LQ winsize:", "lq_wsize", 2, olsr_cnf->lq_wsize);
- }
- else
- {
- size += snprintf(&buf[size], bufsize-size, "<td>LQ disabled</td>\n");
- }
-
-
- size += snprintf(&buf[size], bufsize-size, "</tr>\n");
- size += snprintf(&buf[size], bufsize-size, "<tr>\n");
-
+ if(olsr_cnf->lq_level) {
+ size += snprintf(&buf[size], bufsize-size, admin_basic_setting_int,
+ "LQ level:", "lq_level", 1, olsr_cnf->lq_level);
+ size += snprintf(&buf[size], bufsize-size, admin_basic_setting_int,
+ "LQ winsize:", "lq_wsize", 2, olsr_cnf->lq_wsize);
+ } else {
+ size += snprintf(&buf[size], bufsize-size, "<td>LQ disabled</td>\n");
+ }
+
+ size += snprintf(&buf[size], bufsize-size, "</tr>\n"
+ "<tr>\n");
size += snprintf(&buf[size], bufsize-size, "</tr>\n");
- i++;
-
- while(admin_frame[i] && strcmp(admin_frame[i], "<!-- HNAENTRIES -->\n"))
- {
- size += snprintf(&buf[size], bufsize-size, admin_frame[i]);
- i++;
- }
-
- if(!admin_frame[i] || !admin_frame[i+1])
- return size;
-
- i++;
-
- if((olsr_cnf->ip_version == AF_INET) && (olsr_cnf->hna4_entries))
- {
- struct hna4_entry *hna4;
-
- for(hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next)
- {
- size += snprintf(&buf[size], bufsize-size, admin_frame[i],
- olsr_ip_to_string((union olsr_ip_addr *)&hna4->net),
- olsr_ip_to_string((union olsr_ip_addr *)&hna4->netmask),
- olsr_ip_to_string((union olsr_ip_addr *)&hna4->net),
- olsr_ip_to_string((union olsr_ip_addr *)&hna4->netmask));
- }
- }
- else if((olsr_cnf->ip_version == AF_INET6) && (olsr_cnf->hna6_entries))
- {
- struct hna6_entry *hna6;
-
- for(hna6 = olsr_cnf->hna6_entries; hna6; hna6 = hna6->next)
- {
- size += snprintf(&buf[size], bufsize-size, admin_frame[i],
- olsr_ip_to_string((union olsr_ip_addr *)&hna6->net),
- "TBD"/*hna6->prefix_len*/);
- }
+ size += snprintf(&buf[size], bufsize-size, admin_frame_mid);
+
+ if(olsr_cnf->ip_version == AF_INET) {
+ struct hna4_entry *hna4;
+ for(hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next) {
+ const char * const net = olsr_ip_to_string((union olsr_ip_addr *)&hna4->net);
+ const char * const mask = olsr_ip_to_string((union olsr_ip_addr *)&hna4->netmask);
+ size += snprintf(&buf[size], bufsize-size,
+ "<tr><td halign=\"middle\"><input type=\"checkbox\" name=\"del_hna%s*%s\" class=\"input_checkbox\"></td><td>%s</td><td>%s</td></tr>\n",
+ net,
+ mask,
+ net,
+ mask);
}
-
- i++;
-
- while(admin_frame[i])
- {
- size += snprintf(&buf[size], bufsize-size, admin_frame[i]);
- i++;
+ } else {
+ struct hna6_entry *hna6;
+ for(hna6 = olsr_cnf->hna6_entries; hna6; hna6 = hna6->next) {
+ const char * const net = olsr_ip_to_string((union olsr_ip_addr *)&hna6->net);
+ size += snprintf(&buf[size], bufsize-size,
+ "<tr><td halign=\"middle\"><input type=\"checkbox\" name=\"del_hna%s*%d\" class=\"input_checkbox\"></td><td>%s</td><td>%d</td></tr>\n",
+ net,
+ hna6->prefix_len,
+ net,
+ hna6->prefix_len);
}
-
+ }
+ size += snprintf(&buf[size], bufsize-size, admin_frame_epilog);
return size;
}