[syslinux:master] sysdump: make TFTP server optional

syslinux-bot for H. Peter Anvin hpa at zytor.com
Mon Jun 21 23:03:02 PDT 2010


Commit-ID:  a4f0785b84f3d8fc047c4eb29d139d0d1c7b9704
Gitweb:     http://syslinux.zytor.com/commit/a4f0785b84f3d8fc047c4eb29d139d0d1c7b9704
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Mon, 21 Jun 2010 22:57:35 -0700
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Mon, 21 Jun 2010 22:57:35 -0700

sysdump: make TFTP server optional

Make entering the TFTP server optional (defaults to boot server).

Signed-off-by: H. Peter Anvin <hpa at zytor.com>


---
 com32/sysdump/be_tftp.c |   26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/com32/sysdump/be_tftp.c b/com32/sysdump/be_tftp.c
index 8c92d4d..36a91eb 100644
--- a/com32/sysdump/be_tftp.c
+++ b/com32/sysdump/be_tftp.c
@@ -3,6 +3,7 @@
  */
 
 #include <string.h>
+#include <stdio.h>
 #include <syslinux/pxe.h>
 #include <syslinux/config.h>
 #include <netinet/in.h>
@@ -120,12 +121,31 @@ static int be_tftp_write(struct backend *be)
 
     tftp.my_ip    = sdi->pxe.myip;
     tftp.my_port  = htons(local_port++);
-    tftp.srv_ip   = pxe_dns(be->argv[1]);
     tftp.srv_gw   = ((tftp.srv_ip ^ tftp.my_ip) & sdi->pxe.ipinfo->netmask)
 	? sdi->pxe.ipinfo->gateway : 0;
     tftp.srv_port = 0;
     tftp.seq      = 0;
 
+    if (be->argv[1]) {
+	tftp.srv_ip   = pxe_dns(be->argv[1]);
+	if (!tftp.srv_ip) {
+	    printf("\nUnable to resolve hostname: %s\n", be->argv[1]);
+	    return -1;
+	}
+    } else {
+	tftp.srv_ip   = sdi->pxe.ipinfo->serverip;
+	if (!tftp.srv_ip) {
+	    printf("\nNo server IP address\n");
+	    return -1;
+	}
+    }
+
+    printf("server %u.%u.%u.%u... ",
+	   ((uint8_t *)&tftp.srv_ip)[0],
+	   ((uint8_t *)&tftp.srv_ip)[1],
+	   ((uint8_t *)&tftp.srv_ip)[2],
+	   ((uint8_t *)&tftp.srv_ip)[3]);
+
     buffer[0] = 0;
     buffer[1] = TFTP_WRQ;
     nlen = strlcpy(buffer+2, be->argv[0], 512);
@@ -152,7 +172,7 @@ static int be_tftp_write(struct backend *be)
 
 struct backend be_tftp = {
     .name       = "tftp",
-    .helpmsg    = "filename tftp_server",
-    .minargs    = 2,
+    .helpmsg    = "filename [tftp_server]",
+    .minargs    = 1,
     .write      = be_tftp_write,
 };



More information about the Syslinux-commits mailing list