Skip to content
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

Parsing issues with mDNS packets #1

Open
francais01 opened this issue Feb 20, 2014 · 0 comments
Open

Parsing issues with mDNS packets #1

francais01 opened this issue Feb 20, 2014 · 0 comments

Comments

@francais01
Copy link

Multicast DNS packets have at least 2 characteristics which packet.js does not deal with:

  • A "reply" will not necessarily have a question, just answer RRs.
    I worked around this by adding an escape at the beginning of parseQuestion():
if (packet.header.opcode === 0 && // Standard query
  packet.header.qr === 1 && // Response
  packet.question.length === 0) { // Empty question can occur in mDNS
  return PARSE_RESOURCE_RECORD;
}
  • Some mDNS packets flying around on the network have multiple questions.
    I hacked up a quick loop in parseQuestion() and removed the assert:
var qnum = packet.question.length;
while (qnum > 0) {
  var val = {};
  val.name = nameUnpack(msg);
  val.type = msg.readUInt16BE();
  val.class = msg.readUInt16BE();
  packet.question[packet.question.length - qnum] = val;
  qnum -= 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant