-
-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add setting unicast bit #96
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1608,8 +1608,12 @@ question.encode = function (q, buf, offset) { | |
|
||
buf.writeUInt16BE(types.toType(q.type), offset) | ||
offset += 2 | ||
if (q.qu === undefined || q.qu !== true) { | ||
buf.writeUInt16BE(classes.toClass(q.class === undefined ? 'IN' : q.class), offset) | ||
} else { | ||
buf.writeUInt16BE(classes.toClass(q.class === undefined ? 'IN' : q.class) + QU_MASK, offset) | ||
} | ||
|
||
buf.writeUInt16BE(classes.toClass(q.class === undefined ? 'IN' : q.class), offset) | ||
offset += 2 | ||
|
||
question.encode.bytes = offset - oldOffset | ||
|
@@ -1630,7 +1634,14 @@ question.decode = function (buf, offset) { | |
q.type = types.toString(buf.readUInt16BE(offset)) | ||
offset += 2 | ||
|
||
q.class = classes.toString(buf.readUInt16BE(offset)) | ||
const classValue = buf.readUInt16BE(offset) | ||
if (classValue >= QU_MASK) { | ||
q.qu = true | ||
q.class = classes.toString(classValue - QU_MASK) | ||
} else { | ||
q.class = classes.toString(classValue) | ||
} | ||
|
||
offset += 2 | ||
|
||
const qu = !!(q.class & QU_MASK) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this section is still problematic (and there doesn't seem to be a test for decoding a question with the QU bit set) - if the bit is set, then we end up attempting a bitwise AND operation on the q.class string value (in line 1648 just below), which wipes out the string value (the result is 0). Thank you very much for this effort - would you mind also adding a test for the decode function? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Certainly, this change was quite some time ago. I recall this PR request occurred in 2018 or 2019. This weekend, I will take a look and make some adjustments. |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check does not make sense