2 * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
3 * All rights reserved. See COPYRIGHT.
11 #include <atalk/dsi.h>
12 #include <atalk/afp.h>
13 #include <netatalk/endian.h>
16 #define MIN(a,b) ((a) < (b) ? (a) : (b))
19 /* send an attention. this may get called at any time, so we can't use
20 * DSI buffers to send one. */
21 int dsi_attention(DSI *dsi, AFPUserBytes flags)
23 /* header + AFPUserBytes */
24 char block[DSI_BLOCKSIZ + sizeof(AFPUserBytes)];
29 id = htons(dsi_serverID(dsi));
31 len = MIN(sizeof(flags), dsi->attn_quantum);
34 memset(block, 0, sizeof(block));
35 block[0] = DSIFL_REQUEST; /* sending a request */
36 block[1] = DSIFUNC_ATTN; /* it's an attention */
37 memcpy(block + 2, &id, sizeof(id));
39 memcpy(block + 8, &nlen, sizeof(nlen));
40 memcpy(block + 16, &flags, sizeof(flags));
43 /* send an attention */
44 sigprocmask(SIG_BLOCK, &dsi->sigblockset, &oldset);
45 len = dsi_stream_write(dsi, block, DSI_BLOCKSIZ + len);
46 sigprocmask(SIG_SETMASK, &oldset, NULL);