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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ded6ba3fc5b87b66 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-10-24 20:50:28 PST Path: supernews.google.com!sn-xit-02!sn-xit-03!supernews.com!europa.netcrusader.net!205.252.116.205!howland.erols.net!newshub2.home.com!news.home.com!news1.rdc1.ab.home.com.POSTED!not-for-mail Newsgroups: comp.lang.ada Subject: First time Ada has let me down From: avlogue@home.com (Shifty) Organization: yeah, right Message-ID: <8FD7DEBEEsynoptikdamudderfuck@news> User-Agent: Xnews/2.06.20 Date: Wed, 25 Oct 2000 03:50:28 GMT NNTP-Posting-Host: 24.67.75.188 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.ab.home.com 972445828 24.67.75.188 (Tue, 24 Oct 2000 20:50:28 PDT) NNTP-Posting-Date: Tue, 24 Oct 2000 20:50:28 PDT Xref: supernews.google.com comp.lang.ada:1534 Date: 2000-10-25T03:50:28+00:00 List-Id: OK, here's the story: I had a problem at work where I needed to calculate the offset of a "magic number" within a buffer containing an IP datagram. The magic number is 3 protocol headers deep within the datagram, and all three headers are variable length. I needed to find the HLEN fields of the IP and TCP headers in memory. Turns out both of these are stored in 4 bits. The data in the other 4 bits of the octet belong to another field in the header. This stumped me for awhile, but then I went home and picked up a C book. Hmmm, chapter 15 - bit fiddling. I learned a bunch of stuff about masks and bitwise operators and came up with a working solution. (which seems much better than using record representation clauses and typecasting a 4 bit value into an 8 bit integer) Next morning I tried to implement the solution and couldn't find the Ada equivalent of C's bit-wise & operater. According to my "Ada as a 2nd language" book, the Ada reserved word "AND" only works for boolean types, not integer types. I got the impression that it was up to the programmer to write his own bitwise ANDs/ORs/XORs, etc (it wouldn't be hard). Luckily I found a vendor-supplied package which provided this functionality, but I can't believe Ada (83) doesn't have native language support for these!!! Please tell me that I am hopelessly confused and dead wrong! Cheers, Andrew.