3 * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
4 * All rights reserved. See COPYRIGHT.
9 #endif /* HAVE_CONFIG_H */
14 #include <sys/types.h>
15 #include <arpa/inet.h>
17 #include <atalk/dsi.h>
18 #include <atalk/afp.h>
21 #define MIN(a,b) ((a) < (b) ? (a) : (b))
24 /* send an attention. this may get called at any time, so we can't use
25 * DSI buffers to send one.
29 int dsi_attention(DSI *dsi, AFPUserBytes flags)
31 /* header + AFPUserBytes */
32 char block[DSI_BLOCKSIZ + sizeof(AFPUserBytes)];
36 if (dsi->flags & DSI_SLEEPING)
42 id = htons(dsi_serverID(dsi));
44 len = MIN(sizeof(flags), dsi->attn_quantum);
47 memset(block, 0, sizeof(block));
48 block[0] = DSIFL_REQUEST; /* sending a request */
49 block[1] = DSIFUNC_ATTN; /* it's an attention */
50 memcpy(block + 2, &id, sizeof(id));
52 memcpy(block + 8, &nlen, sizeof(nlen));
53 memcpy(block + 16, &flags, sizeof(flags));
56 /* send an attention */
57 return dsi_stream_write(dsi, block, DSI_BLOCKSIZ + len, DSI_NOWAIT);