]> arthur.barton.de Git - netatalk.git/blob - libatalk/asp/asp_attn.c
Added missing include <sys/socket.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 #include <sys/socket.h>
16
17 #include <atalk/atp.h>
18 #include <atalk/asp.h>
19 #include <atalk/afp.h>
20
21 /* attentions can get sent at any time. as a consequence, we don't
22  * want to touch anything that might be used elsewhere. */
23 int asp_attention(ASP asp, AFPUserBytes flags)
24 {
25     char cmds[ASP_HDRSIZ], data[ASP_HDRSIZ];
26     struct sockaddr_at  sat;
27     struct atp_block    atpb;
28     struct iovec        iov[ 1 ];
29
30     cmds[0] = ASPFUNC_ATTN;
31     cmds[1] = asp->asp_sid;
32     flags = htons(flags);
33     memcpy(cmds + 2, &flags, sizeof(flags));
34
35     sat = asp->asp_sat;
36     sat.sat_port = asp->asp_wss;
37     atpb.atp_saddr = &sat;
38     atpb.atp_sreqdata = cmds;
39     atpb.atp_sreqdlen = sizeof(cmds);
40     atpb.atp_sreqto = 2;
41     atpb.atp_sreqtries = 5;
42
43     if ( atp_sreq( asp->asp_atp, &atpb, 1, 0 ) < 0 ) {
44         syslog( LOG_ERR, "atp_sreq: %m" );
45         return -1;
46     }
47
48     iov[ 0 ].iov_base = data;
49     iov[ 0 ].iov_len = sizeof( data );
50     atpb.atp_rresiov = iov;
51     atpb.atp_rresiovcnt = sizeof( iov )/sizeof( iov[ 0 ] );
52     if ( atp_rresp( asp->asp_atp, &atpb ) < 0 ) {
53         syslog( LOG_ERR, "atp_rresp: %m" );
54         return -1;
55     }
56
57     return 0;
58 }