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
16 /* this assumes that the reply follows right after the command, saving
17 * on a couple assignments. specifically, command, requestID, and
18 * reserved field are assumed to already be set. */
dsi_cmdreply(DSI * dsi,const int err)19 int dsi_cmdreply(DSI *dsi, const int err)
20 {
21 int ret;
22
23 LOG(log_debug, logtype_dsi, "dsi_cmdreply(DSI ID: %u, len: %zd): START",
24 dsi->clientID, dsi->datalen);
25
26 dsi->header.dsi_flags = DSIFL_REPLY;
27 dsi->header.dsi_len = htonl(dsi->datalen);
28 dsi->header.dsi_data.dsi_code = htonl(err);
29
30 ret = dsi_stream_send(dsi, dsi->data, dsi->datalen);
31
32 LOG(log_debug, logtype_dsi, "dsi_cmdreply(DSI ID: %u, len: %zd): END",
33 dsi->clientID, dsi->datalen);
34
35 return ret;
36 }
37