@@ -61,8 +61,9 @@ void tftp_request(struct listener *listen, time_t now)
6161 char * prefix = daemon -> tftp_prefix ;
6262 struct tftp_prefix * pref ;
6363 union all_addr addra ;
64+ int family = listen -> addr .sa .sa_family ;
6465 /* Can always get recvd interface for IPv6 */
65- int check_dest = !option_bool (OPT_NOWILD ) || listen -> family == AF_INET6 ;
66+ int check_dest = !option_bool (OPT_NOWILD ) || family == AF_INET6 ;
6667 union {
6768 struct cmsghdr align ; /* this ensures alignment */
6869 char control6 [CMSG_SPACE (sizeof (struct in6_pktinfo ))];
@@ -121,10 +122,10 @@ void tftp_request(struct listener *listen, time_t now)
121122 if (msg .msg_controllen < sizeof (struct cmsghdr ))
122123 return ;
123124
124- addr .sa .sa_family = listen -> family ;
125+ addr .sa .sa_family = family ;
125126
126127#if defined(HAVE_LINUX_NETWORK )
127- if (listen -> family == AF_INET )
128+ if (family == AF_INET )
128129 for (cmptr = CMSG_FIRSTHDR (& msg ); cmptr ; cmptr = CMSG_NXTHDR (& msg , cmptr ))
129130 if (cmptr -> cmsg_level == IPPROTO_IP && cmptr -> cmsg_type == IP_PKTINFO )
130131 {
@@ -138,7 +139,7 @@ void tftp_request(struct listener *listen, time_t now)
138139 }
139140
140141#elif defined(HAVE_SOLARIS_NETWORK )
141- if (listen -> family == AF_INET )
142+ if (family == AF_INET )
142143 for (cmptr = CMSG_FIRSTHDR (& msg ); cmptr ; cmptr = CMSG_NXTHDR (& msg , cmptr ))
143144 {
144145 union {
@@ -154,7 +155,7 @@ void tftp_request(struct listener *listen, time_t now)
154155 }
155156
156157#elif defined(IP_RECVDSTADDR ) && defined(IP_RECVIF )
157- if (listen -> family == AF_INET )
158+ if (family == AF_INET )
158159 for (cmptr = CMSG_FIRSTHDR (& msg ); cmptr ; cmptr = CMSG_NXTHDR (& msg , cmptr ))
159160 {
160161 union {
@@ -171,7 +172,7 @@ void tftp_request(struct listener *listen, time_t now)
171172
172173#endif
173174
174- if (listen -> family == AF_INET6 )
175+ if (family == AF_INET6 )
175176 {
176177 for (cmptr = CMSG_FIRSTHDR (& msg ); cmptr ; cmptr = CMSG_NXTHDR (& msg , cmptr ))
177178 if (cmptr -> cmsg_level == IPPROTO_IPV6 && cmptr -> cmsg_type == daemon -> v6pktinfo )
@@ -194,7 +195,7 @@ void tftp_request(struct listener *listen, time_t now)
194195
195196 addra .addr4 = addr .in .sin_addr ;
196197
197- if (listen -> family == AF_INET6 )
198+ if (family == AF_INET6 )
198199 addra .addr6 = addr .in6 .sin6_addr ;
199200
200201 if (daemon -> tftp_interfaces )
@@ -210,12 +211,12 @@ void tftp_request(struct listener *listen, time_t now)
210211 else
211212 {
212213 /* Do the same as DHCP */
213- if (!iface_check (listen -> family , & addra , name , NULL ))
214+ if (!iface_check (family , & addra , name , NULL ))
214215 {
215216 if (!option_bool (OPT_CLEVERBIND ))
216217 enumerate_interfaces (0 );
217- if (!loopback_exception (listen -> tftpfd , listen -> family , & addra , name ) &&
218- !label_exception (if_index , listen -> family , & addra ))
218+ if (!loopback_exception (listen -> tftpfd , family , & addra , name ) &&
219+ !label_exception (if_index , family , & addra ))
219220 return ;
220221 }
221222
@@ -281,7 +282,7 @@ void tftp_request(struct listener *listen, time_t now)
281282 prefix = pref -> prefix ;
282283 }
283284
284- if (listen -> family == AF_INET )
285+ if (family == AF_INET )
285286 {
286287 addr .in .sin_port = htons (port );
287288#ifdef HAVE_SOCKADDR_SA_LEN
@@ -304,7 +305,7 @@ void tftp_request(struct listener *listen, time_t now)
304305
305306 if (option_bool (OPT_SINGLE_PORT ))
306307 transfer -> sockfd = listen -> tftpfd ;
307- else if ((transfer -> sockfd = socket (listen -> family , SOCK_DGRAM , 0 )) == -1 )
308+ else if ((transfer -> sockfd = socket (family , SOCK_DGRAM , 0 )) == -1 )
308309 {
309310 free (transfer );
310311 return ;
@@ -337,7 +338,7 @@ void tftp_request(struct listener *listen, time_t now)
337338 {
338339 if (++ port <= daemon -> end_tftp_port )
339340 {
340- if (listen -> family == AF_INET )
341+ if (family == AF_INET )
341342 addr .in .sin_port = htons (port );
342343 else
343344 addr .in6 .sin6_port = htons (port );
@@ -375,7 +376,7 @@ void tftp_request(struct listener *listen, time_t now)
375376 if ((opt = next (& p , end )) && !option_bool (OPT_TFTP_NOBLOCK ))
376377 {
377378 /* 32 bytes for IP, UDP and TFTP headers, 52 bytes for IPv6 */
378- int overhead = (listen -> family == AF_INET ) ? 32 : 52 ;
379+ int overhead = (family == AF_INET ) ? 32 : 52 ;
379380 transfer -> blocksize = atoi (opt );
380381 if (transfer -> blocksize < 1 )
381382 transfer -> blocksize = 1 ;
0 commit comments