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