forked from andig/gosml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopen_request.go
50 lines (39 loc) · 1015 Bytes
/
open_request.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package sml
type OpenRequest struct {
Codepage OctetString // optional
ClientID OctetString
ReqFileID OctetString
ServerID OctetString // optional
Username OctetString // optional
Password OctetString // optional
Version uint8 // optional
}
func OpenRequestParse(buf *Buffer) (OpenRequest, error) {
msg := OpenRequest{}
var err error
if err := Expect(buf, TYPELIST, 7); err != nil {
return msg, err
}
if msg.Codepage, err = OctetStringParse(buf); err != nil {
return msg, err
}
if msg.ClientID, err = OctetStringParse(buf); err != nil {
return msg, err
}
if msg.ReqFileID, err = OctetStringParse(buf); err != nil {
return msg, err
}
if msg.ServerID, err = OctetStringParse(buf); err != nil {
return msg, err
}
if msg.Username, err = OctetStringParse(buf); err != nil {
return msg, err
}
if msg.Password, err = OctetStringParse(buf); err != nil {
return msg, err
}
if msg.Version, err = U8Parse(buf); err != nil {
return msg, err
}
return msg, nil
}