nxt_sockaddr.c (102:8dc96d9dcff7) nxt_sockaddr.c (110:b367ad00650d)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8

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

190nxt_sockaddr_text(nxt_sockaddr_t *sa)
191{
192 size_t offset;
193 u_char *p, *start, *end, *octet;
194 uint32_t port;
195
196 offset = offsetof(nxt_sockaddr_t, u) + sa->socklen;
197 sa->start = offset;
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8

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

190nxt_sockaddr_text(nxt_sockaddr_t *sa)
191{
192 size_t offset;
193 u_char *p, *start, *end, *octet;
194 uint32_t port;
195
196 offset = offsetof(nxt_sockaddr_t, u) + sa->socklen;
197 sa->start = offset;
198 sa->port_start = offset;
198
199 start = nxt_pointer_to(sa, offset);
200 end = nxt_pointer_to(sa, sa->sockaddr_size);
201
202 switch (sa->u.sockaddr.sa_family) {
203
204 case AF_INET:
205 sa->address_start = offset;
206
207 octet = (u_char *) &sa->u.sockaddr_in.sin_addr;
208
209 p = nxt_sprintf(start, end, "%ud.%ud.%ud.%ud",
210 octet[0], octet[1], octet[2], octet[3]);
211
212 sa->address_length = p - start;
199
200 start = nxt_pointer_to(sa, offset);
201 end = nxt_pointer_to(sa, sa->sockaddr_size);
202
203 switch (sa->u.sockaddr.sa_family) {
204
205 case AF_INET:
206 sa->address_start = offset;
207
208 octet = (u_char *) &sa->u.sockaddr_in.sin_addr;
209
210 p = nxt_sprintf(start, end, "%ud.%ud.%ud.%ud",
211 octet[0], octet[1], octet[2], octet[3]);
212
213 sa->address_length = p - start;
213 sa->port_start = sa->address_length + 1;
214 sa->port_start += sa->address_length + 1;
214
215 port = sa->u.sockaddr_in.sin_port;
216
217 break;
218
219#if (NXT_INET6)
220
221 case AF_INET6:
222 sa->address_start = offset + 1;
223
224 p = start;
225 *p++ = '[';
226
227 p = nxt_inet6_ntop(sa->u.sockaddr_in6.sin6_addr.s6_addr, p, end);
228
229 sa->address_length = p - (start + 1);
215
216 port = sa->u.sockaddr_in.sin_port;
217
218 break;
219
220#if (NXT_INET6)
221
222 case AF_INET6:
223 sa->address_start = offset + 1;
224
225 p = start;
226 *p++ = '[';
227
228 p = nxt_inet6_ntop(sa->u.sockaddr_in6.sin6_addr.s6_addr, p, end);
229
230 sa->address_length = p - (start + 1);
230 sa->port_start = sa->address_length + 2;
231 sa->port_start += sa->address_length + 3;
231
232 *p++ = ']';
233
234 port = sa->u.sockaddr_in6.sin6_port;
235
236 break;
237
238#endif

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

260
261#else /* !(NXT_LINUX) */
262
263 p = nxt_sprintf(start, end, "unix:%s", p);
264
265#endif
266
267 sa->address_length = p - start;
232
233 *p++ = ']';
234
235 port = sa->u.sockaddr_in6.sin6_port;
236
237 break;
238
239#endif

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

261
262#else /* !(NXT_LINUX) */
263
264 p = nxt_sprintf(start, end, "unix:%s", p);
265
266#endif
267
268 sa->address_length = p - start;
268 sa->port_start = sa->address_length;
269 sa->port_start += sa->address_length;
269 sa->length = p - start;
270
271 return;
272
273#endif /* NXT_HAVE_UNIX_DOMAIN */
274
275 default:
276 return;

--- 998 unchanged lines hidden ---
270 sa->length = p - start;
271
272 return;
273
274#endif /* NXT_HAVE_UNIX_DOMAIN */
275
276 default:
277 return;

--- 998 unchanged lines hidden ---