]> git.sur5r.net Git - openocd/commitdiff
zy1000: add : port number syntax for tftp filing system
authorØyvind Harboe <oyvind.harboe@zylin.com>
Sun, 5 Sep 2010 19:20:15 +0000 (21:20 +0200)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Fri, 1 Oct 2010 12:18:15 +0000 (14:18 +0200)
Allows using non-standard port number. Default to port 69.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
src/ecosboard.c

index f6e040fac3a26961059a5fca828c9db9cadd0134..26313b423a31db793ecd50c9f63d41c5a35dbe20 100644 (file)
@@ -1277,6 +1277,7 @@ struct Tftp
        cyg_uint8 *mem;
        int actual;
        char *server;
+       int port;
        char *file;
 };
 
@@ -1333,6 +1334,15 @@ static int tftpfs_open(cyg_mtab_entry *mte, cyg_dir dir, const char *name,
        strncpy(tftp->server, name, server - name);
        tftp->server[server - name] = 0;
 
+       tftp->port = 0; /* default port 69 */
+       char *port;
+       port = strchr(tftp->server, ':');
+       if (port != NULL)
+       {
+               tftp->port = atoi(port + 1);
+               *port = 0;
+       }
+
        tftp->file = strdup(server + 1);
        if (tftp->file == NULL)
        {
@@ -1350,7 +1360,7 @@ static int fetchTftp(struct Tftp *tftp)
        if (!tftp->readFile)
        {
                int err;
-               tftp->actual = tftp_client_get(tftp->file, tftp->server, 0, tftp->mem,
+               tftp->actual = tftp_client_get(tftp->file, tftp->server, tftp->port, tftp->mem,
                                tftpMaxSize, TFTP_OCTET, &err);
 
                if (tftp->actual < 0)