瀏覽代碼

Protocol structure can now specify the default port.

tags/v0.9.3
Michael Brown 20 年之前
父節點
當前提交
f14af3d95c
共有 5 個文件被更改,包括 14 次插入13 次删除
  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 查看文件

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

+ 3
- 4
src/proto/nfs.c 查看文件

103
 	*p++ = htonl(ver);
103
 	*p++ = htonl(ver);
104
 	*p++ = htonl(IP_UDP);
104
 	*p++ = htonl(IP_UDP);
105
 	*p++ = 0;
105
 	*p++ = 0;
106
-	if ( ! addr->sin_port ) {
107
-		addr->sin_port = SUNRPC_PORT;
108
-	}
109
 	for (retries = 0; retries < MAX_RPC_RETRIES; retries++) {
106
 	for (retries = 0; retries < MAX_RPC_RETRIES; retries++) {
110
 		long timeout;
107
 		long timeout;
111
 		udp_transmit(addr->sin_addr.s_addr, sport, addr->sin_port,
108
 		udp_transmit(addr->sin_addr.s_addr, sport, addr->sin_port,
623
 INIT_FN ( INIT_RPC, rpc_init, nfs_reset, nfs_reset );
620
 INIT_FN ( INIT_RPC, rpc_init, nfs_reset, nfs_reset );
624
 
621
 
625
 static struct protocol nfs_protocol __protocol = {
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 查看文件

516
 	struct slam_info info;
516
 	struct slam_info info;
517
 	/* Set the defaults */
517
 	/* Set the defaults */
518
 	info.server = *server;
518
 	info.server = *server;
519
-	if ( ! info.server.sin_port )
520
-		info.server.sin_port = SLAM_PORT;
521
 	info.multicast.sin_addr.s_addr = htonl(SLAM_MULTICAST_IP);
519
 	info.multicast.sin_addr.s_addr = htonl(SLAM_MULTICAST_IP);
522
 	info.multicast.sin_port      = SLAM_MULTICAST_PORT;
520
 	info.multicast.sin_port      = SLAM_MULTICAST_PORT;
523
 	info.local.sin_addr.s_addr   = arptable[ARP_CLIENT].ipaddr.s_addr;
521
 	info.local.sin_addr.s_addr   = arptable[ARP_CLIENT].ipaddr.s_addr;
532
 }
530
 }
533
 
531
 
534
 static struct protocol slam_protocol __protocol = {
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 查看文件

391
 
391
 
392
 	/* Set the defaults */
392
 	/* Set the defaults */
393
 	info.server = *server;
393
 	info.server = *server;
394
-	if ( ! info.server.sin_port )
395
-		info.server.sin_port = TFTM_PORT;
396
 	info.local.sin_addr.s_addr = arptable[ARP_CLIENT].ipaddr.s_addr;
394
 	info.local.sin_addr.s_addr = arptable[ARP_CLIENT].ipaddr.s_addr;
397
 	info.local.sin_port = TFTM_PORT; /* Does not matter. */
395
 	info.local.sin_port = TFTM_PORT; /* Does not matter. */
398
 	info.multicast = info.local;
396
 	info.multicast = info.local;
482
 }
480
 }
483
 
481
 
484
 static struct protocol tftm_protocol __protocol = {
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 查看文件

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

Loading…
取消
儲存