atftp:
[openwrt/svn-archive/archive.git] / net / atftp / patches / 110-services.patch
1 Index: atftp-0.7/tftp.c
2 ===================================================================
3 --- atftp-0.7.orig/tftp.c 2007-08-02 23:04:23.000000000 +0200
4 +++ atftp-0.7/tftp.c 2007-08-02 23:04:23.000000000 +0200
5 @@ -409,7 +409,7 @@
6 int set_peer(int argc, char **argv)
7 {
8 struct hostent *host; /* for host name lookup */
9 - struct servent *sp; /* server entry for tftp service */
10 + int port = htons(69);
11
12 /* sanity check */
13 if ((argc < 2) || (argc > 3))
14 @@ -418,13 +418,6 @@
15 return ERR;
16 }
17
18 - /* get the server entry */
19 - sp = getservbyname("tftp", "udp");
20 - if (sp == 0) {
21 - fprintf(stderr, "tftp: udp/tftp, unknown service.\n");
22 - return ERR;
23 - }
24 -
25 /* look up the host */
26 host = gethostbyname(argv[1]);
27 /* if valid, update s_inn structure */
28 @@ -437,7 +430,7 @@
29 Strncpy(data.hostname, host->h_name,
30 sizeof(data.hostname));
31 data.hostname[sizeof(data.hostname)-1] = 0;
32 - data.sa_peer.sin_port = sp->s_port;
33 + data.sa_peer.sin_port = port;
34 }
35 else
36 {
37 @@ -448,17 +441,17 @@
38 /* get the server port */
39 if (argc == 3)
40 {
41 - sp->s_port = htons(atoi(argv[2]));
42 - if (sp->s_port < 0)
43 + port = htons(atoi(argv[2]));
44 + if (port < 0)
45 {
46 fprintf(stderr, "%s: bad port number.\n", argv[2]);
47 data.connected = 0;
48 return ERR;
49 }
50 - data.sa_peer.sin_port = sp->s_port;
51 + data.sa_peer.sin_port = port;
52 }
53 /* copy port number to data structure */
54 - data.port = ntohs(sp->s_port);
55 + data.port = ntohs(port);
56
57 data.connected = 1;
58 return OK;
59 Index: atftp-0.7/tftpd.c
60 ===================================================================
61 --- atftp-0.7.orig/tftpd.c 2007-08-02 23:04:23.000000000 +0200
62 +++ atftp-0.7/tftpd.c 2007-08-02 23:04:23.000000000 +0200
63 @@ -230,14 +230,8 @@
64
65 /* find the port */
66 if (tftpd_port == 0)
67 - {
68 - if ((serv = getservbyname("tftp", "udp")) == NULL)
69 - {
70 - logger(LOG_ERR, "atftpd: udp/tftp, unknown service");
71 - exit(1);
72 - }
73 - tftpd_port = ntohs(serv->s_port);
74 - }
75 + tftpd_port = htons(69);
76 +
77 /* initialise sockaddr_in structure */
78 memset(&sa, 0, sizeof(sa));
79 sa.sin_family = AF_INET;