]> arthur.barton.de Git - netatalk.git/blob - libatalk/asp/asp_attn.c
massive commenting/autoconf changes
[netatalk.git] / libatalk / asp / asp_attn.c
1 /*
2  * $Id: asp_attn.c,v 1.4 2001-06-29 14:14:46 rufustfirefly Exp $
3  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
4  * All rights reserved. See COPYRIGHT.
5  */
6
7 #ifdef HAVE_CONFIG_H
8 #include "config.h"
9 #endif /* HAVE_CONFIG_H */
10
11 #include <stdio.h>
12 #include <string.h>
13 #include <syslog.h>
14 #include <sys/types.h>
15 #include <sys/uio.h>
16 #include <sys/socket.h>
17
18 #include <atalk/atp.h>
19 #include <atalk/asp.h>
20 #include <atalk/afp.h>
21
22 /* attentions can get sent at any time. as a consequence, we don't
23  * want to touch anything that might be used elsewhere. */
24 int asp_attention(ASP asp, AFPUserBytes flags)
25 {
26     char cmds[ASP_HDRSIZ], data[ASP_HDRSIZ];
27     struct sockaddr_at  sat;
28     struct atp_block    atpb;
29     struct iovec        iov[ 1 ];
30
31     cmds[0] = ASPFUNC_ATTN;
32     cmds[1] = asp->asp_sid;
33     flags = htons(flags);
34     memcpy(cmds + 2, &flags, sizeof(flags));
35
36     sat = asp->asp_sat;
37     sat.sat_port = asp->asp_wss;
38     atpb.atp_saddr = &sat;
39     atpb.atp_sreqdata = cmds;
40     atpb.atp_sreqdlen = sizeof(cmds);
41     atpb.atp_sreqto = 2;
42     atpb.atp_sreqtries = 5;
43
44     if ( atp_sreq( asp->asp_atp, &atpb, 1, 0 ) < 0 ) {
45         syslog( LOG_ERR, "atp_sreq: %m" );
46         return -1;
47     }
48
49     iov[ 0 ].iov_base = data;
50     iov[ 0 ].iov_len = sizeof( data );
51     atpb.atp_rresiov = iov;
52     atpb.atp_rresiovcnt = sizeof( iov )/sizeof( iov[ 0 ] );
53     if ( atp_rresp( asp->asp_atp, &atpb ) < 0 ) {
54         syslog( LOG_ERR, "atp_rresp: %m" );
55         return -1;
56     }
57
58     return 0;
59 }