diff options
author | H. Peter Anvin <hpa@zytor.com> | 2010-06-21 22:57:35 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2010-06-21 22:57:35 -0700 |
commit | a4f0785b84f3d8fc047c4eb29d139d0d1c7b9704 (patch) | |
tree | 7a1bd571446e06f02428aacfaf9685bd0fc309eb | |
parent | c739718ba5f15b2686a1f4288fdb9ceee36956b6 (diff) | |
download | syslinux-a4f0785b84f3d8fc047c4eb29d139d0d1c7b9704.tar.gz |
sysdump: make TFTP server optional
Make entering the TFTP server optional (defaults to boot server).
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | 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 8c92d4d6..36a91eb8 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, }; |