]> arthur.barton.de Git - netatalk.git/blob - libatalk/dsi/dsi_cmdreply.c
45798b09e6f026715fb0fc4a1cd9956f56b40bd9
[netatalk.git] / libatalk / dsi / dsi_cmdreply.c
1 /*
2  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
3  * All rights reserved. See COPYRIGHT.
4  */
5
6 #ifdef HAVE_CONFIG_H
7 #include "config.h"
8 #endif /* HAVE_CONFIG_H */
9
10 #include <stdio.h>
11 #include <arpa/inet.h>
12
13 #include <atalk/dsi.h>
14 #include <atalk/logger.h>
15 #include <netatalk/endian.h>
16
17 /* this assumes that the reply follows right after the command, saving
18  * on a couple assignments. specifically, command, requestID, and
19  * reserved field are assumed to already be set. */ 
20 int dsi_cmdreply(DSI *dsi, const int err)
21 {
22     int ret;
23
24     LOG(log_debug, logtype_dsi, "dsi_cmdreply(DSI ID: %u, len: %jd): START",
25         dsi->clientID, (intmax_t)dsi->datalen);
26
27     dsi->header.dsi_flags = DSIFL_REPLY;
28     dsi->header.dsi_len = htonl(dsi->datalen);
29     dsi->header.dsi_code = htonl(err);
30
31     ret = dsi_stream_send(dsi, dsi->data, dsi->datalen);
32
33     LOG(log_debug, logtype_dsi, "dsi_cmdreply(DSI ID: %u, len: %jd): END",
34         dsi->clientID, (intmax_t)dsi->datalen);
35
36     return ret;
37 }