Browse Source

Protocol structure can now specify the default port.

tags/v0.9.3
Michael Brown 20 years ago
parent
commit
f14af3d95c
5 changed files with 14 additions and 13 deletions
  1. 2
    0
      src/include/proto.h
  2. 3
    4
      src/proto/nfs.c
  3. 3
    3
      src/proto/slam.c
  4. 3
    3
      src/proto/tftm.c
  5. 3
    3
      src/proto/tftp.c

+ 2
- 0
src/include/proto.h View File

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

+ 3
- 4
src/proto/nfs.c View File

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

+ 3
- 3
src/proto/slam.c View File

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

+ 3
- 3
src/proto/tftm.c View File

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

+ 3
- 3
src/proto/tftp.c View File

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

Loading…
Cancel
Save