2 * $Id: dsi_attn.c,v 1.3 2001-06-29 14:14:46 rufustfirefly 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>
17 #include <atalk/dsi.h>
18 #include <atalk/afp.h>
19 #include <netatalk/endian.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. */
27 int dsi_attention(DSI *dsi, AFPUserBytes flags)
29 /* header + AFPUserBytes */
30 char block[DSI_BLOCKSIZ + sizeof(AFPUserBytes)];
35 id = htons(dsi_serverID(dsi));
37 len = MIN(sizeof(flags), dsi->attn_quantum);
40 memset(block, 0, sizeof(block));
41 block[0] = DSIFL_REQUEST; /* sending a request */
42 block[1] = DSIFUNC_ATTN; /* it's an attention */
43 memcpy(block + 2, &id, sizeof(id));
45 memcpy(block + 8, &nlen, sizeof(nlen));
46 memcpy(block + 16, &flags, sizeof(flags));
49 /* send an attention */
50 sigprocmask(SIG_BLOCK, &dsi->sigblockset, &oldset);
51 len = dsi_stream_write(dsi, block, DSI_BLOCKSIZ + len);
52 sigprocmask(SIG_SETMASK, &oldset, NULL);