The reconcile package is used for DOM reconcilation in Isomorphic Go web applications.

dstunreach.go 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2014 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package icmp
  5. // A DstUnreach represents an ICMP destination unreachable message
  6. // body.
  7. type DstUnreach struct {
  8. Data []byte // data, known as original datagram field
  9. Extensions []Extension // extensions
  10. }
  11. // Len implements the Len method of MessageBody interface.
  12. func (p *DstUnreach) Len(proto int) int {
  13. if p == nil {
  14. return 0
  15. }
  16. l, _ := multipartMessageBodyDataLen(proto, p.Data, p.Extensions)
  17. return 4 + l
  18. }
  19. // Marshal implements the Marshal method of MessageBody interface.
  20. func (p *DstUnreach) Marshal(proto int) ([]byte, error) {
  21. return marshalMultipartMessageBody(proto, p.Data, p.Extensions)
  22. }
  23. // parseDstUnreach parses b as an ICMP destination unreachable message
  24. // body.
  25. func parseDstUnreach(proto int, b []byte) (MessageBody, error) {
  26. if len(b) < 4 {
  27. return nil, errMessageTooShort
  28. }
  29. p := &DstUnreach{}
  30. var err error
  31. p.Data, p.Extensions, err = parseMultipartMessageBody(proto, b)
  32. if err != nil {
  33. return nil, err
  34. }
  35. return p, nil
  36. }