Tue Dec 2 19:33:44 2014 UTC ()
- s/u_intX/uintX/
- add routines to print sockaddr_at and ataddr.


(christos)
diff -r1.7 -r1.8 src/sys/netatalk/at.h
diff -r0 -r1.1 src/sys/netatalk/at_print.c
diff -r1.1 -r1.2 src/sys/netatalk/files.netatalk

cvs diff -r1.7 -r1.8 src/sys/netatalk/at.h (expand / switch to unified diff)

--- src/sys/netatalk/at.h 2005/12/10 23:29:05 1.7
+++ src/sys/netatalk/at.h 2014/12/02 19:33:44 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: at.h,v 1.7 2005/12/10 23:29:05 elad Exp $ */ 1/* $NetBSD: at.h,v 1.8 2014/12/02 19:33:44 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1990,1991 Regents of The University of Michigan. 4 * Copyright (c) 1990,1991 Regents of The University of Michigan.
5 * All Rights Reserved. 5 * All Rights Reserved.
6 * 6 *
7 * Permission to use, copy, modify, and distribute this software and 7 * Permission to use, copy, modify, and distribute this software and
8 * its documentation for any purpose and without fee is hereby granted, 8 * its documentation for any purpose and without fee is hereby granted,
9 * provided that the above copyright notice appears in all copies and 9 * provided that the above copyright notice appears in all copies and
10 * that both that copyright notice and this permission notice appear 10 * that both that copyright notice and this permission notice appear
11 * in supporting documentation, and that the name of The University 11 * in supporting documentation, and that the name of The University
12 * of Michigan not be used in advertising or publicity pertaining to 12 * of Michigan not be used in advertising or publicity pertaining to
13 * distribution of the software without specific, written prior 13 * distribution of the software without specific, written prior
14 * permission. This software is supplied as is without expressed or 14 * permission. This software is supplied as is without expressed or
@@ -49,57 +49,65 @@ typedef __sa_family_t sa_family_t; @@ -49,57 +49,65 @@ typedef __sa_family_t sa_family_t;
49 * Port was created by a privileged process. 49 * Port was created by a privileged process.
50 * If ATPORT_RESERVED <= Port < ATPORT_LAST, 50 * If ATPORT_RESERVED <= Port < ATPORT_LAST,
51 * Port was not necessarily created by a 51 * Port was not necessarily created by a
52 * privileged process. 52 * privileged process.
53 */ 53 */
54#define ATPORT_FIRST 1 54#define ATPORT_FIRST 1
55#define ATPORT_RESERVED 128 55#define ATPORT_RESERVED 128
56#define ATPORT_LAST 255 56#define ATPORT_LAST 255
57 57
58/* 58/*
59 * AppleTalk address. 59 * AppleTalk address.
60 */ 60 */
61struct at_addr { 61struct at_addr {
62 u_int16_t s_net; 62 uint16_t s_net;
63 u_int8_t s_node; 63 uint8_t s_node;
64}; 64};
65 65
66#define ATADDR_ANYNET (u_int16_t)0x0000 66#define ATADDR_ANYNET (uint16_t)0x0000
67#define ATADDR_ANYNODE (u_int8_t)0x00 67#define ATADDR_ANYNODE (uint8_t)0x00
68#define ATADDR_ANYPORT (u_int8_t)0x00 68#define ATADDR_ANYPORT (uint8_t)0x00
69#define ATADDR_BCAST (u_int8_t)0xff /* There is no BCAST for NET */ 69#define ATADDR_BCAST (uint8_t)0xff /* There is no BCAST for NET */
70 70
71struct netrange { 71struct netrange {
72 u_int8_t nr_phase; 72 uint8_t nr_phase;
73 u_int16_t nr_firstnet; 73 uint16_t nr_firstnet;
74 u_int16_t nr_lastnet; 74 uint16_t nr_lastnet;
75}; 75};
76 76
77/* 77/*
78 * Socket address, AppleTalk style. We keep magic information in the 78 * Socket address, AppleTalk style. We keep magic information in the
79 * zero bytes. There are three types, NONE, CONFIG which has the phase 79 * zero bytes. There are three types, NONE, CONFIG which has the phase
80 * and a net range, and IFACE which has the network address of an 80 * and a net range, and IFACE which has the network address of an
81 * interface. IFACE may be filled in by the client, and is filled in 81 * interface. IFACE may be filled in by the client, and is filled in
82 * by the kernel. 82 * by the kernel.
83 */ 83 */
84struct sockaddr_at { 84struct sockaddr_at {
85 u_int8_t sat_len; 85 uint8_t sat_len;
86 sa_family_t sat_family; 86 sa_family_t sat_family;
87 u_int8_t sat_port; 87 uint8_t sat_port;
88 struct at_addr sat_addr; 88 struct at_addr sat_addr;
89 union { 89 union {
90 struct netrange r_netrange; 90 struct netrange r_netrange;
91 char r_zero[8]; /* Hide a struct netrange in 91 char r_zero[8]; /* Hide a struct netrange in
92 * here */ 92 * here */
93 } sat_range; 93 } sat_range;
94}; 94};
95 95
96#define sat_zero sat_range.r_zero 96#define sat_zero sat_range.r_zero
97 97
98#ifdef _KERNEL 98#ifdef _KERNEL
99#include <sys/protosw.h> 99#include <sys/protosw.h>
100 100
101extern struct domain atalkdomain; 101extern struct domain atalkdomain;
102extern const struct protosw atalksw[]; 102extern const struct protosw atalksw[];
103#endif 103#endif
104 104
 105#if defined(_KERNEL) || defined(_TEST)
 106#define ATALK_ADDRSTRLEN 10
 107
 108extern struct domain atalkdomain;
 109int at_print(char *, size_t, const struct at_addr *);
 110int sat_print(char *, size_t, const void *);
 111#endif
 112
105#endif /* !_NETATALK_AT_H_ */ 113#endif /* !_NETATALK_AT_H_ */

File Added: src/sys/netatalk/at_print.c
/*	$NetBSD: at_print.c,v 1.1 2014/12/02 19:33:44 christos Exp $	*/

/*-
 * Copyright (c) 2014 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
#include <sys/cdefs.h>

#include <sys/types.h>
#ifdef _KERNEL
__KERNEL_RCSID(0, "$NetBSD: at_print.c,v 1.1 2014/12/02 19:33:44 christos Exp $");
#include <sys/systm.h>
#else
__RCSID("$NetBSD: at_print.c,v 1.1 2014/12/02 19:33:44 christos Exp $");
#include <stdio.h>
#endif
#include <netatalk/at.h>

int
at_print(char *buf, size_t len, const struct at_addr *aa)
{
	return snprintf(buf, len, "%hu.%hhu", ntohs(aa->s_net), aa->s_node);
}

// XXX: netrange
int
sat_print(char *buf, size_t len, const void *v)
{
	const struct sockaddr_at *sat = v;
	const struct at_addr *aa = &sat->sat_addr;
	char abuf[ATALK_ADDRSTRLEN];

	if (!sat->sat_port)
		return at_print(buf, len, aa);

	at_print(abuf, sizeof(abuf), aa);
	return snprintf(buf, len, "%s:%hhu", abuf, sat->sat_port);
}

cvs diff -r1.1 -r1.2 src/sys/netatalk/files.netatalk (expand / switch to unified diff)

--- src/sys/netatalk/files.netatalk 2002/10/10 22:10:53 1.1
+++ src/sys/netatalk/files.netatalk 2014/12/02 19:33:44 1.2
@@ -1,11 +1,12 @@ @@ -1,11 +1,12 @@
1# $NetBSD: files.netatalk,v 1.1 2002/10/10 22:10:53 thorpej Exp $ 1# $NetBSD: files.netatalk,v 1.2 2014/12/02 19:33:44 christos Exp $
2 2
3defflag opt_atalk.h NETATALK 3defflag opt_atalk.h NETATALK
4 4
5file netatalk/aarp.c netatalk 5file netatalk/aarp.c netatalk
6file netatalk/at_control.c netatalk 6file netatalk/at_control.c netatalk
 7file netatalk/at_print.c
7file netatalk/at_proto.c netatalk 8file netatalk/at_proto.c netatalk
8file netatalk/at_rmx.c netatalkdebug 9file netatalk/at_rmx.c netatalkdebug
9file netatalk/ddp_input.c netatalk 10file netatalk/ddp_input.c netatalk
10file netatalk/ddp_output.c netatalk 11file netatalk/ddp_output.c netatalk
11file netatalk/ddp_usrreq.c netatalk 12file netatalk/ddp_usrreq.c netatalk