aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiu Aleaxander <Aleaxander@gmail.com>2009-08-05 17:17:46 +0800
committerLiu Aleaxander <Aleaxander@gmail.com>2009-08-05 17:17:46 +0800
commit6b4f3fc3da75f94997673893dfeac254e3044056 (patch)
treee983c5c38a4a40b0f523c0353a8f593e4c278773
parent3509c0d4854f811ed3aa67f24b39870d1da76630 (diff)
downloadpxelinux-6b4f3fc3da75f94997673893dfeac254e3044056.tar.gz
pxelinux-6b4f3fc3da75f94997673893dfeac254e3044056.tar.xz
pxelinux-6b4f3fc3da75f94997673893dfeac254e3044056.zip
Core:PXELINUX: code clean -- 2
-rw-r--r--core/pxe.c65
1 files changed, 25 insertions, 40 deletions
diff --git a/core/pxe.c b/core/pxe.c
index d16d783c..8af03c3a 100644
--- a/core/pxe.c
+++ b/core/pxe.c
@@ -298,28 +298,26 @@ char *parse_dotquad(char *ip_str, uint32_t *res)
/*********************************************************************
;
-; is_url: Return CF=0 if and only if the buffer pointed to by
-; DS:SI is a URL (contains ://). No registers modified.
+; is_url: Return 1 if and only if the buffer pointed to by
+; url is a URL (contains ://). No registers modified.
;
*********************************************************************/
#if GPXE
-void is_url(com32sys_t *regs)
+int is_url(char *url)
{
- char *url = (char *)MK_PTR(regs->ds, regs->esi.w[0]);
while (*url) {
- if(! strncmp(url, "://", 3)) {
- regs->eflags.l &= ~EFLAGS_CF;
- return;
- }
+ if(! strncmp(url, "://", 3))
+ return 1;
+
url++;
}
- regs->eflags.l |= EFLAGS_CF;
+ return 0;
}
#else
-void is_url(com32sys_t *regs)
+int is_url(char *url)
{
- regs->eflags.l |= EFLAGS_CF;
+ return 0;
}
#endif /* GPXE */
@@ -348,11 +346,8 @@ void mangle_name(com32sys_t *regs)
int i = 0;
#if GPXE
- is_url(regs);
- if ((regs->eflags.l & EFLAGS_CF) == 0) {
- ip |= -1;
+ if (is_url(MK_PTR(regs->ds, regs->esi.w[0])))
goto prefix_done;
- }
#endif
ip = ServerIP;
@@ -713,7 +708,6 @@ void pxe_load_config(com32sys_t *regs)
/* Nope, try hexadecimal IP prefixes... */
uchexbytes(config_file, (uint8_t *)&MyIP, 4); /* Convet to hex string */
- //
last = &config_file[8];
while (tries) {
*last = '\0'; /* Zero-terminate string */
@@ -730,7 +724,7 @@ void pxe_load_config(com32sys_t *regs)
if (try_load(regs))
return;
- //call16(no_config, NULL, NULL);
+ /* call16(no_config, NULL, NULL); */
}
@@ -744,7 +738,7 @@ void pxe_load_config(com32sys_t *regs)
; ZF set
;
******************************************************************/
-void allocate_socket(com32sys_t *regs)
+struct open_file_t* allocate_socket()
{
extern uint16_t NextSocket;
uint16_t i = MAX_OPEN;
@@ -757,10 +751,8 @@ void allocate_socket(com32sys_t *regs)
}
/* Not found */
- if (i == 0) {
- regs->eflags.l |= EFLAGS_ZF;
- return;
- }
+ if (i == 0)
+ return NULL;
/*
* Allocate a socket number. Socket numbers are made guaranteed unique
@@ -779,19 +771,16 @@ void allocate_socket(com32sys_t *regs)
i = ntohs(i) ; /* convet to network byte order, little to big */
*(uint16_t*)socket = i; /* socket in use */
- regs->ebx.w[0] = OFFS_WRT(socket, 0);
- regs->eflags.l &= ~EFLAGS_ZF;
+ return socket;
}
/*
* free socket, socket in SI; return SI = 0, ZF = 1 for convenience
*/
-void free_socket(com32sys_t *regs)
+void free_socket(struct open_file_t *file)
{
/* tftp_pktbuf is not cleared */
- memset((void *)(int)(regs->esi.w[0]), 0, sizeof(struct open_file_t) - 2);
- regs->esi.w[0] = 0;
- regs->eflags.l |= EFLAGS_ZF;
+ memset(file, 0, sizeof(struct open_file_t) - 2);
}
@@ -1249,11 +1238,7 @@ int is_gpxe(char *url)
struct gpxe_file_api_check *ac = (struct gpxe_file_api_check *)gpxe_file_api_check;
char *gpxe_warning_msg = "URL syntax, but gPXE extensions not detected, tring plain TFTP...\n";
- com32sys_t regs;
- memset(&regs, 0, sizeof regs);
- regs.esi.w[0] = OFFS_WRT(url, 0);
- is_url(&regs);
- if (regs.eflags.l & EFLAGS_CF)
+ if (! is_url(url))
return 0;
/* If has_gpxe is greater than one, means the gpxe status is unknow */
@@ -1493,7 +1478,8 @@ void getfssec(com32sys_t *regs)
* The socket is closed and the buffer dranined
* close socket structure and re-init for next user
*/
- free_socket(regs);
+ free_socket(file);
+ regs->esi.w[0] = 0;
regs->eflags.l |= EFLAGS_CF; /* Hit EOF */
return;
}
@@ -1794,8 +1780,7 @@ void searchdir_c(com32sys_t *regs)
uint32_t *data_ptr;
init_options();
- allocate_socket(regs);
- file = MK_PTR(0, regs->ebx.w[0]);
+ file = allocate_socket();
if (!file) {
regs->eflags.l |= EFLAGS_ZF;
return;
@@ -1828,8 +1813,8 @@ void searchdir_c(com32sys_t *regs)
fo->filename[1] = regs->ds;
err = pxe_call(PXENV_FILE_OPEN, fo);
if (err) {
- regs->esi.w[0] = OFFS_WRT(file, 0);
- free_socket(regs);
+ free_socket(file);
+ regs->esi.w[0] = 0;
regs->eflags.l |= EFLAGS_ZF;
return;
}
@@ -2031,8 +2016,8 @@ void searchdir_c(com32sys_t *regs)
regs->eflags.l &= ~EFLAGS_ZF;
if (!file->tftp_filesize) {
error:
- regs->esi.w[0] = OFFS_WRT(file, 0);
- free_socket(regs);
+ free_socket(file);
+ regs->esi.w[0] = 0;
regs->eflags.l |= EFLAGS_ZF;
}
return;