summaryrefslogtreecommitdiffstats
path: root/control.go
diff options
context:
space:
mode:
authortmfkams <tmfkams@gmail.com>2014-02-02 19:00:45 +0100
committerSamuel Stauffer <samuel@descolada.com>2014-03-19 21:57:59 +0100
commit16e1575c86d09a0495b994341e9541a9fdfc6761 (patch)
treec3f1d00c0521f9857a3e81932ae10868b5596b3d /control.go
parentSSL/TLS with certificates (diff)
downloadldap-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.go44
1 files changed, 22 insertions, 22 deletions
diff --git a/control.go b/control.go
index cada47a..19f5bc2 100644
--- a/control.go
+++ b/control.go
@@ -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
}