nxt_listen_socket.c (564:762f8c976ead) nxt_listen_socket.c (703:2d536dde84d2)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8

--- 186 unchanged lines hidden (view full) ---

195 case AF_UNIX:
196 /*
197 * A remote socket is usually unbound and thus has unspecified Unix
198 * domain sockaddr_un which can be shortcut to 3 bytes. To handle
199 * a bound remote socket correctly ls->socklen should be larger, see
200 * comment in nxt_socket.h.
201 */
202 ls->socklen = offsetof(struct sockaddr_un, sun_path) + 1;
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8

--- 186 unchanged lines hidden (view full) ---

195 case AF_UNIX:
196 /*
197 * A remote socket is usually unbound and thus has unspecified Unix
198 * domain sockaddr_un which can be shortcut to 3 bytes. To handle
199 * a bound remote socket correctly ls->socklen should be larger, see
200 * comment in nxt_socket.h.
201 */
202 ls->socklen = offsetof(struct sockaddr_un, sun_path) + 1;
203 ls->address_length = sizeof("unix:") - 1;
203 ls->address_length = nxt_length("unix:");
204
205 break;
206
207#endif
208
209 default:
210 case AF_INET:
211 ls->socklen = sizeof(struct sockaddr_in);

--- 22 unchanged lines hidden (view full) ---

234
235#if (NXT_INET6)
236
237 case AF_INET6:
238 ls->socklen = sizeof(struct sockaddr_in6);
239 ls->address_length = NXT_INET6_ADDR_STR_LEN;
240
241 size = offsetof(nxt_sockaddr_t, u) + sizeof(struct sockaddr_in6)
204
205 break;
206
207#endif
208
209 default:
210 case AF_INET:
211 ls->socklen = sizeof(struct sockaddr_in);

--- 22 unchanged lines hidden (view full) ---

234
235#if (NXT_INET6)
236
237 case AF_INET6:
238 ls->socklen = sizeof(struct sockaddr_in6);
239 ls->address_length = NXT_INET6_ADDR_STR_LEN;
240
241 size = offsetof(nxt_sockaddr_t, u) + sizeof(struct sockaddr_in6)
242 + NXT_INET6_ADDR_STR_LEN + (sizeof(":65535") - 1);
242 + NXT_INET6_ADDR_STR_LEN + nxt_length(":65535");
243
244 if (IN6_IS_ADDR_UNSPECIFIED(&ls->sockaddr->u.sockaddr_in6.sin6_addr)) {
245 size += offsetof(nxt_sockaddr_t, u) + sizeof(struct sockaddr_in6);
246 }
247
248 break;
249
250#endif
251
252#if (NXT_HAVE_UNIX_DOMAIN)
253
254 case AF_UNIX:
255 /*
256 * A remote socket is usually unbound and thus has unspecified Unix
257 * domain sockaddr_un which can be shortcut to 3 bytes. To handle
258 * a bound remote socket correctly ls->socklen should be at least
259 * sizeof(struct sockaddr_un), see comment in nxt_socket.h.
260 */
261 ls->socklen = 3;
243
244 if (IN6_IS_ADDR_UNSPECIFIED(&ls->sockaddr->u.sockaddr_in6.sin6_addr)) {
245 size += offsetof(nxt_sockaddr_t, u) + sizeof(struct sockaddr_in6);
246 }
247
248 break;
249
250#endif
251
252#if (NXT_HAVE_UNIX_DOMAIN)
253
254 case AF_UNIX:
255 /*
256 * A remote socket is usually unbound and thus has unspecified Unix
257 * domain sockaddr_un which can be shortcut to 3 bytes. To handle
258 * a bound remote socket correctly ls->socklen should be at least
259 * sizeof(struct sockaddr_un), see comment in nxt_socket.h.
260 */
261 ls->socklen = 3;
262 size = ls->socklen + sizeof("unix:") - 1;
263 ls->address_length = sizeof("unix:") - 1;
262 size = ls->socklen + nxt_length("unix:");
263 ls->address_length = nxt_length("unix:");
264
265 break;
266
267#endif
268
269 default:
270 ls->socklen = sizeof(struct sockaddr_in);
271 ls->address_length = NXT_INET_ADDR_STR_LEN;
272
273 size = offsetof(nxt_sockaddr_t, u) + sizeof(struct sockaddr_in)
264
265 break;
266
267#endif
268
269 default:
270 ls->socklen = sizeof(struct sockaddr_in);
271 ls->address_length = NXT_INET_ADDR_STR_LEN;
272
273 size = offsetof(nxt_sockaddr_t, u) + sizeof(struct sockaddr_in)
274 + NXT_INET_ADDR_STR_LEN + (sizeof(":65535") - 1);
274 + NXT_INET_ADDR_STR_LEN + nxt_length(":65535");
275
276 if (ls->sockaddr->u.sockaddr_in.sin_addr.s_addr == INADDR_ANY) {
277 size += offsetof(nxt_sockaddr_t, u) + sizeof(struct sockaddr_in);
278 }
279
280 break;
281 }
282

--- 26 unchanged lines hidden ---
275
276 if (ls->sockaddr->u.sockaddr_in.sin_addr.s_addr == INADDR_ANY) {
277 size += offsetof(nxt_sockaddr_t, u) + sizeof(struct sockaddr_in);
278 }
279
280 break;
281 }
282

--- 26 unchanged lines hidden ---