diff options
author | tmfkams <tmfkams@gmail.com> | 2014-02-02 19:00:45 +0100 |
---|---|---|
committer | Samuel Stauffer <samuel@descolada.com> | 2014-03-19 21:57:59 +0100 |
commit | 16e1575c86d09a0495b994341e9541a9fdfc6761 (patch) | |
tree | c3f1d00c0521f9857a3e81932ae10868b5596b3d /control.go | |
parent | SSL/TLS with certificates (diff) | |
download | ldap-16e1575c86d09a0495b994341e9541a9fdfc6761.tar ldap-16e1575c86d09a0495b994341e9541a9fdfc6761.tar.gz ldap-16e1575c86d09a0495b994341e9541a9fdfc6761.tar.bz2 ldap-16e1575c86d09a0495b994341e9541a9fdfc6761.tar.lz ldap-16e1575c86d09a0495b994341e9541a9fdfc6761.tar.xz ldap-16e1575c86d09a0495b994341e9541a9fdfc6761.tar.zst ldap-16e1575c86d09a0495b994341e9541a9fdfc6761.zip |
Diffstat (limited to '')
-rw-r--r-- | control.go | 44 |
1 files changed, 22 insertions, 22 deletions
@@ -34,14 +34,14 @@ func (c *ControlString) GetControlType() string { return c.ControlType } -func (c *ControlString) Encode() (p *ber.Packet) { - p = ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Control") - p.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimative, ber.TagOctetString, c.ControlType, "Control Type ("+ControlTypeMap[c.ControlType]+")")) +func (c *ControlString) Encode() *ber.Packet { + packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Control") + packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimative, ber.TagOctetString, c.ControlType, "Control Type ("+ControlTypeMap[c.ControlType]+")")) if c.Criticality { - p.AppendChild(ber.NewBoolean(ber.ClassUniversal, ber.TypePrimative, ber.TagBoolean, c.Criticality, "Criticality")) + packet.AppendChild(ber.NewBoolean(ber.ClassUniversal, ber.TypePrimative, ber.TagBoolean, c.Criticality, "Criticality")) } - p.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimative, ber.TagOctetString, c.ControlValue, "Control Value")) - return + packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimative, ber.TagOctetString, c.ControlValue, "Control Value")) + return packet } func (c *ControlString) String() string { @@ -57,9 +57,9 @@ func (c *ControlPaging) GetControlType() string { return ControlTypePaging } -func (c *ControlPaging) Encode() (p *ber.Packet) { - p = ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Control") - p.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimative, ber.TagOctetString, ControlTypePaging, "Control Type ("+ControlTypeMap[ControlTypePaging]+")")) +func (c *ControlPaging) Encode() *ber.Packet { + packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Control") + packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimative, ber.TagOctetString, ControlTypePaging, "Control Type ("+ControlTypeMap[ControlTypePaging]+")")) p2 := ber.Encode(ber.ClassUniversal, ber.TypePrimative, ber.TagOctetString, nil, "Control Value (Paging)") seq := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Search Control Value") @@ -70,8 +70,8 @@ func (c *ControlPaging) Encode() (p *ber.Packet) { seq.AppendChild(cookie) p2.AppendChild(seq) - p.AppendChild(p2) - return + packet.AppendChild(p2) + return packet } func (c *ControlPaging) String() string { @@ -97,16 +97,16 @@ func FindControl(Controls []Control, ControlType string) Control { return nil } -func DecodeControl(p *ber.Packet) Control { - ControlType := p.Children[0].Value.(string) +func DecodeControl(packet *ber.Packet) Control { + ControlType := packet.Children[0].Value.(string) Criticality := false - p.Children[0].Description = "Control Type (" + ControlTypeMap[ControlType] + ")" - value := p.Children[1] - if len(p.Children) == 3 { - value = p.Children[2] - p.Children[1].Description = "Criticality" - Criticality = p.Children[1].Value.(bool) + packet.Children[0].Description = "Control Type (" + ControlTypeMap[ControlType] + ")" + value := packet.Children[1] + if len(packet.Children) == 3 { + value = packet.Children[2] + packet.Children[1].Description = "Criticality" + Criticality = packet.Children[1].Value.(bool) } value.Description = "Control Value" @@ -149,9 +149,9 @@ func NewControlPaging(PagingSize uint32) *ControlPaging { } func encodeControls(Controls []Control) *ber.Packet { - p := ber.Encode(ber.ClassContext, ber.TypeConstructed, 0, nil, "Controls") + packet := ber.Encode(ber.ClassContext, ber.TypeConstructed, 0, nil, "Controls") for _, control := range Controls { - p.AppendChild(control.Encode()) + packet.AppendChild(control.Encode()) } - return p + return packet } |