-static int
-rcaux (struct servent *sp, struct hostent *hp, int rproto,
- char *response, int len_response)
-{
- int sd;
- struct in_addr in;
- register struct addrent *ap;
- struct sockaddr_in in_socket;
- register struct sockaddr_in *isock = &in_socket;
-
-#ifdef KPOP
- int rem;
- struct hostent *hp2;
-#endif /* KPOP */
-
- for (ap = nets; ap < n1; ap++)
- if (ap->a_addrtype == hp->h_addrtype && inet (hp, ap->a_net))
- return NOTOK;
-
- for (ap = hosts; ap < h1; ap++)
- if (ap->a_addrtype == hp->h_addrtype
- && memcmp(ap->a_addr, hp->h_addr, hp->h_length) == 0)
- return NOTOK;
-
- if ((sd = getport (rproto, hp->h_addrtype, response, len_response)) == NOTOK)
- return OOPS2;
-
- memset (isock, 0, sizeof(*isock));
- isock->sin_family = hp->h_addrtype;
- inaddr_copy (hp, isock);
- isock->sin_port = sp->s_port;
-
- if (connect (sd, (struct sockaddr *) isock, sizeof(*isock)) == NOTOK)
- switch (errno) {
- case ENETDOWN:
- case ENETUNREACH:
- close (sd);
- if (n1 < n2) {
- n1->a_addrtype = hp->h_addrtype;
- memcpy(&in, hp->h_addr, sizeof(in));
- n1->a_net = inet_netof (in);
- n1++;
- }
- return OOPS1;
-
- case ETIMEDOUT:
- case ECONNREFUSED:
- default:
- close (sd);
- if (h1 < h2) {
- h1->a_addrtype = hp->h_addrtype;
- memcpy(h1->a_addr, hp->h_addr, hp->h_length);
- h1++;
- }
- return NOTOK;
- }
-
-#ifdef KPOP
- if (kservice) { /* "pop" */
- char *instance;
-
- if (( hp2 = gethostbyaddr( hp->h_addr, hp->h_length, hp->h_addrtype ))
- == NULL ) {
- return NOTOK;
- }
- if ((instance = strdup (hp2->h_name)) == NULL) {
- close (sd);
- strncpy (response, "Out of memory.", len_response);
- return OOPS2;
- }
- ticket = (KTEXT) malloc (sizeof(KTEXT_ST));
- rem = krb_sendauth (0L, sd, ticket, kservice, instance,
- (char *) krb_realmofhost (instance),
- (unsigned long) 0, &msg_data, &cred, schedule,
- (struct sockaddr_in *) NULL,
- (struct sockaddr_in *) NULL,
- "KPOPV0.1");
- free (instance);
- if (rem != KSUCCESS) {
- close (sd);
- strncpy (response, "Post office refused connection: ", len_response);
- strncat (response, krb_err_txt[rem], len_response - strlen(response));
- return OOPS2;
- }
- }
-#endif /* KPOP */