mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* PATCH added tftp port to fsoptions
@ 2018-08-03 11:07 Toews, Dietrich
  2018-08-03 11:34 ` Oleksij Rempel
  2018-08-08  8:15 ` Sascha Hauer
  0 siblings, 2 replies; 5+ messages in thread
From: Toews, Dietrich @ 2018-08-03 11:07 UTC (permalink / raw)
  To: barebox

Hi all,

we are using barebox for a while now, but we need different tftp-server with different ports.
Here a proposition for a patch, if someone else needs it also.

Usage: tftp -o port=1234 ....

Sincirely
Dietrich


From 062a4c8148c2d31c7ce1d405632051b297b64ce0 Mon Sep 17 00:00:00 2001
From: Dietrich Toews <dietrich.toews@heidelberg.com>
Date: Fri, 3 Aug 2018 12:55:53 +0200
Subject: [PATCH] Added tftp port to fsoptions

---
 fs/tftp.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/fs/tftp.c b/fs/tftp.c
index 847921a..13efa20 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -87,6 +87,7 @@ struct file_priv {

 struct tftp_priv {
        IPaddr_t server;
+       uint16_t port;
 };

 static int tftp_create(struct device_d *dev, const char *pathname, mode_t mode)
@@ -423,7 +424,7 @@ static struct file_priv *tftp_do_open(struct device_d *dev,
                goto out;
        }

-       priv->tftp_con = net_udp_new(tpriv->server, TFTP_PORT, tftp_handler,
+       priv->tftp_con = net_udp_new(tpriv->server, tpriv->port, tftp_handler,
                        priv);
        if (IS_ERR(priv->tftp_con)) {
                ret = PTR_ERR(priv->tftp_con);
@@ -651,7 +652,22 @@ static int tftp_probe(struct device_d *dev)
        dev->priv = priv;

        priv->server = resolv(fsdev->backingstore);
-
+       priv->port   = TFTP_PORT;
+       if( fsdev->options ) {
+               // ToDo: if needed check other options.
+               //       Assumption here: the only option used is 'port=nxxxx'
+               if( strncmp( fsdev->options, "port=", 5 ) == 0 ) {
+                       uint16_t p = 0;
+                       for( uint8_t i=5; i<10; i++ ) {
+                               // portnumber can only contain ascii chars 0..9
+                               if( (fsdev->options[i] >= 48) && (fsdev->options[i] < 58) )
+                                       p = (p * 10) + (fsdev->options[i] - 48);
+                               else
+                                       break;  // break on first char that is not a number
+                       }
+                       if( p > 0 ) priv->port = p;
+               }
+       }
        return 0;
 }

--
1.9.1


________________________________

Confidentiality note:
The information in this email and any attachment may contain confidential and proprietary information of Heidelberger Druckmaschinen AG and/or its affiliates and may be privileged or otherwise protected from disclosure. If you are not the intended recipient, you are hereby notified that any review, reliance or distribution by others or forwarding without express permission is strictly prohibited and may cause liability. In case you have received this message due to an error in transmission, we kindly ask you to notify the sender immediately and to delete this email and any attachment from your system.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH added tftp port to fsoptions
  2018-08-03 11:07 PATCH added tftp port to fsoptions Toews, Dietrich
@ 2018-08-03 11:34 ` Oleksij Rempel
  2018-08-03 12:10   ` Toews, Dietrich
  2018-08-08  8:15 ` Sascha Hauer
  1 sibling, 1 reply; 5+ messages in thread
From: Oleksij Rempel @ 2018-08-03 11:34 UTC (permalink / raw)
  To: Toews, Dietrich, barebox


[-- Attachment #1.1.1: Type: text/plain, Size: 3491 bytes --]

Hi,

Am 03.08.2018 um 13:07 schrieb Toews, Dietrich:
> Hi all,
> 
> we are using barebox for a while now, but we need different tftp-server with different ports.
> Here a proposition for a patch, if someone else needs it also.
> 
> Usage: tftp -o port=1234 ....

Good point. I assume, barebox way, would be to make it:
global.net.tftp_port
nv.net.tftp_port
nv.dev.<devname>.tftp_port

> Sincirely
> Dietrich
> 
> 
> From 062a4c8148c2d31c7ce1d405632051b297b64ce0 Mon Sep 17 00:00:00 2001
> From: Dietrich Toews <dietrich.toews@heidelberg.com>
> Date: Fri, 3 Aug 2018 12:55:53 +0200
> Subject: [PATCH] Added tftp port to fsoptions
> 
> ---
>  fs/tftp.c | 20 ++++++++++++++++++--
>  1 file changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/tftp.c b/fs/tftp.c
> index 847921a..13efa20 100644
> --- a/fs/tftp.c
> +++ b/fs/tftp.c
> @@ -87,6 +87,7 @@ struct file_priv {
> 
>  struct tftp_priv {
>         IPaddr_t server;
> +       uint16_t port;
>  };
> 
>  static int tftp_create(struct device_d *dev, const char *pathname, mode_t mode)
> @@ -423,7 +424,7 @@ static struct file_priv *tftp_do_open(struct device_d *dev,
>                 goto out;
>         }
> 
> -       priv->tftp_con = net_udp_new(tpriv->server, TFTP_PORT, tftp_handler,
> +       priv->tftp_con = net_udp_new(tpriv->server, tpriv->port, tftp_handler,
>                         priv);
>         if (IS_ERR(priv->tftp_con)) {
>                 ret = PTR_ERR(priv->tftp_con);
> @@ -651,7 +652,22 @@ static int tftp_probe(struct device_d *dev)
>         dev->priv = priv;
> 
>         priv->server = resolv(fsdev->backingstore);
> -
> +       priv->port   = TFTP_PORT;
> +       if( fsdev->options ) {
> +               // ToDo: if needed check other options.
> +               //       Assumption here: the only option used is 'port=nxxxx'
> +               if( strncmp( fsdev->options, "port=", 5 ) == 0 ) {
> +                       uint16_t p = 0;
> +                       for( uint8_t i=5; i<10; i++ ) {
> +                               // portnumber can only contain ascii chars 0..9
> +                               if( (fsdev->options[i] >= 48) && (fsdev->options[i] < 58) )
> +                                       p = (p * 10) + (fsdev->options[i] - 48);
> +                               else
> +                                       break;  // break on first char that is not a number
> +                       }
> +                       if( p > 0 ) priv->port = p;
> +               }
> +       }
>         return 0;
>  }
> 
> --
> 1.9.1
> 
> 
> ________________________________
> 
> Confidentiality note:
> The information in this email and any attachment may contain confidential and proprietary information of Heidelberger Druckmaschinen AG and/or its affiliates and may be privileged or otherwise protected from disclosure. If you are not the intended recipient, you are hereby notified that any review, reliance or distribution by others or forwarding without express permission is strictly prohibited and may cause liability. In case you have received this message due to an error in transmission, we kindly ask you to notify the sender immediately and to delete this email and any attachment from your system.
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 


-- 
Regards,
Oleksij


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: PATCH added tftp port to fsoptions
  2018-08-03 11:34 ` Oleksij Rempel
@ 2018-08-03 12:10   ` Toews, Dietrich
  2018-08-06 18:40     ` Uwe Kleine-König
  0 siblings, 1 reply; 5+ messages in thread
From: Toews, Dietrich @ 2018-08-03 12:10 UTC (permalink / raw)
  To: barebox

Hi,

that can be a way, but then it is not possible to connect to different servers, when they have different ports.
e.g. one server for large files, one (intelligent) server for script-files

Why different ports? - For testing it is very nice to have all the servers on one machine.

Dietrich

-----Original Message-----
Hi,

Am 03.08.2018 um 13:07 schrieb Toews, Dietrich:
> Hi all,
>
> we are using barebox for a while now, but we need different tftp-server with different ports.
> Here a proposition for a patch, if someone else needs it also.
>
> Usage: tftp -o port=1234 ....

Good point. I assume, barebox way, would be to make it:
global.net.tftp_port
nv.net.tftp_port
nv.dev.<devname>.tftp_port

> Sincirely
> Dietrich
>
>
> From 062a4c8148c2d31c7ce1d405632051b297b64ce0 Mon Sep 17 00:00:00 2001
> From: Dietrich Toews <dietrich.toews@heidelberg.com>
> Date: Fri, 3 Aug 2018 12:55:53 +0200
> Subject: [PATCH] Added tftp port to fsoptions
>
> ---
>  fs/tftp.c | 20 ++++++++++++++++++--
>  1 file changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/fs/tftp.c b/fs/tftp.c
> index 847921a..13efa20 100644
> --- a/fs/tftp.c
> +++ b/fs/tftp.c
> @@ -87,6 +87,7 @@ struct file_priv {
>
>  struct tftp_priv {
>         IPaddr_t server;
> +       uint16_t port;
>  };
>
>  static int tftp_create(struct device_d *dev, const char *pathname,
> mode_t mode) @@ -423,7 +424,7 @@ static struct file_priv *tftp_do_open(struct device_d *dev,
>                 goto out;
>         }
>
> -       priv->tftp_con = net_udp_new(tpriv->server, TFTP_PORT, tftp_handler,
> +       priv->tftp_con = net_udp_new(tpriv->server, tpriv->port,
> + tftp_handler,
>                         priv);
>         if (IS_ERR(priv->tftp_con)) {
>                 ret = PTR_ERR(priv->tftp_con); @@ -651,7 +652,22 @@
> static int tftp_probe(struct device_d *dev)
>         dev->priv = priv;
>
>         priv->server = resolv(fsdev->backingstore);
> -
> +       priv->port   = TFTP_PORT;
> +       if( fsdev->options ) {
> +               // ToDo: if needed check other options.
> +               //       Assumption here: the only option used is 'port=nxxxx'
> +               if( strncmp( fsdev->options, "port=", 5 ) == 0 ) {
> +                       uint16_t p = 0;
> +                       for( uint8_t i=5; i<10; i++ ) {
> +                               // portnumber can only contain ascii chars 0..9
> +                               if( (fsdev->options[i] >= 48) && (fsdev->options[i] < 58) )
> +                                       p = (p * 10) + (fsdev->options[i] - 48);
> +                               else
> +                                       break;  // break on first char that is not a number
> +                       }
> +                       if( p > 0 ) priv->port = p;
> +               }
> +       }
>         return 0;
>  }
>
> --
> 1.9.1
>
>
> ________________________________
>
> Confidentiality note:
> The information in this email and any attachment may contain confidential and proprietary information of Heidelberger Druckmaschinen AG and/or its affiliates and may be privileged or otherwise protected from disclosure. If you are not the intended recipient, you are hereby notified that any review, reliance or distribution by others or forwarding without express permission is strictly prohibited and may cause liability. In case you have received this message due to an error in transmission, we kindly ask you to notify the sender immediately and to delete this email and any attachment from your system.
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>


--
Regards,
Oleksij


________________________________

Confidentiality note:
The information in this email and any attachment may contain confidential and proprietary information of Heidelberger Druckmaschinen AG and/or its affiliates and may be privileged or otherwise protected from disclosure. If you are not the intended recipient, you are hereby notified that any review, reliance or distribution by others or forwarding without express permission is strictly prohibited and may cause liability. In case you have received this message due to an error in transmission, we kindly ask you to notify the sender immediately and to delete this email and any attachment from your system.
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH added tftp port to fsoptions
  2018-08-03 12:10   ` Toews, Dietrich
@ 2018-08-06 18:40     ` Uwe Kleine-König
  0 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2018-08-06 18:40 UTC (permalink / raw)
  To: Toews, Dietrich; +Cc: barebox

On Fri, Aug 03, 2018 at 12:10:34PM +0000, Toews, Dietrich wrote:
> Hi,
> 
> that can be a way, but then it is not possible to connect to different servers, when they have different ports.
> e.g. one server for large files, one (intelligent) server for script-files
> 
> Why different ports? - For testing it is very nice to have all the servers on one machine.
> 
> Dietrich
> 
> -----Original Message-----
> Hi,
> 
> Am 03.08.2018 um 13:07 schrieb Toews, Dietrich:
> > Hi all,
> >
> > we are using barebox for a while now, but we need different tftp-server with different ports.
> > Here a proposition for a patch, if someone else needs it also.
> >
> > Usage: tftp -o port=1234 ....
> 
> Good point. I assume, barebox way, would be to make it:
> global.net.tftp_port
> nv.net.tftp_port
> nv.dev.<devname>.tftp_port

I'd say

	nv.net.server.tftp_port=1234

and only use that for the default mount to /mnt/tftp and otherwise keep
it as a mount option.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH added tftp port to fsoptions
  2018-08-03 11:07 PATCH added tftp port to fsoptions Toews, Dietrich
  2018-08-03 11:34 ` Oleksij Rempel
@ 2018-08-08  8:15 ` Sascha Hauer
  1 sibling, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2018-08-08  8:15 UTC (permalink / raw)
  To: Toews, Dietrich; +Cc: barebox

On Fri, Aug 03, 2018 at 11:07:11AM +0000, Toews, Dietrich wrote:
> Hi all,
> 
> we are using barebox for a while now, but we need different tftp-server with different ports.
> Here a proposition for a patch, if someone else needs it also.
> 
> Usage: tftp -o port=1234 ....
> 
> Sincirely
> Dietrich
> 
> 
> From 062a4c8148c2d31c7ce1d405632051b297b64ce0 Mon Sep 17 00:00:00 2001
> From: Dietrich Toews <dietrich.toews@heidelberg.com>
> Date: Fri, 3 Aug 2018 12:55:53 +0200
> Subject: [PATCH] Added tftp port to fsoptions
> 
> ---
>  fs/tftp.c | 20 ++++++++++++++++++--
>  1 file changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/tftp.c b/fs/tftp.c
> index 847921a..13efa20 100644
> --- a/fs/tftp.c
> +++ b/fs/tftp.c
> @@ -87,6 +87,7 @@ struct file_priv {
> 
>  struct tftp_priv {
>         IPaddr_t server;
> +       uint16_t port;
>  };
> 
>  static int tftp_create(struct device_d *dev, const char *pathname, mode_t mode)
> @@ -423,7 +424,7 @@ static struct file_priv *tftp_do_open(struct device_d *dev,
>                 goto out;
>         }
> 
> -       priv->tftp_con = net_udp_new(tpriv->server, TFTP_PORT, tftp_handler,
> +       priv->tftp_con = net_udp_new(tpriv->server, tpriv->port, tftp_handler,
>                         priv);
>         if (IS_ERR(priv->tftp_con)) {
>                 ret = PTR_ERR(priv->tftp_con);
> @@ -651,7 +652,22 @@ static int tftp_probe(struct device_d *dev)
>         dev->priv = priv;
> 
>         priv->server = resolv(fsdev->backingstore);
> -
> +       priv->port   = TFTP_PORT;
> +       if( fsdev->options ) {
> +               // ToDo: if needed check other options.
> +               //       Assumption here: the only option used is 'port=nxxxx'
> +               if( strncmp( fsdev->options, "port=", 5 ) == 0 ) {
> +                       uint16_t p = 0;
> +                       for( uint8_t i=5; i<10; i++ ) {
> +                               // portnumber can only contain ascii chars 0..9
> +                               if( (fsdev->options[i] >= 48) && (fsdev->options[i] < 58) )
> +                                       p = (p * 10) + (fsdev->options[i] - 48);
> +                               else
> +                                       break;  // break on first char that is not a number
> +                       }
> +                       if( p > 0 ) priv->port = p;
> +               }
> +       }

Look at fs/nfs.c to see how it's implemented there. There is
parseopt_hu() which can be used to simplify this code.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-08-08  8:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-03 11:07 PATCH added tftp port to fsoptions Toews, Dietrich
2018-08-03 11:34 ` Oleksij Rempel
2018-08-03 12:10   ` Toews, Dietrich
2018-08-06 18:40     ` Uwe Kleine-König
2018-08-08  8:15 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox