]> arthur.barton.de Git - netatalk.git/blob - etc/atalkd/aep.c
Previous fix 9e4e07c1811edbaf3376ad6e238a1353b405002b resulted in the inability to...
[netatalk.git] / etc / atalkd / aep.c
1 /*
2  * $Id: aep.c,v 1.9 2009-10-13 22:55:37 didg Exp $
3  *
4  * Copyright (c) 1990,1993 Regents of The University of Michigan.
5  * All Rights Reserved. See COPYRIGHT.
6  */
7
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif /* HAVE_CONFIG_H */
11
12 #include <string.h>
13 #include <errno.h>
14
15 #include <atalk/logger.h>
16 #include <sys/types.h>
17 #include <sys/socket.h>
18 #include <netatalk/at.h>
19 #include <atalk/aep.h>
20 #include <atalk/ddp.h>
21
22 #include "atserv.h"
23
24 int aep_packet(
25     struct atport       *ap,
26     struct sockaddr_at  *from,
27     char                *data,
28     int                 len)
29 {
30     char                *end;
31
32     end = data + len;
33     if ( data + 2 > end || *data != DDPTYPE_AEP ||
34             *( data + 1 ) != AEPOP_REQUEST ) {
35         LOG(log_info, logtype_atalkd, "aep_packet malformed packet" );
36         return 1;
37     }
38
39     *( data + 1 ) = AEPOP_REPLY;
40     if ( sendto( ap->ap_fd, data, len, 0, (struct sockaddr *)from,
41             sizeof( struct sockaddr_at )) < 0 ) {
42         LOG(log_error, logtype_atalkd, "aep sendto: %s", strerror(errno) );
43         return 1;
44     }
45
46     return 0;
47 }