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