From owner-freebsd-net@FreeBSD.ORG Tue Mar 30 11:25:35 2010 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C998C106566B for ; Tue, 30 Mar 2010 11:25:35 +0000 (UTC) (envelope-from rpaulo@gmail.com) Received: from mail-bw0-f216.google.com (mail-bw0-f216.google.com [209.85.218.216]) by mx1.freebsd.org (Postfix) with ESMTP id 51D068FC08 for ; Tue, 30 Mar 2010 11:25:34 +0000 (UTC) Received: by bwz8 with SMTP id 8so5526161bwz.3 for ; Tue, 30 Mar 2010 04:25:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:subject:mime-version :content-type:from:x-priority:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=zisBkbpp/vcoTO3QMWLfDdqALYLjTV/yMkA7JQOxjwE=; b=ZFShCzd+SFplNX7ZpBf1N+F/UypUa3SKu0t/ZDiZoWbqIfPSiW/DGs6K903epdiKHl c6zih6EsNW6wTtbzj+USQUmQPeqT3PWMBWh1oH+XOnwo2Yrx+Aw7QCcbacpIYIGnpwJq BbpVaIzYD7FrqjmMkzYGQh45VYnn9xutdau8o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:subject:mime-version:content-type:from:x-priority :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to:x-mailer; b=Mwfv2bIJBGayC1qLb1OEBguO/1PfDG6nuMqjAbGYSyXgkbfjmFLr8L0jhD6e/5VcRP Tuws5CAAxZJT4obDV9iL7dHOaOWgekXKiBLci/ln6fFAYISeL4qkabstd/9lFjuXzM6e afT1xSzWUq5E80sqj/lAmX6LfdXQRxFWN3tdo= Received: by 10.204.34.206 with SMTP id m14mr1220448bkd.14.1269948333560; Tue, 30 Mar 2010 04:25:33 -0700 (PDT) Received: from [10.0.10.2] (54.81.54.77.rev.vodafone.pt [77.54.81.54]) by mx.google.com with ESMTPS id 24sm47138366bkr.18.2010.03.30.04.25.31 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 30 Mar 2010 04:25:31 -0700 (PDT) Sender: Rui Paulo Mime-Version: 1.0 (Apple Message framework v1078) Content-Type: text/plain; charset=us-ascii From: Rui Paulo X-Priority: 3 In-Reply-To: Date: Tue, 30 Mar 2010 12:25:29 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <06B53E1D-48A7-4739-9B94-CA6AC8AE902B@freebsd.org> References: To: jiani1012 X-Mailer: Apple Mail (2.1078) Cc: freebsd-net Subject: Re: space of ath_node X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Mar 2010 11:25:35 -0000 On 30 Mar 2010, at 01:58, jiani1012 wrote: > Hi,all =20 > A problem puzzled me in ath code. The following code in = function ath_node_alloc( ) shows the space allocated to an, >=20 >> struct ath_ratectrl { >> size_t arc_space; /* space required for per-node state */ >> };=20 >=20 >> const size_t space =3D sizeof(struct ath_node) + = sc->sc_rc->arc_space; >> struct ath_node *an; >> an =3D malloc(space, M_80211_NODE, M_NOWAIT|M_ZERO); >=20 > but in the two lines below ,what is (an)[1]? Where is the = initialization of (an)[1]? What does it contain? Can you show me? and = how to get the content of sn? >=20 >> struct sample_node *sn =3D ATH_NODE_SAMPLE(an); /*in sample.c*/ >> #define ATH_NODE_SAMPLE(an) ((struct sample_node *)&(an)[1]) = /*in sample.h*/ >=20 > Otherwise, the struct ath_ratectrl has been used in structures = ath_softc, sample_softc and so on. Is there any relations between them? Think about memory in the following way: an[0] .................................. an[1] ................... struct ath_node struct sample_node=20 Indexing an[1] gives the address past the end of struct ath_node, which = is the start address of struct sample_node. -- Rui Paulo