david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

Protocol structure can now specify the default port.

This commit is contained in:
Michael Brown 2005-05-01 23:57:09 +00:00
parent 63482e4fe9
commit f14af3d95c
5 changed files with 14 additions and 13 deletions

View File

@ -2,9 +2,11 @@
#define PROTO_H #define PROTO_H
#include "tables.h" #include "tables.h"
#include "in.h"
struct protocol { struct protocol {
char *name; char *name;
in_port_t default_port;
int ( * load ) ( char *url, int ( * load ) ( char *url,
struct sockaddr_in *server, struct sockaddr_in *server,
char *file, char *file,

View File

@ -103,9 +103,6 @@ static int rpc_lookup(struct sockaddr_in *addr, int prog, int ver, int sport)
*p++ = htonl(ver); *p++ = htonl(ver);
*p++ = htonl(IP_UDP); *p++ = htonl(IP_UDP);
*p++ = 0; *p++ = 0;
if ( ! addr->sin_port ) {
addr->sin_port = SUNRPC_PORT;
}
for (retries = 0; retries < MAX_RPC_RETRIES; retries++) { for (retries = 0; retries < MAX_RPC_RETRIES; retries++) {
long timeout; long timeout;
udp_transmit(addr->sin_addr.s_addr, sport, addr->sin_port, udp_transmit(addr->sin_addr.s_addr, sport, addr->sin_port,
@ -623,5 +620,7 @@ nfssymlink:
INIT_FN ( INIT_RPC, rpc_init, nfs_reset, nfs_reset ); INIT_FN ( INIT_RPC, rpc_init, nfs_reset, nfs_reset );
static struct protocol nfs_protocol __protocol = { static struct protocol nfs_protocol __protocol = {
"nfs", nfs .name = "nfs",
.default_port = SUNRPC_PORT,
.load = nfs,
}; };

View File

@ -516,8 +516,6 @@ static int url_slam ( char *url __unused,
struct slam_info info; struct slam_info info;
/* Set the defaults */ /* Set the defaults */
info.server = *server; info.server = *server;
if ( ! info.server.sin_port )
info.server.sin_port = SLAM_PORT;
info.multicast.sin_addr.s_addr = htonl(SLAM_MULTICAST_IP); info.multicast.sin_addr.s_addr = htonl(SLAM_MULTICAST_IP);
info.multicast.sin_port = SLAM_MULTICAST_PORT; info.multicast.sin_port = SLAM_MULTICAST_PORT;
info.local.sin_addr.s_addr = arptable[ARP_CLIENT].ipaddr.s_addr; info.local.sin_addr.s_addr = arptable[ARP_CLIENT].ipaddr.s_addr;
@ -532,5 +530,7 @@ static int url_slam ( char *url __unused,
} }
static struct protocol slam_protocol __protocol = { static struct protocol slam_protocol __protocol = {
"x-slam", url_slam .name = "x-slam",
.default_port = SLAM_PORT,
.load = url_slam,
}; };

View File

@ -391,8 +391,6 @@ static int url_tftm ( char *url __unused,
/* Set the defaults */ /* Set the defaults */
info.server = *server; info.server = *server;
if ( ! info.server.sin_port )
info.server.sin_port = TFTM_PORT;
info.local.sin_addr.s_addr = arptable[ARP_CLIENT].ipaddr.s_addr; info.local.sin_addr.s_addr = arptable[ARP_CLIENT].ipaddr.s_addr;
info.local.sin_port = TFTM_PORT; /* Does not matter. */ info.local.sin_port = TFTM_PORT; /* Does not matter. */
info.multicast = info.local; info.multicast = info.local;
@ -482,5 +480,7 @@ static int opt_get_multicast(struct tftp_t *tr, unsigned short *len,
} }
static struct protocol tftm_protocol __protocol = { static struct protocol tftm_protocol __protocol = {
"x-tftm", url_tftm .name = "x-tftm",
.default_port = TFTM_PORT,
.load = url_tftm,
}; };

View File

@ -50,8 +50,6 @@ int tftp_block ( struct tftpreq_info_t *request,
blksize = TFTP_DEFAULTSIZE_PACKET; blksize = TFTP_DEFAULTSIZE_PACKET;
lport++; /* Use new local port */ lport++; /* Use new local port */
server = *(request->server); server = *(request->server);
if ( ! server.sin_port )
server.sin_port = TFTP_PORT;
if ( !udp_transmit(server.sin_addr.s_addr, lport, if ( !udp_transmit(server.sin_addr.s_addr, lport,
server.sin_port, xmitlen, &xmit) ) server.sin_port, xmitlen, &xmit) )
return (0); return (0);
@ -170,5 +168,7 @@ int tftp ( char *url __unused,
} }
struct protocol tftp_protocol __default_protocol = { struct protocol tftp_protocol __default_protocol = {
"tftp", tftp .name = "tftp",
.default_port = TFTP_PORT,
.load = tftp,
}; };