2 * $Id: dsi_attn.c,v 1.8 2009-10-25 06:13:11 didg Exp $
4 * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
5 * All rights reserved. See COPYRIGHT.
10 #endif /* HAVE_CONFIG_H */
15 #include <sys/types.h>
16 #include <arpa/inet.h>
18 #include <atalk/dsi.h>
19 #include <atalk/afp.h>
22 #define MIN(a,b) ((a) < (b) ? (a) : (b))
25 /* send an attention. this may get called at any time, so we can't use
26 * DSI buffers to send one.
30 int dsi_attention(DSI *dsi, AFPUserBytes flags)
32 /* header + AFPUserBytes */
33 char block[DSI_BLOCKSIZ + sizeof(AFPUserBytes)];
37 if (dsi->flags & DSI_SLEEPING)
43 id = htons(dsi_serverID(dsi));
45 len = MIN(sizeof(flags), dsi->attn_quantum);
48 memset(block, 0, sizeof(block));
49 block[0] = DSIFL_REQUEST; /* sending a request */
50 block[1] = DSIFUNC_ATTN; /* it's an attention */
51 memcpy(block + 2, &id, sizeof(id));
53 memcpy(block + 8, &nlen, sizeof(nlen));
54 memcpy(block + 16, &flags, sizeof(flags));
57 /* send an attention */
58 return dsi_stream_write(dsi, block, DSI_BLOCKSIZ + len, DSI_NOWAIT);