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