[syslinux:lwip] pxe: continue to bounce URLs with unknown schemes to gPXE

syslinux-bot for H. Peter Anvin hpa at zytor.com
Sun Apr 24 21:03:24 PDT 2011


Commit-ID:  9c136a34a30708efa50545cb8859e937964bed2f
Gitweb:     http://syslinux.zytor.com/commit/9c136a34a30708efa50545cb8859e937964bed2f
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Sun, 24 Apr 2011 14:42:56 -0700
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Sun, 24 Apr 2011 14:42:56 -0700

pxe: continue to bounce URLs with unknown schemes to gPXE

If we're running on top of a gPXE/iPXE stack, and get a URL we don't
know, continue to bounce it to gPXE.  It isn't entirely clear how well
this will actually work with an UNDI-based network stack, however...

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


---
 core/fs/pxe/gpxeurl.c |    2 --
 core/fs/pxe/pxe.c     |   22 +++++++++++++++++++++-
 core/fs/pxe/tftp.c    |    3 ---
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/core/fs/pxe/gpxeurl.c b/core/fs/pxe/gpxeurl.c
index 6f456bb..6bbae3c 100644
--- a/core/fs/pxe/gpxeurl.c
+++ b/core/fs/pxe/gpxeurl.c
@@ -8,8 +8,6 @@ static void gpxe_close_file(struct inode *inode)
 
     file_close.FileHandle = socket->tftp_remoteport;
     pxe_call(PXENV_FILE_CLOSE, &file_close);
-
-    free(socket->tftp_pktbuf);
 }
 
 /**
diff --git a/core/fs/pxe/pxe.c b/core/fs/pxe/pxe.c
index 5789bb6..939ce71 100644
--- a/core/fs/pxe/pxe.c
+++ b/core/fs/pxe/pxe.c
@@ -68,6 +68,7 @@ void free_socket(struct inode *inode)
 {
     struct pxe_pvt_inode *socket = PVT(inode);
 
+    free(socket->tftp_pktbuf);	/* If we allocated a buffer, free it now */
     free_port(socket->tftp_localport);
     free_inode(inode);
 }
@@ -380,9 +381,13 @@ static void __pxe_searchdir(const char *filename, struct file *file)
     struct fs_info *fs = file->fs;
     struct inode *inode;
     char fullpath[2*FILENAME_MAX];
+#ifdef GPXE
+    char urlsave[2*FILENAME_MAX];
+#endif
     struct url_info url;
-    const struct url_scheme *us;
+    const struct url_scheme *us = NULL;
     int redirect_count = 0;
+    bool found_scheme = false;
 
     inode = file->inode = NULL;
 
@@ -391,9 +396,15 @@ static void __pxe_searchdir(const char *filename, struct file *file)
 	    break;
 
 	strlcpy(fullpath, filename, sizeof fullpath);
+#ifdef GPXE
+	strcpy(urlsave, fullpath);
+#endif
 	parse_url(&url, fullpath);
 	if (url.type == URL_SUFFIX) {
 	    snprintf(fullpath, sizeof fullpath, "%s%s", fs->cwd_name, filename);
+#ifdef GPXE
+	    strcpy(urlsave, fullpath);
+#endif
 	    parse_url(&url, fullpath);
 	}
 
@@ -404,9 +415,11 @@ static void __pxe_searchdir(const char *filename, struct file *file)
 	url_set_ip(&url);
 	
 	filename = NULL;
+	found_scheme = false;
 	for (us = url_schemes; us->name; us++) {
 	    if (!strcmp(us->name, url.scheme)) {
 		us->open(&url, inode, &filename);
+		found_scheme = true;
 		break;
 	    }
 	}
@@ -414,6 +427,13 @@ static void __pxe_searchdir(const char *filename, struct file *file)
 	/* filename here is set on a redirect */
     }
 
+#ifdef GPXE
+    if (!found_scheme) {
+	/* No URL scheme found, hand it to GPXE */
+	gpxe_open(inode, urlsave);
+    }
+#endif
+
     if (inode->size)
 	file->inode = inode;
     else
diff --git a/core/fs/pxe/tftp.c b/core/fs/pxe/tftp.c
index 637f0e9..77efe49 100644
--- a/core/fs/pxe/tftp.c
+++ b/core/fs/pxe/tftp.c
@@ -37,7 +37,6 @@ static void tftp_close_file(struct inode *inode)
 	netconn_delete(socket->conn);
 	socket->conn = NULL;
     }
-    free(socket->tftp_pktbuf);
 }
 
 /**
@@ -461,10 +460,8 @@ err_reply:
 
 done:
     if (!inode->size) {
-	free(socket->tftp_pktbuf);
 	netconn_delete(socket->conn);
 	socket->conn = NULL;
     }
     return;
-
 }



More information about the Syslinux-commits mailing list