(self, pkt)
| 195 | return self.sock.session |
| 196 | |
| 197 | def send(self, pkt): |
| 198 | # Calculate what CreditCharge to send. |
| 199 | if self.session.Dialect > 0x0202 and isinstance(pkt.payload, SMB2_Header): |
| 200 | # [MS-SMB2] sect 3.2.4.1.5 |
| 201 | typ = type(pkt.payload.payload) |
| 202 | if typ is SMB2_Negotiate_Protocol_Request: |
| 203 | # See [MS-SMB2] 3.2.4.1.2 note |
| 204 | pkt.CreditCharge = 0 |
| 205 | elif typ in [ |
| 206 | SMB2_Read_Request, |
| 207 | SMB2_Write_Request, |
| 208 | SMB2_IOCTL_Request, |
| 209 | SMB2_Query_Directory_Request, |
| 210 | SMB2_Change_Notify_Request, |
| 211 | SMB2_Query_Info_Request, |
| 212 | ]: |
| 213 | # [MS-SMB2] 3.1.5.2 |
| 214 | # "For READ, WRITE, IOCTL, and QUERY_DIRECTORY requests" |
| 215 | # "CHANGE_NOTIFY, QUERY_INFO, or SET_INFO" |
| 216 | if typ == SMB2_Read_Request: |
| 217 | Length = pkt.payload.Length |
| 218 | elif typ == SMB2_Write_Request: |
| 219 | Length = len(pkt.payload.Data) |
| 220 | elif typ == SMB2_IOCTL_Request: |
| 221 | # [MS-SMB2] 3.3.5.15 |
| 222 | Length = max(len(pkt.payload.Input), pkt.payload.MaxOutputResponse) |
| 223 | elif typ in [ |
| 224 | SMB2_Query_Directory_Request, |
| 225 | SMB2_Change_Notify_Request, |
| 226 | SMB2_Query_Info_Request, |
| 227 | ]: |
| 228 | Length = pkt.payload.OutputBufferLength |
| 229 | else: |
| 230 | raise RuntimeError("impossible case") |
| 231 | pkt.CreditCharge = 1 + (Length - 1) // 65536 |
| 232 | else: |
| 233 | # "For all other requests, the client MUST set CreditCharge to 1" |
| 234 | pkt.CreditCharge = 1 |
| 235 | # [MS-SMB2] 3.2.4.1.2 |
| 236 | pkt.CreditRequest = pkt.CreditCharge + 1 # this code is a bit lazy |
| 237 | # Get first available message ID: [MS-SMB2] 3.2.4.1.3 and 3.2.4.1.5 |
| 238 | pkt.MID = self.SequenceWindow[0] |
| 239 | return super(SMB_Client, self).send(pkt) |
| 240 | |
| 241 | @ATMT.state(initial=1) |
| 242 | def BEGIN(self): |
no outgoing calls
no test coverage detected