summaryrefslogtreecommitdiffstats
path: root/src/kdc/network.c
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2007-04-27 23:27:31 +0000
committerKen Raeburn <raeburn@mit.edu>2007-04-27 23:27:31 +0000
commit973b2b635f3de9ae9cd3a79872cb5f70b9745760 (patch)
tree3576ba5e80543f55a8bb89004fba05be282a7e4d /src/kdc/network.c
parentded1d245bbb7b419f5d583802e4967e82a008801 (diff)
downloadkrb5-973b2b635f3de9ae9cd3a79872cb5f70b9745760.tar.gz
krb5-973b2b635f3de9ae9cd3a79872cb5f70b9745760.tar.xz
krb5-973b2b635f3de9ae9cd3a79872cb5f70b9745760.zip
Move the code for queueing an outgoing response on a TCP stream into a separate
function. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19535 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/kdc/network.c')
-rw-r--r--src/kdc/network.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/kdc/network.c b/src/kdc/network.c
index e73352fda3..20a0bd50cb 100644
--- a/src/kdc/network.c
+++ b/src/kdc/network.c
@@ -1225,6 +1225,17 @@ make_toolong_error (krb5_data **out)
}
static void
+queue_tcp_outgoing_response(struct connection *conn)
+{
+ store_32_be(conn->u.tcp.response->length, conn->u.tcp.lenbuf);
+ SG_SET(&conn->u.tcp.sgbuf[1], conn->u.tcp.response->data,
+ conn->u.tcp.response->length);
+ conn->u.tcp.sgp = conn->u.tcp.sgbuf;
+ conn->u.tcp.sgnum = 2;
+ FD_SET(conn->fd, &sstate.wfds);
+}
+
+static void
process_tcp_connection(struct connection *conn, const char *prog, int selflags)
{
if (selflags & SSF_WRITE) {
@@ -1284,10 +1295,7 @@ process_tcp_connection(struct connection *conn, const char *prog, int selflags)
conn->u.tcp.offset += nread;
if (conn->u.tcp.offset == 4) {
unsigned char *p = (unsigned char *)conn->u.tcp.buffer;
- conn->u.tcp.msglen = ((p[0] << 24)
- | (p[1] << 16)
- | (p[2] << 8)
- | p[3]);
+ conn->u.tcp.msglen = load_32_be(p);
if (conn->u.tcp.msglen > conn->u.tcp.bufsiz - 4) {
krb5_error_code err;
/* message too big */
@@ -1332,16 +1340,8 @@ process_tcp_connection(struct connection *conn, const char *prog, int selflags)
goto kill_tcp_connection;
}
have_response:
- conn->u.tcp.lenbuf[0] = 0xff & (conn->u.tcp.response->length >> 24);
- conn->u.tcp.lenbuf[1] = 0xff & (conn->u.tcp.response->length >> 16);
- conn->u.tcp.lenbuf[2] = 0xff & (conn->u.tcp.response->length >> 8);
- conn->u.tcp.lenbuf[3] = 0xff & (conn->u.tcp.response->length >> 0);
- SG_SET(&conn->u.tcp.sgbuf[1], conn->u.tcp.response->data,
- conn->u.tcp.response->length);
- conn->u.tcp.sgp = conn->u.tcp.sgbuf;
- conn->u.tcp.sgnum = 2;
+ queue_tcp_outgoing_response(conn);
FD_CLR(conn->fd, &sstate.rfds);
- FD_SET(conn->fd, &sstate.wfds);
}
} else
abort();