| 381 | } |
| 382 | |
| 383 | func calculatePaddingSize(packetSize, mtu int) int { |
| 384 | lastUnit := packetSize |
| 385 | if mtu == 0 { |
| 386 | return ((lastUnit + PaddingMultiple - 1) & ^(PaddingMultiple - 1)) - lastUnit |
| 387 | } |
| 388 | if lastUnit > mtu { |
| 389 | lastUnit %= mtu |
| 390 | } |
| 391 | paddedSize := ((lastUnit + PaddingMultiple - 1) & ^(PaddingMultiple - 1)) |
| 392 | if paddedSize > mtu { |
| 393 | paddedSize = mtu |
| 394 | } |
| 395 | return paddedSize - lastUnit |
| 396 | } |
| 397 | |
| 398 | /* Encrypts the elements in the queue |
| 399 | * and marks them for sequential consumption (by releasing the mutex) |