summaryrefslogtreecommitdiff
path: root/application/boottable
diff options
context:
space:
mode:
authorBenjamin Decavel2009-03-31 17:20:32 +0200
committerBenjamin Decavel2009-03-31 17:20:32 +0200
commit791edd65752446a2c99d9089281b657cdc2ff341 (patch)
treece6587b6d4a21458c44b2925d320074e30d0668d /application/boottable
parentede849ec92aa9d5dd198cedaf30fd680762e6523 (diff)
Updating the master through SNMP now calls boottable_secure_create rather than a simple boottable_create
Diffstat (limited to 'application/boottable')
-rw-r--r--application/boottable/Makefile2
-rw-r--r--application/boottable/inc/boottable.h1
-rwxr-xr-xapplication/boottable/src/commands.c11
-rwxr-xr-xapplication/boottable/src/commands_linux.c24
-rw-r--r--application/boottable/src/ftp.c17
5 files changed, 49 insertions, 6 deletions
diff --git a/application/boottable/Makefile b/application/boottable/Makefile
index 73340c31f0..6eab987f81 100644
--- a/application/boottable/Makefile
+++ b/application/boottable/Makefile
@@ -9,7 +9,7 @@ SRCDIR=src
INCDIR=inc
OBJDIR=obj
-OBJ=commands_linux.o posix_crc.o image_table_linux.o mtd_part.o
+OBJ=commands_linux.o posix_crc.o image_table_linux.o mtd_part.o commands.o ftp.o
BT_OBJ=commands.o ftp.o bt.o
OBJS=$(addprefix $(OBJDIR)/,$(OBJ))
BT_OBJS=$(addprefix $(OBJDIR)/,$(BT_OBJ))
diff --git a/application/boottable/inc/boottable.h b/application/boottable/inc/boottable.h
index d23d2c606f..1c5e7952b7 100644
--- a/application/boottable/inc/boottable.h
+++ b/application/boottable/inc/boottable.h
@@ -22,6 +22,7 @@ extern int SOFTWARE_UPGRADE_IN_PROGRESS;
*/
extern void bootTable_register_commands(void);
int boottable_create(char* ftpIp, uint16_t ftpPort, char* login, char* passwd, char* filename);
+int boottable_secure_create(char* ftpIp, uint16_t ftpPort, char* login, char* passwd, char *remoteFile, char* md5_file);
int boottable_select(char* filename);
int boottable_erase(char* filename);
int boottable_images(char releaseName[10][32]);
diff --git a/application/boottable/src/commands.c b/application/boottable/src/commands.c
index f4717e4050..800bdf464f 100755
--- a/application/boottable/src/commands.c
+++ b/application/boottable/src/commands.c
@@ -401,7 +401,16 @@ int secure_create(int argc, char **argv) {
if((fd = open("/tmp/secure_image", O_RDWR | O_CREAT | O_TRUNC)) != -1){
/* Receive file */
- img.size = ftp_secure_main(argv[2], argv[3], argv[4], fd, md5);
+ if (argc == 5)
+ img.size = ftp_secure_main(argv[2], argv[3], argv[4], fd, md5, NULL, NULL, 0);
+ else if (argc == 8)
+ {
+ unsigned int port = 0;
+ sscanf(argv[7], "%u", &port);
+ img.size = ftp_secure_main(argv[2], argv[3], argv[4], fd, md5, argv[5], argv[6], port);
+ }
+ else
+ bb_error_msg_and_die("Error: not enough arguments for bt secure\n");
/* Time measure */
t = time (NULL);
diff --git a/application/boottable/src/commands_linux.c b/application/boottable/src/commands_linux.c
index ea111e3866..83b0816318 100755
--- a/application/boottable/src/commands_linux.c
+++ b/application/boottable/src/commands_linux.c
@@ -600,6 +600,30 @@ int boottable_create(char* ftpIp, uint16_t ftpPort, char* login, char* passwd, c
return RC_UPG_ON_GOING;
}
+/* ftpPort is in host format */
+int boottable_secure_create(char* ftpIp, uint16_t ftpPort, char* login, char* passwd, char *remoteFile, char* md5_file)
+{
+ char temp_port[16];
+
+ sprintf(temp_port, "%u", ftpPort);
+ char* temp_table[8];
+ temp_table[0] = "Boottable library";
+ temp_table[1] = "active";
+ temp_table[2] = ftpIp;
+ temp_table[3] = remoteFile;
+ temp_table[4] = md5_file;
+ temp_table[5] = login;
+ temp_table[6] = passwd;
+ temp_table[7] = temp_port;
+
+ int return_value = secure_create(8, &ftpIp);
+
+ if (!return_value)
+ return RC_UPG_OK;
+ else
+ return return_value;
+}
+
int boottable_erase(char* softwarename)
{
int ret;
diff --git a/application/boottable/src/ftp.c b/application/boottable/src/ftp.c
index c54a5bc8dd..7427adc75a 100644
--- a/application/boottable/src/ftp.c
+++ b/application/boottable/src/ftp.c
@@ -265,7 +265,7 @@ int ftp_secure_main(const char *serverip,
const char* file,
const char *md5,
int fd,
- unsigned char *md) {
+ unsigned char *md, char* login, char* password, unsigned int port) {
/* Socket to ftp server */
FILE *control_stream;
@@ -275,8 +275,14 @@ int ftp_secure_main(const char *serverip,
ftp_host_info_t server;
/* Set default values */
- server.user = "spidcom";
- server.password = "spidcom";
+ if (login == NULL)
+ server.user = "spidcom";
+ else
+ server.user = login;
+ if (password == NULL)
+ server.password = "spidcom";
+ else
+ server.user = password;
verbose_flag = 0;
/* We want to do exactly _one_ DNS lookup, since some
@@ -284,7 +290,10 @@ int ftp_secure_main(const char *serverip,
* and we want to connect to only one IP... */
server.s_in = &s_in;
bb_lookup_host(&s_in, serverip);
- s_in.sin_port = htons(FTP_PORT);
+ if (port == 0)
+ s_in.sin_port = htons(FTP_PORT);
+ else
+ s_in.sin_port = htons(port);
/* Connect/Setup/Configure the FTP session */
if(!(control_stream = ftp_login(&server)))