hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 73ae82e5eb1de4c49ab029cebe20328f3698c57e
parent f2873c1209e462c5829d4bd2e215261f25a8e6e5
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed, 23 Jun 2021 12:47:03 -0400

net::dns: decode_op/encode_op style fix

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mnet/dns/decode.ha | 4++--
Mnet/dns/encode.ha | 4++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/dns/decode.ha b/net/dns/decode.ha @@ -66,14 +66,14 @@ fn decode_u32(dec: *decoder) (u32 | format) = { fn decode_header(dec: *decoder, head: *header) (void | format) = { head.id = decode_u16(dec)?; let rawop = decode_u16(dec)?; - op_decode(rawop, &head.op); + decode_op(rawop, &head.op); head.qdcount = decode_u16(dec)?; head.ancount = decode_u16(dec)?; head.nscount = decode_u16(dec)?; head.arcount = decode_u16(dec)?; }; -fn op_decode(in: u16, out: *op) void = { +fn decode_op(in: u16, out: *op) void = { out.qr = ((in & 0b1000000000000000) >> 15): qr; out.opcode = ((in & 0b01111000000000u16) >> 11): opcode; out.aa = in & 0b0000010000000000u16 != 0; diff --git a/net/dns/encode.ha b/net/dns/encode.ha @@ -22,7 +22,7 @@ export fn unparse_domain(in: []str) str = strings::join(".", in...); export fn encode(buf: []u8, msg: *message) (size | error) = { let enc = encoder { buf = buf, offs = 0z }; encode_u16(&enc, msg.header.id)?; - encode_u16(&enc, op_encode(&msg.header.op))?; + encode_u16(&enc, encode_op(&msg.header.op))?; encode_u16(&enc, msg.header.qdcount)?; encode_u16(&enc, msg.header.ancount)?; encode_u16(&enc, msg.header.nscount)?; @@ -99,7 +99,7 @@ fn rrecord_encode(enc: *encoder, r: *rrecord) (void | error) = { abort(); // TODO }; -fn op_encode(op: *op) u16 = +fn encode_op(op: *op) u16 = (op.qr: u16 << 15u16) | (op.opcode: u16 << 11u16) | (if (op.aa) 0b0000010000000000u16 else 0u16) |