| 409 | |
| 410 | /* Returns the number of records not successfully rendered. */ |
| 411 | private int |
| 412 | sectionToWire(DNSOutput out, int section, Compression c, |
| 413 | int maxLength) |
| 414 | { |
| 415 | int n = sections[section].size(); |
| 416 | int pos = out.current(); |
| 417 | int rendered = 0; |
| 418 | int skipped = 0; |
| 419 | Record lastrec = null; |
| 420 | |
| 421 | for (int i = 0; i < n; i++) { |
| 422 | Record rec = (Record)sections[section].get(i); |
| 423 | if (section == Section.ADDITIONAL && rec instanceof OPTRecord) { |
| 424 | skipped++; |
| 425 | continue; |
| 426 | } |
| 427 | |
| 428 | if (lastrec != null && !sameSet(rec, lastrec)) { |
| 429 | pos = out.current(); |
| 430 | rendered = i; |
| 431 | } |
| 432 | lastrec = rec; |
| 433 | rec.toWire(out, section, c); |
| 434 | if (out.current() > maxLength) { |
| 435 | out.jump(pos); |
| 436 | return n - rendered + skipped; |
| 437 | } |
| 438 | } |
| 439 | return skipped; |
| 440 | } |
| 441 | |
| 442 | /* Returns true if the message could be rendered. */ |
| 443 | private boolean |