Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Protocol structure can now specify the default port.
  • Loading branch information
Michael Brown committed May 1, 2005
1 parent 63482e4 commit f14af3d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/include/proto.h
Expand Up @@ -2,9 +2,11 @@
#define PROTO_H

#include "tables.h"
#include "in.h"

struct protocol {
char *name;
in_port_t default_port;
int ( * load ) ( char *url,
struct sockaddr_in *server,
char *file,
Expand Down
7 changes: 3 additions & 4 deletions src/proto/nfs.c
Expand Up @@ -103,9 +103,6 @@ static int rpc_lookup(struct sockaddr_in *addr, int prog, int ver, int sport)
*p++ = htonl(ver);
*p++ = htonl(IP_UDP);
*p++ = 0;
if ( ! addr->sin_port ) {
addr->sin_port = SUNRPC_PORT;
}
for (retries = 0; retries < MAX_RPC_RETRIES; retries++) {
long timeout;
udp_transmit(addr->sin_addr.s_addr, sport, addr->sin_port,
Expand Down Expand Up @@ -623,5 +620,7 @@ static int nfs ( char *url __unused,
INIT_FN ( INIT_RPC, rpc_init, nfs_reset, nfs_reset );

static struct protocol nfs_protocol __protocol = {
"nfs", nfs
.name = "nfs",
.default_port = SUNRPC_PORT,
.load = nfs,
};
6 changes: 3 additions & 3 deletions src/proto/slam.c
Expand Up @@ -516,8 +516,6 @@ static int url_slam ( char *url __unused,
struct slam_info info;
/* Set the defaults */
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_port = SLAM_MULTICAST_PORT;
info.local.sin_addr.s_addr = arptable[ARP_CLIENT].ipaddr.s_addr;
Expand All @@ -532,5 +530,7 @@ static int url_slam ( char *url __unused,
}

static struct protocol slam_protocol __protocol = {
"x-slam", url_slam
.name = "x-slam",
.default_port = SLAM_PORT,
.load = url_slam,
};
6 changes: 3 additions & 3 deletions src/proto/tftm.c
Expand Up @@ -391,8 +391,6 @@ static int url_tftm ( char *url __unused,

/* Set the defaults */
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_port = TFTM_PORT; /* Does not matter. */
info.multicast = info.local;
Expand Down Expand Up @@ -482,5 +480,7 @@ static int opt_get_multicast(struct tftp_t *tr, unsigned short *len,
}

static struct protocol tftm_protocol __protocol = {
"x-tftm", url_tftm
.name = "x-tftm",
.default_port = TFTM_PORT,
.load = url_tftm,
};
6 changes: 3 additions & 3 deletions src/proto/tftp.c
Expand Up @@ -50,8 +50,6 @@ int tftp_block ( struct tftpreq_info_t *request,
blksize = TFTP_DEFAULTSIZE_PACKET;
lport++; /* Use new local port */
server = *(request->server);
if ( ! server.sin_port )
server.sin_port = TFTP_PORT;
if ( !udp_transmit(server.sin_addr.s_addr, lport,
server.sin_port, xmitlen, &xmit) )
return (0);
Expand Down Expand Up @@ -170,5 +168,7 @@ int tftp ( char *url __unused,
}

struct protocol tftp_protocol __default_protocol = {
"tftp", tftp
.name = "tftp",
.default_port = TFTP_PORT,
.load = tftp,
};

0 comments on commit f14af3d

Please sign in to comment.