From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e2be1c8e99a1c994 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local02.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 13 Sep 2008 01:21:38 -0500 From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Adding offset to 'Address References: X-Newsreader: Tom's custom newsreader Message-ID: Date: Sat, 13 Sep 2008 01:21:38 -0500 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 71.202.183.17 X-Trace: sv3-BfP/pqJio9iEQvWIPkc6Y0EaOjXUSw0bM/r0bw/qsD54G+Bs+crBv3+tH0OO7A7pGhb8Yk7wjzrwA0F!7Lp+wkCl2WSgGGIJ2yFPdor0atcChgBev1a9cbl2pAcILmvMSOFV9FJNzqw7J8LA17+7010myFh/!HXtsDGegJr9KMhHjY9vpQwNVFgs0jw== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.39 Xref: g2news1.google.com comp.lang.ada:2010 Date: 2008-09-13T01:21:38-05:00 List-Id: > Raw_Bytes : access Unsigned_Char > for Ethernet_Header'Address use Raw_Bytes.all'Address; > >and additionally need something like: > for IP_Packet'Address use Raw_Bytes.all'Address + Ethernet_Header'Size; It's not clear to me exactly what problem you are trying to get past. How about something like: with Ada.Unchecked_Conversion, Interfaces.C; procedure Eiptest is type Ethernet_Header_Type is new Integer; -- or whatever type IP_Packet_Type is array (1 .. 5) of Integer; -- " type R_Type is record Ethernet_Header: Ethernet_Header_Type; IP_Packet: IP_Packet_Type; Other_Stuff : Integer; end record; for R_Type use record Ethernet_Header at 0 range 0 .. 31; IP_Packet at 4 range 0 .. 159; Other_Stuff at 30 range 0 .. 31; end record; type Lpvoid is access all Interfaces.C.Char; type R_Ptr_Type is access all R_Type; function Convert is new Ada.Unchecked_Conversion (Source => Lpvoid, Target => R_Ptr_Type); procedure Process(Raw_Bytes: in Lpvoid) is R_Ptr : constant R_Ptr_Type := Convert(Raw_Bytes); This_IP_Packet: IP_Packet_Type renames R_Ptr.IP_Packet; begin null; -- do something with This_IP_Packet end Process; Buffer : Interfaces.C.Char_Array(1 .. 100); begin Process(Buffer(1)'access); end Eiptest;