Lines Matching +full:port +full:- +full:config

2  * Copyright (c) 1997-2005 Kungliga Tekniska Högskolan
37 int enable_http = -1;
57 int port; member
66 * add `family, port, protocol' to the list with duplicate suppresion.
71 int family, int port, const char *protocol) in add_port() argument
84 && ports[i].port == port in add_port()
93 ports[num_ports].port = port; in add_port()
98 * add a triple but with service -> port lookup
104 int family, const char *service, int port, in add_port_service() argument
107 port = krb5_getportbyname (context, service, protocol, port); in add_port_service()
108 add_port (context, family, port, protocol); in add_port_service()
112 * add the port with service -> port lookup or string -> number
121 int port; in add_port_string() local
125 port = sp->s_port; in add_port_string()
129 port = htons(strtol(str, &end, 0)); in add_port_string()
133 add_port (context, family, port, protocol); in add_port_string()
142 krb5_kdc_configuration *config, in add_standard_ports() argument
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.
161 * otherwise it's port|service[/protocol]
166 krb5_kdc_configuration *config, in parse_ports() argument
177 add_standard_ports(context, config, AF_INET6); in parse_ports()
179 add_standard_ports(context, config, AF_INET); in parse_ports()
210 int port; member
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'.
243 * Create the socket (family, type, port) in `d'
248 krb5_kdc_configuration *config, in init_socket() argument
249 struct descr *d, krb5_address *a, int family, int type, int port) in init_socket() argument
258 ret = krb5_addr2sockaddr (context, a, sa, &sa_size, port); in init_socket()
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()
289 krb5_warn(context, errno, "bind %s/%d", a_str, ntohs(port)); 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()
299 krb5_warn(context, errno, "listen %s/%d", a_str, ntohs(port)); in init_socket()
300 rk_closesocket(d->s); in init_socket()
301 d->s = rk_INVALID_SOCKET; in init_socket()
313 krb5_kdc_configuration *config, in init_sockets() argument
329 parse_ports(context, config, port_str); in init_sockets()
337 init_socket(context, config, &d[num], &addresses.val[j], in init_sockets()
338 ports[i].family, ports[i].type, ports[i].port); in init_sockets()
346 kdc_log(context, config, 5, "listening on %s port %u/%s", in init_sockets()
348 ntohs(ports[i].port), 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()
400 krb5_kdc_configuration *config, in send_reply() argument
405 kdc_log(context, config, 5, in send_reply()
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()
415 kdc_log (context, config, 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()
434 krb5_kdc_configuration *config, in do_request() argument
440 int datagram_reply = (d->type == SOCK_DGRAM); in do_request()
445 ret = krb5_kdc_process_request(context, config, 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()
452 send_reply(context, config, prependlength, d, &reply); in do_request()
456 kdc_log(context, config, 0, in do_request()
458 (unsigned long)len, d->addr_string); in do_request()
467 krb5_kdc_configuration *config, in handle_udp() argument
475 kdc_log(context, config, 0, "Failed to allocate %lu bytes", (unsigned long)max_request_udp); in handle_udp()
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()
500 send_reply(context, config, FALSE, d, &data); in handle_udp()
503 do_request(context, config, buf, n, FALSE, d); 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()
548 krb5_kdc_configuration *config, in add_new_tcp() argument
553 if (child == -1) in add_new_tcp()
586 krb5_kdc_configuration *config, in grow_descr() argument
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()
595 kdc_log(context, config, 0, "Request exceeds max request size (%lu bytes).", 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.
620 krb5_kdc_configuration *config, in handle_vanilla_tcp() argument
626 sp = krb5_storage_from_mem(d->buf, d->len); in handle_vanilla_tcp()
628 kdc_log (context, config, 0, "krb5_storage_from_mem failed"); 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.
648 krb5_kdc_configuration *config, in handle_http_tcp() argument
656 s = (char *)d->buf; in handle_http_tcp()
666 kdc_log(context, config, 0, 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()
673 kdc_log(context, config, 0, 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()
680 kdc_log(context, config, 0, "Failed to allocate %lu bytes", 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()
688 kdc_log(context, config, 5, "HTTP request: %s", t); 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()
712 kdc_log(context, config, 5, "HTTP request: %s", t); in handle_http_tcp()
714 if (rk_IS_SOCKET_ERROR(send(d->s, proto, strlen(proto), 0))) { in handle_http_tcp()
715 kdc_log(context, config, 0, "HTTP write failed: %s: %s", 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()
720 kdc_log(context, config, 0, "HTTP write failed: %s: %s", 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()
736 kdc_log(context, config, 0, "HTTP write failed: %s: %s", 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()
742 kdc_log(context, config, 0, "HTTP write failed: %s: %s", 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()
761 krb5_kdc_configuration *config, in handle_tcp() argument
769 add_new_tcp (context, config, d, idx, min_free); in handle_tcp()
777 ntohs(d[idx].port)); in handle_tcp()
783 ntohs(d[idx].port)); in handle_tcp()
787 if (grow_descr (context, config, &d[idx], n)) in handle_tcp()
792 ret = handle_vanilla_tcp (context, config, &d[idx]); in handle_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()
802 ret = handle_http_tcp (context, config, &d[idx]); in handle_tcp()
806 kdc_log (context, config, in handle_tcp()
809 ntohs(d[idx].port)); in handle_tcp()
813 kdc_log (context, config, 0, "TCP extension not supported"); in handle_tcp()
825 send_reply(context, config, TRUE, d + idx, &reply); in handle_tcp()
835 do_request(context, config, in handle_tcp()
843 krb5_kdc_configuration *config) in loop() argument
848 ndescr = init_sockets(context, config, &d); in loop()
851 kdc_log(context, config, 0, "KDC started"); in loop()
855 int min_free = -1; in loop()
864 kdc_log(context, config, 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()
911 handle_udp(context, config, &d[i]); in loop()
913 handle_tcp(context, config, d, i, min_free); in loop()
920 kdc_log(context, config, 0, "CPU time limit exceeded"); in loop()
923 kdc_log(context, config, 0, "Terminated"); in loop()
925 kdc_log(context, config, 0, "Unexpected exit reason: %d", exit_flag); in loop()