~allenap/gotftp/trunk

« back to all changes in this revision

Viewing changes to packets.go

  • Committer: Gavin Panella
  • Date: 2013-08-24 16:30:33 UTC
  • Revision ID: gavin@gromper.net-20130824163033-fxxcbku3u24gwlux
New function readErrCode(); use constants to help skipping.

Show diffs side-by-side

added added

removed removed

Lines of Context:
116
116
        Block uint16
117
117
}
118
118
 
119
 
func (ack *ACK) FromWire(data []byte) {
120
 
        _, data = readOpCode(data)
121
 
        binary.Read(bytes.NewReader(data), binary.BigEndian, &ack.Block)
 
119
func (ack *ACK) FromWire(buf []byte) {
 
120
        _, buf = readOpCode(buf)
 
121
        binary.Read(bytes.NewReader(buf), binary.BigEndian, &ack.Block)
122
122
}
123
123
 
124
124
func (ack *ACK) ToWire() []byte {
150
150
        Message string
151
151
}
152
152
 
153
 
func (error *ERROR) FromWire(data []byte) {
154
 
        _, data = readOpCode(data)
155
 
        binary.Read(bytes.NewReader(data), binary.BigEndian, &error.Code)
156
 
        error.Message, data = readString(data[2:])
 
153
func (error *ERROR) FromWire(buf []byte) {
 
154
        _, buf = readOpCode(buf)
 
155
        error.Code, buf = readErrCode(buf)
 
156
        error.Message, _ = readString(buf)
157
157
}
158
158
 
159
159
func (error *ERROR) ToWire() []byte {