third_party/virtualbox/src/VBox/Devices/Network/DevE1000.cpp
/**
 * Compute and write internet checksum (e1kCSum16) at the specified offset.
 *
 * @param   pThis       The device state structure.
 * @param   pPkt        Pointer to the packet.
 * @param   u16PktLen   Total length of the packet.
 * @param   cso         Offset in packet to write checksum at.
 * @param   css         Offset in packet to start computing
 *                      checksum from.
 * @param   cse         Offset in packet to stop computing
 *                      checksum at.
 * @thread  E1000_TX
 */
Compute and write internet checksum (e1kCSum16) at the specified offset.
@param   pThis       The device state structure.
@param   pPkt        Pointer to the packet.
@param   u16PktLen   Total length of the packet.
@param   cso         Offset in packet to write checksum at.
@param   css         Offset in packet to start computing
checksum from.
@param   cse         Offset in packet to stop computing
checksum at.
Compute and write internet checksum ( e1kCSum16 ) at the specified offset . @param pThis The device state structure . @param pPkt Pointer to the packet . @param u16PktLen Total length of the packet . @param cso Offset in packet to write checksum at . @param css Offset in packet to start computing checksum from . @param cse Offset in packet to stop computing checksum at .
static void e1kInsertChecksum(PE1KSTATE pThis, uint8_t *pPkt, uint16_t u16PktLen, uint8_t cso, uint8_t css, uint16_t cse)
{
    RT_NOREF1(pThis);
    if (css >= u16PktLen)
    {
        E1kLog2(("%s css(%X) is greater than packet length-1(%X), checksum is not inserted\n",
                 pThis->szPrf, cso, u16PktLen));
        return;
    }
    if (cso >= u16PktLen - 1)
    {
        E1kLog2(("%s cso(%X) is greater than packet length-2(%X), checksum is not inserted\n",
                 pThis->szPrf, cso, u16PktLen));
        return;
    }
    if (cse == 0 || cse >= u16PktLen)
        cse = u16PktLen - 1;
    else if (cse < css)
    {
        E1kLog2(("%s css(%X) is greater than cse(%X), checksum is not inserted\n",
                 pThis->szPrf, css, cse));
        return;
    }
    uint16_t u16ChkSum = e1kCSum16(pPkt + css, cse - css + 1);
    E1kLog2(("%s Inserting csum: %04X at %02X, old value: %04X\n", pThis->szPrf,
             u16ChkSum, cso, *(uint16_t*)(pPkt + cso)));
    *(uint16_t*)(pPkt + cso) = u16ChkSum;
}
static void e1kInsertChecksum ( PE1KSTATE pThis , uint8_t * pPkt , uint16_t u16PktLen , uint8_t cso , uint8_t css , uint16_t cse ) { RT_NOREF1 ( pThis ) ; if ( css >= u16PktLen ) { E1kLog2 ( ( " \n " , pThis -> szPrf , cso , u16PktLen ) ) ; return ; } if ( cso >= u16PktLen - 1 ) { E1kLog2 ( ( " \n " , pThis -> szPrf , cso , u16PktLen ) ) ; return ; } if ( cse == 0 || cse >= u16PktLen ) cse = u16PktLen - 1 ; else if ( cse < css ) { E1kLog2 ( ( " \n " , pThis -> szPrf , css , cse ) ) ; return ; } uint16_t u16ChkSum = e1kCSum16 ( pPkt + css , cse - css + 1 ) ; E1kLog2 ( ( " \n " , pThis -> szPrf , u16ChkSum , cso , * ( uint16_t * ) ( pPkt + cso ) ) ) ; * ( uint16_t * ) ( pPkt + cso ) = u16ChkSum ; }
Compute and write internet checksum (e1kCSum16) at the specified offset.
Compute and write internet checksum ( e1kCSum16 ) at the specified offset .