Merged with BB-stefan

This commit is contained in:
Martin Schröder 2015-05-06 19:03:32 +02:00 committed by Martin Schröder
parent 69b54433b1
commit 4f37cdb979
6 changed files with 102 additions and 64 deletions

View file

@ -60,17 +60,8 @@ angular.module("luci")
"asterisk.status",
"luci2.system.password_set",
"luci2.system.backup_restore",
"luci2.system.upgrade_test",
"luci2.system.upgrade_clean",
"luci2.system.upgrade_start",
"luci2.system.reset_test",
"luci2.system.reset_start",
"luci2.system.reboot",
"luci2.system.ping",
"luci2.network.ping",
"luci2.network.traceroute",
"network.interface.dump",
"router.networks",
// local stuff for the node server.
"local.features",
"local.set_rpc_host"

View file

@ -1,4 +1,67 @@
$juci.module("settings")
.controller("SettingsConfigurationCtrl", function($scope){
.controller("SettingsConfigurationCtrl", function($scope, $rpc, $session){
$scope.sessionID = $session.sid;
$scope.resetPossible = 0;
$rpc.luci2.system.reset_test().done(function(result){
if(result && result.supported) {
$scope.resetPossible = 1;
$scope.$apply();
}
});
$scope.onReset = function(){
$rpc.luci2.system.reset_start().done(function(result){
console.log("Performing reset: "+JSON.stringify(result));
});
}
$scope.onSaveConfig = function(){
$scope.showModal = 1;
}
$scope.onRestoreConfig = function(){
$scope.showUploadModal = 1;
}
$scope.onCancelRestore = function(){
$scope.showUploadModal = 0;
}
$scope.restore = {};
/*setInterval(function checkUpload(){
var iframe = $("#postiframe").load(function(){;
var json = iframe.contents().text();
try {
if(json.length && JSON.parse(json)) {
$scope.onUploadComplete(JSON.parse(json));
}
} catch(e){}
iframe.each(function(e){$(e).contents().html("<html>");}); ;
}, 500); */
$scope.onUploadConfig = function(){
$("#postiframe").bind("load", function(){
var json = $(this).contents().text();
try {
var obj = JSON.parse(json);
$scope.onUploadComplete(JSON.parse(json));
} catch(e){}
$(this).unbind("load");
});
$("form[name='restoreForm']").submit();
}
$scope.onUploadComplete = function(result){
console.log("Result: "+JSON.stringify(result)+": "+$scope.restore.password);
$rpc.luci2.system.backup_restore({
password: $scope.restore.password
}).done(function(result){
if(result.code){
alert(result.stderr);
} else {
$scope.showUploadModal = 0;
}
});
}
$scope.onAcceptModal = function(){
$("form[name='backupForm']").submit();
$scope.showModal = 0;
}
$scope.onDismissModal = function(){
$scope.showModal = 0;
}
});

View file

@ -13,10 +13,10 @@
<iframe name="postiframe" id="postiframe" style="display: none;" ></iframe>
<form target="postiframe" action="/cgi-bin/luci-upload" method="post" enctype="multipart/form-data">
<input type="hidden" name="sessionid" value="{{sessionID}}" />
<input type="hidden" name="filename" value="/tmp/firmware.bin" />
<input type="hidden" name="filename" value="{{uploadFilename}}" />
<luci-config-lines>
<luci-config-line title="{{'Pick firmware file to upload'|translate}}">
<input type="file" class="" name="filedata" />
<input type="file" class="btn btn-default btn-file" name="filedata" />
</luci-config-line>
<luci-config-line title="{{'Start upgrade'|translate}}">
<input type="submit" class="btn btn-lg btn-default" value="{{'Upgrade'|translate}}"/>

View file

@ -109,11 +109,19 @@
})( jQuery);
$juci.module("settings")
.controller("SettingsUpgradeCtrl", function($scope, $session){
.controller("SettingsUpgradeCtrl", function($scope, $uci, $session){
$scope.sessionID = $session.sid;
$scope.uploadFilename = "/tmp/firmware.bin";
$scope.usbFileName = "()";
console.log("SID: "+$scope.sessionID);
$uci.sync("system").done(function(){
if($uci.system.upgrade && $uci.system.upgrade.fw_upload_path.value){
$scope.uploadFilename = $uci.system.upgrade.fw_upload_path.value;
console.log("Using upload path from config: "+$scope.uploadFilename);
}
});
$scope.onUploadComplete = function(result){
console.log("Upload completed: "+JSON.stringify(result));
}
@ -122,9 +130,9 @@ $juci.module("settings")
var json = iframe.contents().text();
if(json.length) {
$scope.onUploadComplete(JSON.parse(json));
iframe.contents().html("<html>");
iframe.contents().html("");
}
}, 100);
}, 500);
$scope.onUploadUpgrade = function(){
var formData = new FormData($('uploadForm')[0]);

View file

@ -8,6 +8,7 @@
#include "questd.h"
#include "igmp.h"
static void tokenize_line(char *str, const char **tokens, size_t tokens_size) {
char *ptr = str;
const char **token = tokens; // = line;
@ -26,7 +27,7 @@ static void tokenize_line(char *str, const char **tokens, size_t tokens_size) {
continue;
}
ptr++;
}
}
}
int igmp_rpc(struct ubus_context *ctx, struct ubus_object *obj,
@ -38,7 +39,7 @@ int igmp_rpc(struct ubus_context *ctx, struct ubus_object *obj,
char line[256];
IGMPtable table[128];
const char *tokens[32] = { 0 };
void *object, *array,*t;
void *object, *array;
blob_buf_init(&bb, 0);
if (!(in = fopen("/tmp/igmp_snooping", "r")))
@ -59,91 +60,80 @@ int igmp_rpc(struct ubus_context *ctx, struct ubus_object *obj,
tokenize_line(line, tokens, sizeof(tokens) / sizeof(char*));
int tok_pos = 0;
const char **token = tokens;
const char *names[] = { "bridge", "dev", "srcdev", "tags", "lantci",
"wantci", "group", "mode", "rxgroup", "source", "reporter",
"timeout", "index", "excludept" };
//const char *names[] = { "bridge", "dev", "srcdev", "tags", "lantci",
// "wantci", "group", "mode", "rxgroup", "source", "reporter",
// "timeout", "index", "excludept" };
while (*token) {
printf("<%d>\n",tok_pos);
switch (tok_pos) {
case 0:
snprintf(table[row-2].bridge,"%s",token);
printf("%s\n%s\n",table[row-2].bridge,token);
sprintf(table[row-2].bridge,"%s",*token);
printf("%s\n%s\n",table[row-2].bridge,*token);
break;
case 1:
snprintf(table[row-2].device,"%s",token);
sprintf(table[row-2].device,"%s",*token);
break;
case 2:
snprintf(table[row - 2].tags ,"%s",token);
sprintf(table[row - 2].tags ,"%s",*token);
break;
case 3: {
uint32_t ip;
char str[17];
sscanf(token, "%8x", &ip);
sscanf(*token, "%8x", &ip);
sprintf(table[row - 2].lantci, "%d.%d.%d.%d", (ip >> 16),
(ip >> 8) & 0xff, ip & 0xff, (ip >> 24) & 0xff);
}
break;
case 4: {
uint32_t ip;
char str[17];
sscanf(token, "%8x", &ip);
sscanf(*token, "%8x", &ip);
sprintf(table[row - 2].wantci, "%d.%d.%d.%d", (ip >> 16),
(ip >> 8) & 0xff, ip & 0xff, (ip >> 24) & 0xff);
}
break;
case 5: {
uint32_t ip;
char str[17];
sscanf(token, "%8x", &ip);
sscanf(*token, "%8x", &ip);
sprintf(table[row - 2].group, "%d.%d.%d.%d", (ip >> 16),
(ip >> 8) & 0xff, ip & 0xff, (ip >> 24) & 0xff);
}
break;
case 6:
snprintf(table[row - 2].mode,"%s",token);
sprintf(table[row - 2].mode,"%s",*token);
break;
case 7: {
uint32_t ip;
char str[17];
sscanf(token, "%8x", &ip);
sscanf(*token, "%8x", &ip);
sprintf(table[row - 2].RxGroup, "%d.%d.%d.%d", (ip >> 16),
(ip >> 8) & 0xff, ip & 0xff, (ip >> 24) & 0xff);
}
break;
case 8: {
uint32_t ip;
char str[17];
sscanf(token, "%8x", &ip);
sscanf(*token, "%8x", &ip);
sprintf(table[row - 2].source, "%d.%d.%d.%d", (ip >> 16),
(ip >> 8) & 0xff, ip & 0xff, (ip >> 24) & 0xff);
}
break;
case 9: {
uint32_t ip;
char str[17];
sscanf(token, "%8x", &ip);
sscanf(*token, "%8x", &ip);
sprintf(table[row - 2].reporter, "%d.%d.%d.%d", (ip >> 16),
(ip >> 8) & 0xff, ip & 0xff, (ip >> 24) & 0xff);
}
break;
case 10:
snprintf(table[row - 2].timeout,"%s",token);
sprintf(table[row - 2].timeout,"%s",*token);
break;
case 11:
snprintf(table[row - 2].Index,"%s",token);
sprintf(table[row - 2].Index,"%s",*token);
break;
case 12:
snprintf(table[row - 2].ExcludPt,"%s",token);
sprintf(table[row - 2].ExcludPt,"%s",*token);
break;
default:
@ -182,3 +172,4 @@ int igmp_rpc(struct ubus_context *ctx, struct ubus_object *obj,
return 0;
}

View file

@ -329,11 +329,11 @@ match_client_to_network(Network *lan, char *hostaddr, bool *local, char *net, ch
if((snet.s_addr ^ rslt.s_addr) == 0) {
*local = true;
snprintf(net, 32, lan->name);
snprintf(*net, 32, lan->name);
if (lan->type && !strcmp(lan->type, "bridge"))
snprintf(dev, 32, "br-%s", lan->name);
snprintf(*dev, 32, "br-%s", lan->name);
else
snprintf(dev, 32, lan->ifname);
snprintf(*dev, 32, lan->ifname);
}
}
@ -1313,21 +1313,6 @@ quest_router_igmp_table(struct ubus_context *ctx, struct ubus_object *obj,
return 0;
}*/
static int
quest_router_igmp_table(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
struct blob_attr *msg)
{
struct blob_attr *tb[__QUEST_MAX];
blobmsg_parse(quest_policy, __QUEST_MAX, tb, blob_data(msg), blob_len(msg));
blob_buf_init(&bb, 0);
router_dump_connected_clients6(&bb);
ubus_send_reply(ctx, req, bb.head);
return 0;
}
static int
quest_router_clients6(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,