Lines Matching +full:num +full:- +full:addresses

2  * Copyright (c) 1997-2005 Kungliga Tekniska Högskolan
37 int enable_http = -1;
98 * add a triple but with service -> port lookup
112 * add the port with service -> port lookup or string -> number
125 port = sp->s_port; in add_port_string()
147 add_port_service(context, family, "kerberos-sec", 88, "udp"); in add_standard_ports()
148 add_port_service(context, family, "kerberos-sec", 88, "tcp"); in add_standard_ports()
151 if(config->enable_kx509) { in add_standard_ports()
159 * parse the set of space-delimited ports in `str' and add them.
225 d->sa = (struct sockaddr *)&d->__ss; in init_descr()
226 d->s = rk_INVALID_SOCKET; in init_descr()
230 * re-initialize all `n' ->sa in `d'.
261 rk_closesocket(d->s); in init_socket()
262 d->s = rk_INVALID_SOCKET; in init_socket()
266 if (sa->sa_family != family) in init_socket()
269 d->s = socket(family, type, 0); in init_socket()
270 if(rk_IS_BAD_SOCKET(d->s)){ in init_socket()
272 d->s = rk_INVALID_SOCKET; in init_socket()
278 setsockopt(d->s, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof(one)); in init_socket()
281 d->type = type; in init_socket()
282 d->port = port; in init_socket()
284 if(rk_IS_SOCKET_ERROR(bind(d->s, sa, sa_size))){ in init_socket()
290 rk_closesocket(d->s); in init_socket()
291 d->s = rk_INVALID_SOCKET; in init_socket()
294 if(type == SOCK_STREAM && rk_IS_SOCKET_ERROR(listen(d->s, SOMAXCONN))){ in init_socket()
300 rk_closesocket(d->s); in init_socket()
301 d->s = rk_INVALID_SOCKET; in init_socket()
319 int num = 0; in init_sockets() local
320 krb5_addresses addresses; in init_sockets() local
323 addresses = explicit_addresses; in init_sockets()
325 ret = krb5_get_all_server_addrs (context, &addresses); in init_sockets()
330 d = malloc(addresses.len * num_ports * sizeof(*d)); in init_sockets()
336 for (j = 0; j < addresses.len; ++j) { in init_sockets()
337 init_socket(context, config, &d[num], &addresses.val[j], in init_sockets()
339 if(d[num].s != rk_INVALID_SOCKET){ in init_sockets()
343 krb5_print_address (&addresses.val[j], a_str, in init_sockets()
351 num++; in init_sockets()
355 krb5_free_addresses (context, &addresses); in init_sockets()
356 d = realloc(d, num * sizeof(*d)); in init_sockets()
357 if (d == NULL && num != 0) in init_sockets()
359 (unsigned long)num * sizeof(*d)); in init_sockets()
360 reinit_descrs (d, num); in init_sockets()
362 return num; in init_sockets()
372 if (d->type == SOCK_DGRAM) in descr_type()
374 else if (d->type == SOCK_STREAM) in descr_type()
391 snprintf(str, len, "<family=%d>", addr->sa_family); in addr_to_string()
406 "sending %lu bytes to %s", (unsigned long)reply->length, in send_reply()
407 d->addr_string); in send_reply()
410 l[0] = (reply->length >> 24) & 0xff; in send_reply()
411 l[1] = (reply->length >> 16) & 0xff; in send_reply()
412 l[2] = (reply->length >> 8) & 0xff; in send_reply()
413 l[3] = reply->length & 0xff; in send_reply()
414 if(rk_IS_SOCKET_ERROR(sendto(d->s, l, sizeof(l), 0, d->sa, d->sock_len))) { in send_reply()
416 0, "sendto(%s): %s", d->addr_string, in send_reply()
421 if(rk_IS_SOCKET_ERROR(sendto(d->s, reply->data, reply->length, 0, d->sa, d->sock_len))) { in send_reply()
422 kdc_log (context, config, 0, "sendto(%s): %s", d->addr_string, in send_reply()
440 int datagram_reply = (d->type == SOCK_DGRAM); in do_request()
447 d->addr_string, d->sa, in do_request()
450 krb5_kdc_save_request(context, request_log, buf, len, &reply, d->sa); in do_request()
458 (unsigned long)len, d->addr_string); in do_request()
479 d->sock_len = sizeof(d->__ss); in handle_udp()
480 n = recvfrom(d->s, buf, max_request_udp, 0, d->sa, &d->sock_len); in handle_udp()
484 addr_to_string (context, d->sa, d->sock_len, in handle_udp()
485 d->addr_string, sizeof(d->addr_string)); in handle_udp()
490 d->addr_string); in handle_udp()
512 if(d->buf) in clear_descr()
513 memset(d->buf, 0, d->size); in clear_descr()
514 d->len = 0; in clear_descr()
515 if(d->s != rk_INVALID_SOCKET) in clear_descr()
516 rk_closesocket(d->s); in clear_descr()
517 d->s = rk_INVALID_SOCKET; in clear_descr()
521 /* remove HTTP %-quoting from buf */
530 return -1; in de_http()
553 if (child == -1) in add_new_tcp()
589 if (d->size - d->len < n) { in grow_descr()
593 grow = max(1024, d->len + n); in grow_descr()
594 if (d->size + grow > max_request_tcp) { in grow_descr()
596 (unsigned long)d->size + grow); in grow_descr()
598 return -1; in grow_descr()
600 tmp = realloc (d->buf, d->size + grow); in grow_descr()
602 kdc_log(context, config, 0, "Failed to re-allocate %lu bytes.", in grow_descr()
603 (unsigned long)d->size + grow); in grow_descr()
605 return -1; in grow_descr()
607 d->size += grow; in grow_descr()
608 d->buf = tmp; in grow_descr()
614 * Try to handle the TCP data at `d->buf, d->len'.
615 * Return -1 if failed, 0 if succesful, and 1 if data is complete.
626 sp = krb5_storage_from_mem(d->buf, d->len); in handle_vanilla_tcp()
629 return -1; in handle_vanilla_tcp()
633 if(d->len - 4 >= len) { in handle_vanilla_tcp()
634 memmove(d->buf, d->buf + 4, d->len - 4); in handle_vanilla_tcp()
635 d->len -= 4; in handle_vanilla_tcp()
642 * Try to handle the TCP/HTTP data at `d->buf, d->len'.
643 * Return -1 if failed, 0 if succesful, and 1 if data is complete.
656 s = (char *)d->buf; in handle_http_tcp()
667 "Missing HTTP operand (GET) request from %s", d->addr_string); in handle_http_tcp()
668 return -1; in handle_http_tcp()
674 "Missing HTTP GET data in request from %s", d->addr_string); in handle_http_tcp()
675 return -1; in handle_http_tcp()
682 return -1; in handle_http_tcp()
687 kdc_log(context, config, 0, "Malformed HTTP request from %s", d->addr_string); in handle_http_tcp()
690 return -1; in handle_http_tcp()
694 kdc_log(context, config, 0, "Malformed HTTP request from %s", d->addr_string); in handle_http_tcp()
696 return -1; in handle_http_tcp()
703 "Cache-Control: no-cache\r\n" in handle_http_tcp()
704 "Pragma: no-cache\r\n" in handle_http_tcp()
705 "Content-type: text/html\r\n" in handle_http_tcp()
706 "Content-transfer-encoding: 8bit\r\n\r\n" in handle_http_tcp()
711 kdc_log(context, config, 0, "HTTP request from %s is non KDC request", d->addr_string); in handle_http_tcp()
714 if (rk_IS_SOCKET_ERROR(send(d->s, proto, strlen(proto), 0))) { in handle_http_tcp()
716 d->addr_string, strerror(rk_SOCK_ERRNO)); in handle_http_tcp()
717 return -1; in handle_http_tcp()
719 if (rk_IS_SOCKET_ERROR(send(d->s, msg, strlen(msg), 0))) { in handle_http_tcp()
721 d->addr_string, strerror(rk_SOCK_ERRNO)); in handle_http_tcp()
722 return -1; in handle_http_tcp()
724 return -1; in handle_http_tcp()
730 "Cache-Control: no-cache\r\n" in handle_http_tcp()
731 "Pragma: no-cache\r\n" in handle_http_tcp()
732 "Content-type: application/octet-stream\r\n" in handle_http_tcp()
733 "Content-transfer-encoding: binary\r\n\r\n"; in handle_http_tcp()
734 if (rk_IS_SOCKET_ERROR(send(d->s, proto, strlen(proto), 0))) { in handle_http_tcp()
737 d->addr_string, strerror(rk_SOCK_ERRNO)); in handle_http_tcp()
738 return -1; in handle_http_tcp()
740 if (rk_IS_SOCKET_ERROR(send(d->s, msg, strlen(msg), 0))) { in handle_http_tcp()
743 d->addr_string, strerror(rk_SOCK_ERRNO)); in handle_http_tcp()
744 return -1; in handle_http_tcp()
747 if ((size_t)len > d->len) in handle_http_tcp()
748 len = d->len; in handle_http_tcp()
749 memcpy(d->buf, data, len); in handle_http_tcp()
750 d->len = len; in handle_http_tcp()
796 strncmp((char *)d[idx].buf + d[idx].len - 4, in handle_tcp()
800 d[idx].buf[d[idx].len - 4] = '\0'; in handle_tcp()
855 int min_free = -1; in loop()
865 "TCP-connection from %s expired after %lu bytes", in loop()
882 if(min_free == -1){ in loop()
903 case -1: in loop()