- /*
- * First, find and decode the header:
- */
- if((headoff = readhead(fd, &inbuf)) < 0)
- goto out;
- if(headoff > 65536) {
- /* We cannot handle arbitrarily large headers, as they
- * need to fit within a single Unix datagram. This is
- * probably a safe limit, and larger packets than this are
- * most likely erroneous (or malicious) anyway. */
- goto out;
- }
- old = inbuf.b[headoff];
- inbuf.b[headoff] = 0;
- if((req = parserawreq(inbuf.b)) == NULL)
- goto out;
- inbuf.b[headoff] = old;
- bufeat(inbuf, headoff);
-
- /*
- * Add metainformation and then send the request to the root
- * multiplexer:
- */
- if(name.ss_family == AF_INET) {
- headappheader(req, "X-Ash-Address", inet_ntop(AF_INET, &((struct sockaddr_in *)&name)->sin_addr, nmbuf, sizeof(nmbuf)));
- headappheader(req, "X-Ash-Port", sprintf3("%i", ntohs(((struct sockaddr_in *)&name)->sin_port)));
- } else if(name.ss_family == AF_INET6) {
- headappheader(req, "X-Ash-Address", inet_ntop(AF_INET6, &((struct sockaddr_in6 *)&name)->sin6_addr, nmbuf, sizeof(nmbuf)));
- headappheader(req, "X-Ash-Port", sprintf3("%i", ntohs(((struct sockaddr_in6 *)&name)->sin6_port)));
- }
- cfd = sendreq(plex, req);
-
- /*
- * Find and decode the response header:
- */
- outbuf.d = 0;
- headoff = readhead(cfd, &outbuf);
- hd = memcpy(smalloc(headoff + 1), outbuf.b, headoff);
- hd[headoff] = 0;
- if((resp = parserawresp(hd)) == NULL)
- goto out;