Changeset 1131

Show
Ignore:
Timestamp:
05/07/08 13:03:16 (12 years ago)
Author:
ppalmers
Message:

implement endian fixes (thx Heikki Lindholm)
switch from network host order byteswap routines to size based swap routines to remove ambiguity in definition of "long"

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/bebob/bebob_dl_mgr.cpp

    r969 r1131  
    3232#include "libutil/Time.h" 
    3333 
    34 #include <netinet/in.h> 
     34#include <byteswap.h> 
    3535 
    3636#include <cstdio> 
  • trunk/libffado/src/bebob/focusrite/focusrite_cmd.cpp

    r864 r1131  
    2424#include "focusrite_cmd.h" 
    2525 
    26 #include <netinet/in.h> 
     26#include <byteswap.h> 
    2727#include <iostream> 
    2828 
     
    5454    result &= se.write(m_arg1,"FocusriteVendorDependentCmd arg1"); 
    5555    result &= se.write(m_arg2,"FocusriteVendorDependentCmd arg2"); 
    56     // FIXME: this is not consistent, we should not have to care about ntohl here 
    57     result &= se.write(htonl(m_id),"FocusriteVendorDependentCmd ID"); 
    58     result &= se.write(htonl(m_value),"FocusriteVendorDependentCmd value"); 
     56    // FIXME: this is not consistent, we should not have to care about bswap_32 here 
     57    result &= se.write(bswap_32(m_id),"FocusriteVendorDependentCmd ID"); 
     58    result &= se.write(bswap_32(m_value),"FocusriteVendorDependentCmd value"); 
    5959     
    6060    return result; 
     
    6969    result &= de.read(&m_arg2); 
    7070    result &= de.read(&m_id); 
    71     m_id=ntohl(m_id); 
     71    m_id=bswap_32(m_id); 
    7272    result &= de.read(&m_value); 
    73     m_value=ntohl(m_value); 
     73    m_value=bswap_32(m_value); 
    7474 
    7575    return result; 
  • trunk/libffado/src/bebob/focusrite/focusrite_generic.cpp

    r1072 r1131  
    2525#include "focusrite_cmd.h" 
    2626 
    27 #include <netinet/in.h> 
     27#include <byteswap.h> 
    2828 
    2929namespace BeBoB { 
     
    140140    fb_nodeid_t nodeId = getNodeId() | 0xFFC0; 
    141141 
    142     if(!get1394Service().write_quadlet( nodeId, addr, htonl(data) ) ) { 
     142    if(!get1394Service().write_quadlet( nodeId, addr, bswap_32(data) ) ) { 
    143143        debugError("Could not write to node 0x%04X addr 0x%012X\n", nodeId, addr); 
    144144        return false; 
     
    161161    } 
    162162 
    163     result=ntohl(result); 
     163    result=bswap_32(result); 
    164164    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Read result: 0x%08llX\n", result); 
    165165 
  • trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.cpp

    r1107 r1131  
    2828#include "libutil/Time.h" 
    2929 
    30 #include <netinet/in.h> 
     30#include <byteswap.h> 
    3131 
    3232namespace BeBoB { 
     
    757757        char *ptr = (char *) &name[i*4]; 
    758758        tmp = *((uint32_t *)ptr); 
    759         tmp = htonl(tmp); 
     759        tmp = bswap_32(tmp); 
    760760        if ( !setSpecificValue(FR_SAFFIREPRO_CMD_ID_DEVICE_NAME_1 + i, tmp ) ) { 
    761761            debugError( "setSpecificValue failed\n" ); 
     
    776776            return ""; 
    777777        } 
    778         tmp = ntohl(tmp); 
     778        tmp = bswap_32(tmp); 
    779779        unsigned int j; 
    780780        char *ptr = (char *) &tmp; 
  • trunk/libffado/src/bebob/terratec/terratec_cmd.cpp

    r864 r1131  
    2424#include "terratec_cmd.h" 
    2525 
    26 #include <netinet/in.h> 
     26#include <byteswap.h> 
    2727#include <iostream> 
    2828 
  • trunk/libffado/src/bounce/bounce_avdevice.cpp

    r969 r1131  
    4242 
    4343#include <string> 
    44 #include <netinet/in.h> 
     44#include <byteswap.h> 
    4545 
    4646namespace Bounce { 
  • trunk/libffado/src/bounce/bounce_slave_avdevice.cpp

    r864 r1131  
    367367//     { 
    368368//         if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 
    369 //         printf(" %08x", ntohl(current_rom[i])); 
     369//         printf(" %08x", bswap_32(current_rom[i])); 
    370370//     } 
    371371//     printf("\n"); 
     
    391391//     { 
    392392//         if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 
    393 //         printf(" %08x", ntohl(rom[i])); 
     393//         printf(" %08x", bswap_32(rom[i])); 
    394394//     } 
    395395//     printf("\n"); 
     
    411411//     { 
    412412//         if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 
    413 //         printf(" %08x", ntohl(rom[i])); 
     413//         printf(" %08x", bswap_32(rom[i])); 
    414414//     } 
    415415//     printf("\n"); 
     
    435435//     { 
    436436//         if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 
    437 //         printf(" %08x", ntohl(rom[i])); 
     437//         printf(" %08x", bswap_32(rom[i])); 
    438438//     } 
    439439//     printf("\n"); 
     
    449449//     { 
    450450//         if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 
    451 //         printf(" %08x", ntohl(rom[i])); 
     451//         printf(" %08x", bswap_32(rom[i])); 
    452452//     } 
    453453//     printf("\n"); 
  • trunk/libffado/src/debugmodule/debugmodule.cpp

    r1099 r1131  
    2727 
    2828#include <stdarg.h> 
    29 #include <netinet/in.h> 
     29#include <byteswap.h> 
    3030 
    3131#include <iostream> 
     
    802802    for (i = 0; i< length; i += 1) { 
    803803        printf( "%02d %04X: %08X (%08X)" 
    804                 "\n", i, i*4, data[i],ntohl(data[i])); 
    805     } 
    806 } 
    807  
    808  
     804                "\n", i, i*4, data[i],bswap_32(data[i])); 
     805    } 
     806} 
     807 
     808 
  • trunk/libffado/src/dice/dice_avdevice.cpp

    r1063 r1131  
    3232#include <string> 
    3333#include <stdint.h> 
     34#include <byteswap.h> 
    3435#include <assert.h> 
    35 #include <netinet/in.h> 
     36#include <byteswap.h> 
    3637#include <libraw1394/csr.h> 
    3738 
     
    12581259    char namestring[DICE_TX_NAMES_SIZE+1]; 
    12591260 
    1260     if (!readTxRegBlock(i, DICE_REGISTER_TX_NAMES_BASE, 
     1261    if (!readTxRegBlockSwapped(i, DICE_REGISTER_TX_NAMES_BASE, 
    12611262                        (fb_quadlet_t *)namestring, DICE_TX_NAMES_SIZE)) { 
    12621263        debugError("Could not read TX name string \n"); 
     
    12731274    char namestring[DICE_RX_NAMES_SIZE+1]; 
    12741275 
    1275     if (!readRxRegBlock(i, DICE_REGISTER_RX_NAMES_BASE, 
     1276    if (!readRxRegBlockSwapped(i, DICE_REGISTER_RX_NAMES_BASE, 
    12761277                        (fb_quadlet_t *)namestring, DICE_RX_NAMES_SIZE)) { 
    12771278        debugError("Could not read RX name string \n"); 
     
    12881289    char namestring[DICE_CLOCKSOURCENAMES_SIZE+1]; 
    12891290 
    1290     if (!readGlobalRegBlock(DICE_REGISTER_GLOBAL_CLOCKSOURCENAMES, 
    1291                         (fb_quadlet_t *)namestring, DICE_CLOCKSOURCENAMES_SIZE)) { 
     1291    if (!readGlobalRegBlockSwapped(DICE_REGISTER_GLOBAL_CLOCKSOURCENAMES, 
     1292                     (fb_quadlet_t *)namestring, DICE_CLOCKSOURCENAMES_SIZE)) { 
    12921293        debugError("Could not read CLOCKSOURCE name string \n"); 
    12931294        return names; 
     
    13021303    char namestring[DICE_NICK_NAME_SIZE+1]; 
    13031304 
    1304     if (!readGlobalRegBlock(DICE_REGISTER_GLOBAL_NICK_NAME, 
     1305    if (!readGlobalRegBlockSwapped(DICE_REGISTER_GLOBAL_NICK_NAME, 
    13051306                        (fb_quadlet_t *)namestring, DICE_NICK_NAME_SIZE)) { 
    13061307        debugError("Could not read nickname string \n"); 
     
    13171318    strncpy(namestring, name.c_str(), DICE_NICK_NAME_SIZE); 
    13181319 
    1319     if (!writeGlobalRegBlock(DICE_REGISTER_GLOBAL_NICK_NAME, 
     1320    if (!writeGlobalRegBlockSwapped(DICE_REGISTER_GLOBAL_NICK_NAME, 
    13201321                        (fb_quadlet_t *)namestring, DICE_NICK_NAME_SIZE)) { 
    13211322        debugError("Could not write nickname string \n"); 
     
    14631464    } 
    14641465 
    1465     *result=ntohl(*result); 
     1466    *result=bswap_32(*result); 
    14661467 
    14671468    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Read result: 0x%08X\n", *result); 
     
    14831484    fb_nodeid_t nodeId=getNodeId() | 0xFFC0; 
    14841485 
    1485     if(!get1394Service().write_quadlet( nodeId, addr, htonl(data) ) ) { 
     1486    if(!get1394Service().write_quadlet( nodeId, addr, bswap_32(data) ) ) { 
    14861487        debugError("Could not write to node 0x%04X addr 0x%012X\n", nodeId, addr); 
    14871488        return false; 
     
    15091510 
    15101511    for(unsigned int i=0;i<length/4;i++) { 
    1511         *(data+i)=ntohl(*(data+i)); 
     1512        *(data+i)=bswap_32(*(data+i)); 
    15121513    } 
    15131514 
     
    15311532 
    15321533    for(unsigned int i=0;i<length/4;i++) { 
    1533         data_out[i]=ntohl(*(data+i)); 
     1534        data_out[i]=bswap_32(*(data+i)); 
     1535    } 
     1536 
     1537    if(!get1394Service().write( nodeId, addr, length/4, data_out ) ) { 
     1538        debugError("Could not write to node 0x%04X addr 0x%012llX\n", nodeId, addr); 
     1539        return false; 
     1540    } 
     1541 
     1542    return true; 
     1543
     1544 
     1545bool 
     1546DiceAvDevice::readRegBlockSwapped(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 
     1547    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX, length %u\n", 
     1548        offset, length); 
     1549 
     1550    if(offset >= DICE_INVALID_OFFSET) { 
     1551        debugError("invalid offset: 0x%016llX\n", offset); 
     1552        return false; 
     1553    } 
     1554 
     1555    fb_nodeaddr_t addr=DICE_REGISTER_BASE + offset; 
     1556    fb_nodeid_t nodeId=getNodeId() | 0xFFC0; 
     1557 
     1558    if(!get1394Service().read( nodeId, addr, length/4, data ) ) { 
     1559        debugError("Could not read from node 0x%04X addr 0x%012llX\n", nodeId, addr); 
     1560        return false; 
     1561    } 
     1562 
     1563    for(unsigned int i=0;i<length/4;i++) { 
     1564        *(data+i)=bswap_32(*(data+i)); 
     1565    } 
     1566 
     1567    return true; 
     1568
     1569 
     1570bool 
     1571DiceAvDevice::writeRegBlockSwapped(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 
     1572    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, length: %u\n", 
     1573        offset, length); 
     1574 
     1575    if(offset >= DICE_INVALID_OFFSET) { 
     1576        debugError("invalid offset: 0x%016llX\n", offset); 
     1577        return false; 
     1578    } 
     1579 
     1580    fb_nodeaddr_t addr=DICE_REGISTER_BASE + offset; 
     1581    fb_nodeid_t nodeId=getNodeId() | 0xFFC0; 
     1582 
     1583    fb_quadlet_t data_out[length/4]; 
     1584 
     1585    for(unsigned int i=0;i<length/4;i++) { 
     1586        data_out[i]=bswap_32(*(data+i)); 
    15341587    } 
    15351588 
     
    15751628    fb_nodeaddr_t offset_gl=globalOffsetGen(offset, length); 
    15761629    return writeRegBlock(m_global_reg_offset + offset_gl, data, length); 
     1630} 
     1631 
     1632bool 
     1633DiceAvDevice::readGlobalRegBlockSwapped(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 
     1634    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading global register block offset 0x%04llX, length %u bytes\n", 
     1635        offset, length); 
     1636 
     1637    fb_nodeaddr_t offset_gl=globalOffsetGen(offset, length); 
     1638    return readRegBlockSwapped(m_global_reg_offset + offset_gl, data, length); 
     1639} 
     1640 
     1641bool 
     1642DiceAvDevice::writeGlobalRegBlockSwapped(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 
     1643    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing global register block offset 0x%04llX, length %u bytes\n", 
     1644        offset, length); 
     1645 
     1646    fb_nodeaddr_t offset_gl=globalOffsetGen(offset, length); 
     1647    return writeRegBlockSwapped(m_global_reg_offset + offset_gl, data, length); 
    15771648} 
    15781649 
     
    16281699    fb_nodeaddr_t offset_tx=txOffsetGen(i, offset, length); 
    16291700    return writeRegBlock(m_tx_reg_offset + offset_tx, data, length); 
     1701} 
     1702 
     1703bool 
     1704DiceAvDevice::readTxRegBlockSwapped(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 
     1705    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading rx register block offset 0x%04llX, length %u bytes\n", 
     1706        offset, length); 
     1707 
     1708    fb_nodeaddr_t offset_tx=txOffsetGen(i, offset, length); 
     1709    return readRegBlockSwapped(m_tx_reg_offset + offset_tx, data, length); 
    16301710} 
    16311711 
     
    16971777} 
    16981778 
     1779bool 
     1780DiceAvDevice::readRxRegBlockSwapped(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 
     1781    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading rx register block offset 0x%04llX, length %u bytes\n", 
     1782        offset, length); 
     1783 
     1784    fb_nodeaddr_t offset_rx=rxOffsetGen(i, offset, length); 
     1785    return readRegBlockSwapped(m_rx_reg_offset + offset_rx, data, length); 
     1786} 
     1787 
    16991788fb_nodeaddr_t 
    17001789DiceAvDevice::rxOffsetGen(unsigned int i, fb_nodeaddr_t offset, size_t length) { 
  • trunk/libffado/src/dice/dice_avdevice.h

    r1063 r1131  
    149149    bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 
    150150    bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 
     151    bool readRegBlockSwapped(fb_nodeaddr_t, fb_quadlet_t *, size_t); 
     152    bool writeRegBlockSwapped(fb_nodeaddr_t, fb_quadlet_t *, size_t); 
    151153 
    152154    bool readGlobalReg(fb_nodeaddr_t, fb_quadlet_t *); 
     
    154156    bool readGlobalRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 
    155157    bool writeGlobalRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 
     158    bool readGlobalRegBlockSwapped(fb_nodeaddr_t, fb_quadlet_t *, size_t); 
     159    bool writeGlobalRegBlockSwapped(fb_nodeaddr_t, fb_quadlet_t *, size_t); 
    156160    fb_nodeaddr_t globalOffsetGen(fb_nodeaddr_t, size_t); 
    157161 
     
    160164    bool readTxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length); 
    161165    bool writeTxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length); 
     166    bool readTxRegBlockSwapped(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length); 
    162167    fb_nodeaddr_t txOffsetGen(unsigned int, fb_nodeaddr_t, size_t); 
    163168 
     
    166171    bool readRxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length); 
    167172    bool writeRxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length); 
     173    bool readRxRegBlockSwapped(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length); 
    168174    fb_nodeaddr_t rxOffsetGen(unsigned int, fb_nodeaddr_t, size_t); 
    169175 
  • trunk/libffado/src/fireworks/efc/efc_avc_cmd.cpp

    r1011 r1131  
    2424#include "efc_avc_cmd.h" 
    2525 
    26 #include <netinet/in.h> 
     26#include <byteswap.h> 
    2727#include <iostream> 
    2828 
  • trunk/libffado/src/fireworks/efc/efc_cmd.cpp

    r969 r1131  
    2525#include "efc_cmds_hardware.h" 
    2626 
    27 #include <netinet/in.h> 
     27#include <byteswap.h> 
    2828#include <iostream> 
    2929 
     
    110110    bool result=true; 
    111111     
    112     result &= se.write(htonl(m_length), "EFC length"); 
     112    result &= se.write(bswap_32(m_length), "EFC length"); 
    113113     
    114114    unsigned int i=0; 
     
    123123    // serialize the header 
    124124    quadlet_t *header_as_quadlets=(quadlet_t *)&m_header; 
    125     result &= se.write(htonl(*(header_as_quadlets+i)), "EFC header version"); i++; 
    126     result &= se.write(htonl(*(header_as_quadlets+i)), "EFC header seqnum"); i++; 
    127     result &= se.write(htonl(*(header_as_quadlets+i)), "EFC header category"); i++; 
    128     result &= se.write(htonl(*(header_as_quadlets+i)), "EFC header command"); i++; 
    129     result &= se.write(htonl(*(header_as_quadlets+i)), "EFC header return value"); i++; 
     125    result &= se.write(bswap_32(*(header_as_quadlets+i)), "EFC header version"); i++; 
     126    result &= se.write(bswap_32(*(header_as_quadlets+i)), "EFC header seqnum"); i++; 
     127    result &= se.write(bswap_32(*(header_as_quadlets+i)), "EFC header category"); i++; 
     128    result &= se.write(bswap_32(*(header_as_quadlets+i)), "EFC header command"); i++; 
     129    result &= se.write(bswap_32(*(header_as_quadlets+i)), "EFC header return value"); i++; 
    130130     
    131131    return result; 
     
    138138     
    139139    result &= de.read(&m_length); 
    140     m_length=ntohl(m_length); 
     140    m_length=bswap_32(m_length); 
    141141     
    142142    // read the EFC header 
     
    144144    for (unsigned int i=0; i<sizeof(m_header)/4; i++) { 
    145145        result &= de.read((header_as_quadlets+i)); 
    146         *(header_as_quadlets+i)=ntohl(*(header_as_quadlets+i)); 
     146        *(header_as_quadlets+i)=bswap_32(*(header_as_quadlets+i)); 
    147147    } 
    148148 
  • trunk/libffado/src/fireworks/efc/efc_cmd.h

    r864 r1131  
    100100#define EFC_DESERIALIZE_AND_SWAP(__de__, __value__, __result__) \ 
    101101    { __result__ &= __de__.read(__value__); \ 
    102       *(__value__)=ntohl(*(__value__)); } \ 
     102      *(__value__)=bswap_32(*(__value__)); } \ 
    103103 
    104104 
  • trunk/libffado/src/fireworks/efc/efc_cmds_flash.cpp

    r1011 r1131  
    2525#include "efc_cmds_flash.h" 
    2626 
    27 #include <netinet/in.h> 
     27#include <byteswap.h> 
    2828#include <iostream> 
    2929 
     
    4848 
    4949    result &= EfcCmd::serialize ( se ); 
    50     result &= se.write(htonl(m_address), "Address" ); 
     50    result &= se.write(bswap_32(m_address), "Address" ); 
    5151 
    5252    return result; 
     
    9090    result &= EfcCmd::serialize ( se ); 
    9191 
    92     result &= se.write(htonl(m_address), "Address" ); 
    93     result &= se.write(htonl(m_nb_quadlets), "Length (quadlets)" ); 
     92    result &= se.write(bswap_32(m_address), "Address" ); 
     93    result &= se.write(bswap_32(m_nb_quadlets), "Length (quadlets)" ); 
    9494 
    9595    return result; 
     
    152152    result &= EfcCmd::serialize ( se ); 
    153153 
    154     result &= se.write(htonl(m_address), "Address" ); 
    155     result &= se.write(htonl(m_nb_quadlets), "Length (quadlets)" ); 
    156  
    157     for (unsigned int i=0; i < m_nb_quadlets; i++) { 
    158         result &= se.write(htonl(m_data[i]), "Data"); 
     154    result &= se.write(bswap_32(m_address), "Address" ); 
     155    result &= se.write(bswap_32(m_nb_quadlets), "Length (quadlets)" ); 
     156 
     157    for (unsigned int i=0; i < m_nb_quadlets; i++) { 
     158        result &= se.write(bswap_32(m_data[i]), "Data"); 
    159159    } 
    160160    return result; 
     
    200200 
    201201    result &= EfcCmd::serialize ( se ); 
    202     result &= se.write(htonl(m_lock), "Locked" ); 
     202    result &= se.write(bswap_32(m_lock), "Locked" ); 
    203203 
    204204    return result; 
  • trunk/libffado/src/fireworks/efc/efc_cmds_hardware.cpp

    r864 r1131  
    2424#include "efc_cmds_hardware.h" 
    2525 
    26 #include <netinet/in.h> 
     26#include <byteswap.h> 
    2727#include <iostream> 
    2828 
  • trunk/libffado/src/fireworks/efc/efc_cmds_hardware_ctrl.cpp

    r864 r1131  
    2525#include "efc_cmds_hardware_ctrl.h" 
    2626 
    27 #include <netinet/in.h> 
     27#include <byteswap.h> 
    2828#include <iostream> 
    2929 
     
    9898    result &= EfcCmd::serialize ( se ); 
    9999 
    100     result &= se.write(htonl(m_clock), "Clock" ); 
    101     result &= se.write(htonl(m_samplerate), "Samplerate" ); 
    102     result &= se.write(htonl(m_index), "Index" ); 
     100    result &= se.write(bswap_32(m_clock), "Clock" ); 
     101    result &= se.write(bswap_32(m_samplerate), "Samplerate" ); 
     102    result &= se.write(bswap_32(m_index), "Index" ); 
    103103 
    104104    return result; 
  • trunk/libffado/src/fireworks/efc/efc_cmds_ioconfig.cpp

    r864 r1131  
    2525#include "efc_cmds_ioconfig.h" 
    2626 
    27 #include <netinet/in.h> 
     27#include <byteswap.h> 
    2828#include <iostream> 
    2929 
     
    6060        result &= EfcCmd::serialize ( se ); 
    6161 
    62         result &= se.write(htonl(m_value), "Value" ); 
     62        result &= se.write(bswap_32(m_value), "Value" ); 
    6363    } 
    6464    return result; 
  • trunk/libffado/src/fireworks/efc/efc_cmds_mixer.cpp

    r864 r1131  
    2525#include "efc_cmds_mixer.h" 
    2626 
    27 #include <netinet/in.h> 
     27#include <byteswap.h> 
    2828#include <iostream> 
    2929 
     
    7373        result &= EfcCmd::serialize ( se ); 
    7474         
    75         result &= se.write(htonl(m_channel), "Channel" ); 
     75        result &= se.write(bswap_32(m_channel), "Channel" ); 
    7676         
    7777    } else { 
     
    8282        result &= EfcCmd::serialize ( se ); 
    8383         
    84         result &= se.write(htonl(m_channel), "Channel" ); 
    85         result &= se.write(htonl(m_value), "Value" ); 
     84        result &= se.write(bswap_32(m_channel), "Channel" ); 
     85        result &= se.write(bswap_32(m_value), "Value" ); 
    8686    } 
    8787 
  • trunk/libffado/src/fireworks/efc/efc_cmds_monitor.cpp

    r864 r1131  
    2525#include "efc_cmds_monitor.h" 
    2626 
    27 #include <netinet/in.h> 
     27#include <byteswap.h> 
    2828#include <iostream> 
    2929 
     
    106106        result &= EfcCmd::serialize ( se ); 
    107107         
    108         result &= se.write(htonl(m_input), "Input" ); 
    109         result &= se.write(htonl(m_output), "Output" ); 
     108        result &= se.write(bswap_32(m_input), "Input" ); 
     109        result &= se.write(bswap_32(m_output), "Output" ); 
    110110         
    111111    } else { 
     
    116116        result &= EfcCmd::serialize ( se ); 
    117117         
    118         result &= se.write(htonl(m_input), "Input" ); 
    119         result &= se.write(htonl(m_output), "Output" ); 
    120         result &= se.write(htonl(m_value), "Value" ); 
     118        result &= se.write(bswap_32(m_input), "Input" ); 
     119        result &= se.write(bswap_32(m_output), "Output" ); 
     120        result &= se.write(bswap_32(m_value), "Value" ); 
    121121    } 
    122122    return result; 
  • trunk/libffado/src/genericavc/avc_avdevice.cpp

    r1110 r1131  
    3939#include <stdint.h> 
    4040#include <assert.h> 
    41 #include <netinet/in.h> 
     41#include <byteswap.h> 
    4242#include <iostream> 
    4343#include <sstream> 
  • trunk/libffado/src/libavc/ccm/avc_signal_source.cpp

    r864 r1131  
    2626#include "libieee1394/ieee1394service.h" 
    2727 
    28 #include <netinet/in.h> 
     28#include <byteswap.h> 
    2929#include <iostream> 
    3030 
  • trunk/libffado/src/libavc/descriptors/avc_descriptor_cmd.cpp

    r969 r1131  
    2828#include "libieee1394/ieee1394service.h" 
    2929 
    30 #include <netinet/in.h> 
     30#include <byteswap.h> 
    3131#include <iostream> 
    3232 
  • trunk/libffado/src/libavc/general/avc_connect.cpp

    r864 r1131  
    2626#include "libieee1394/ieee1394service.h" 
    2727 
    28 #include <netinet/in.h> 
     28#include <byteswap.h> 
    2929#include <iostream> 
    3030 
  • trunk/libffado/src/libavc/general/avc_extended_plug_info.cpp

    r864 r1131  
    2626#include "libieee1394/ieee1394service.h" 
    2727 
    28 #include <netinet/in.h> 
     28#include <byteswap.h> 
    2929#include <iostream> 
    3030 
  • trunk/libffado/src/libavc/general/avc_extended_subunit_info.cpp

    r864 r1131  
    2626#include "libieee1394/ieee1394service.h" 
    2727 
    28 #include <netinet/in.h> 
     28#include <byteswap.h> 
    2929 
    3030#define NR_OF_PAGE_DATA 5 
  • trunk/libffado/src/libavc/general/avc_generic.cpp

    r864 r1131  
    3030#include "libutil/Time.h" 
    3131 
    32 #include <netinet/in.h> 
     32#include <byteswap.h> 
    3333 
    3434#define DEBUG_EXTRA_VERBOSE 5 
  • trunk/libffado/src/libavc/general/avc_plug_info.cpp

    r864 r1131  
    2626#include "libieee1394/ieee1394service.h" 
    2727 
    28 #include <netinet/in.h> 
     28#include <byteswap.h> 
    2929#include <iostream> 
    3030 
  • trunk/libffado/src/libavc/general/avc_signal_format.cpp

    r864 r1131  
    2626#include "libieee1394/ieee1394service.h" 
    2727 
    28 #include <netinet/in.h> 
     28#include <byteswap.h> 
    2929#include <iostream> 
    3030 
  • trunk/libffado/src/libavc/general/avc_subunit_info.cpp

    r864 r1131  
    2626#include "libieee1394/ieee1394service.h" 
    2727 
    28 #include <netinet/in.h> 
     28#include <byteswap.h> 
    2929#include <iostream> 
    3030 
  • trunk/libffado/src/libavc/general/avc_unit_info.cpp

    r864 r1131  
    2626#include "libieee1394/ieee1394service.h" 
    2727 
    28 #include <netinet/in.h> 
     28#include <byteswap.h> 
    2929#include <iostream> 
    3030 
  • trunk/libffado/src/libavc/general/avc_vendor_dependent_cmd.cpp

    r864 r1131  
    2626#include "libieee1394/ieee1394service.h" 
    2727 
    28 #include <netinet/in.h> 
     28#include <byteswap.h> 
    2929#include <iostream> 
    3030 
  • trunk/libffado/src/libavc/musicsubunit/avc_descriptor_music.cpp

    r1042 r1131  
    3333#include "../general/avc_unit.h" 
    3434 
    35 #include <netinet/in.h> 
     35#include <byteswap.h> 
    3636 
    3737// info block implementations 
     
    5353    result &= AVCInfoBlock::serialize(se); 
    5454     
    55     quadlet_t tmp=htonl(m_current_latency_capability); 
     55    quadlet_t tmp=bswap_32(m_current_latency_capability); 
    5656     
    5757    result &= se.write(m_current_transmit_capability, "AVCMusicGeneralStatusInfoBlock m_current_transmit_capability"); 
     
    7575    result &= de.read(&m_current_receive_capability); 
    7676    result &= de.read(&m_current_latency_capability); 
    77     m_current_latency_capability=ntohl(m_current_latency_capability); 
     77    m_current_latency_capability=bswap_32(m_current_latency_capability); 
    7878     
    7979    return result; 
  • trunk/libffado/src/libavc/streamformat/avc_extended_stream_format.cpp

    r864 r1131  
    2626#include "libieee1394/ieee1394service.h" 
    2727 
    28 #include <netinet/in.h> 
     28#include <byteswap.h> 
    2929 
    3030namespace AVC { 
  • trunk/libffado/src/libieee1394/ARMHandler.h

    r864 r1131  
    6464 
    6565    nodeaddr_t getStart() {return m_start;}; 
    66     nodeaddr_t getLength() {return m_length;}; 
     66    size_t getLength() {return m_length;}; 
    6767    unsigned int getAccessRights() {return m_access_rights;}; 
    6868    unsigned int getNotificationOptions() {return m_notification_options;}; 
  • trunk/libffado/src/libieee1394/ieee1394service.cpp

    r1046 r1131  
    3939 
    4040#include <errno.h> 
    41 #include <netinet/in.h> 
     41#include <byteswap.h> 
    4242 
    4343#include <string.h> 
     
    388388                CSR_REGISTER_BASE | CSR_CYCLE_TIME, 
    389389                sizeof(uint32_t), cycle_timer ) == 0 ) { 
    390             *cycle_timer = ntohl(*cycle_timer); 
     390            *cycle_timer = bswap_32(*cycle_timer); 
    391391            return true; 
    392392        } else { 
     
    479479    return write( nodeId, addr, sizeof( data )/4, 
    480480                  reinterpret_cast<fb_quadlet_t*>( &data ) ); 
    481 } 
    482  
    483 fb_octlet_t 
    484 Ieee1394Service::byteSwap_octlet(fb_octlet_t value) { 
    485     #if __BYTE_ORDER == __BIG_ENDIAN 
    486         return value; 
    487     #elif __BYTE_ORDER == __LITTLE_ENDIAN 
    488         fb_quadlet_t in_hi = (value >> 32) & 0xFFFFFFFF; 
    489         fb_quadlet_t in_lo = value & 0xFFFFFFFF; 
    490         in_hi = htonl(in_hi); 
    491         in_lo = htonl(in_lo); 
    492         fb_octlet_t value_new = in_lo; 
    493         value_new <<= 32; 
    494         value_new |= in_hi; 
    495         return value_new; 
    496     #else 
    497         #error Unknown endiannes 
    498     #endif 
    499481} 
    500482 
     
    520502 
    521503    // do endiannes swapping 
    522     compare_value = byteSwap_octlet(compare_value); 
    523     swap_value    = byteSwap_octlet(swap_value); 
     504    compare_value = bswap_64(compare_value); 
     505    swap_value    = bswap_64(swap_value); 
    524506 
    525507    // do separate locking here (no MutexLockHelper) since  
     
    543525    #endif 
    544526 
    545     *result = byteSwap_octlet(*result); 
     527    *result = bswap_64(*result); 
    546528 
    547529    return (retval == 0); 
     
    557539    m_handle_lock->Lock(); 
    558540    for (int i = 0; i < len; ++i) { 
    559         buf[i] = ntohl( buf[i] ); 
     541        buf[i] = bswap_32( buf[i] ); 
    560542    } 
    561543 
     
    569551 
    570552    for ( unsigned int i = 0; i < *resp_len; ++i ) { 
    571         result[i] = htonl( result[i] ); 
     553        result[i] = bswap_32( result[i] ); 
    572554    } 
    573555 
     
    11141096    if (result < 0) 
    11151097        return -1; 
    1116     return ntohl(buffer); 
     1098    return bswap_32(buffer); 
    11171099} 
    11181100 
  • trunk/libffado/src/libieee1394/ieee1394service.h

    r1044 r1131  
    345345    arm_handler_vec_t m_armHandlers; 
    346346 
    347     fb_octlet_t byteSwap_octlet(fb_octlet_t value); 
    348  
    349347public: 
    350348    void setVerboseLevel(int l); 
  • trunk/libffado/src/libieee1394/IsoHandler.cpp

    r1090 r1131  
    3434 
    3535#include <errno.h> 
    36 #include <netinet/in.h> 
     36#include <byteswap.h> 
    3737#include <assert.h> 
    3838#include <unistd.h> 
  • trunk/libffado/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp

    r1037 r1131  
    3232#include "libieee1394/cycletimer.h" 
    3333 
    34 #include <netinet/in.h> 
     34#include <byteswap.h> 
    3535#include <assert.h> 
    3636 
     
    102102              (length >= 2*sizeof(quadlet_t)); 
    103103    if(ok) { 
    104         m_last_timestamp = sytRecvToFullTicks2((uint32_t)ntohs(packet->syt), pkt_ctr); 
     104        m_last_timestamp = sytRecvToFullTicks2((uint32_t)bswap_16(packet->syt), pkt_ctr); 
    105105        //#ifdef DEBUG 
    106106        #if 0 
     
    108108 
    109109        //=> convert the SYT to a full timestamp in ticks 
    110         uint64_t old_last_timestamp = sytRecvToFullTicks((uint32_t)ntohs(packet->syt), 
     110        uint64_t old_last_timestamp = sytRecvToFullTicks((uint32_t)bswap_16(packet->syt), 
    111111                                              CYCLE_TIMER_GET_CYCLES(pkt_ctr), now); 
    112112        if(m_last_timestamp != old_last_timestamp) { 
     
    224224 
    225225            for(j = 0; j < nevents; j += 1) { 
    226                 *(buffer)=(ntohl((*target_event) ) & 0x00FFFFFF); 
     226                *(buffer)=(bswap_32((*target_event) ) & 0x00FFFFFF); 
    227227                buffer++; 
    228228                target_event+=m_dimension; 
     
    258258 
    259259            for(j = 0; j < nevents; j += 1) { 
    260                 unsigned int v = ntohl(*target_event) & 0x00FFFFFF; 
     260                unsigned int v = bswap_32(*target_event) & 0x00FFFFFF; 
    261261                // sign-extend highest bit of 24-bit int 
    262262                int tmp = (int)(v << 8) / 256; 
     
    295295 
    296296            for(j = 0; j < nevents; j += 1) { 
    297                 *(buffer)=(ntohl((*target_event) ) & 0x00FFFFFF); 
     297                *(buffer)=(bswap_32((*target_event) ) & 0x00FFFFFF); 
    298298                buffer++; 
    299299                target_event+=m_dimension; 
     
    329329 
    330330            for(j = 0; j < nevents; j += 1) { 
    331                 unsigned int v = ntohl(*target_event) & 0x00FFFFFF; 
     331                unsigned int v = bswap_32(*target_event) & 0x00FFFFFF; 
    332332                // sign-extend highest bit of 24-bit int 
    333333                int tmp = (int)(v << 8) / 256; 
     
    365365            for (j = p.location;j < nevents; j += 8) { 
    366366                target_event = (quadlet_t *) (data + ((j * m_dimension) + p.position)); 
    367                 sample_int=ntohl(*target_event); 
     367                sample_int=bswap_32(*target_event); 
    368368                // FIXME: this assumes that 2X and 3X speed isn't used, 
    369369                // because only the 1X slot is put into the ringbuffer 
  • trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp

    r1103 r1131  
    3535#include "libieee1394/cycletimer.h" 
    3636 
    37 #include <netinet/in.h> 
     37#include <byteswap.h> 
    3838#include <assert.h> 
    3939 
     
    353353    // convert the timestamp to SYT format 
    354354    uint16_t timestamp_SYT = TICKS_TO_SYT ( ts ); 
    355     packet->syt = htons ( timestamp_SYT ); 
     355    packet->syt = bswap_16 ( timestamp_SYT ); 
    356356 
    357357    // FIXME: use a precomputed value here 
     
    497497        for (j = 0;j < nevents; j += 1) 
    498498        { 
     499#if __BYTE_ORDER == __BIG_ENDIAN 
     500            *target_event = 0x40000000; 
     501#elif __BYTE_ORDER == __LITTLE_ENDIAN 
    499502            *target_event = 0x00000040; 
     503#else 
     504 
     505#error Unknown host byte order 
     506 
     507#endif 
    500508            target_event += m_dimension; 
    501509        } 
     
    683691                unsigned int tmp = ((int) v); 
    684692                tmp = ( tmp >> 8 ) | 0x40000000; 
    685                 *target_event = htonl((quadlet_t)tmp); 
     693                *target_event = bswap_32((quadlet_t)tmp); 
    686694                buffer++; 
    687695                target_event += m_dimension; 
     
    839847            for(;j < nevents; j += 1) { 
    840848                uint32_t in = (uint32_t)(*buffer); 
    841                 *target_event = htonl((quadlet_t)((in & 0x00FFFFFF) | 0x40000000)); 
     849                *target_event = bswap_32((quadlet_t)((in & 0x00FFFFFF) | 0x40000000)); 
    842850                buffer++; 
    843851                target_event += m_dimension; 
     
    884892            { 
    885893                uint32_t in = (uint32_t)(*buffer); 
    886                 *target_event = htonl((quadlet_t)((in & 0x00FFFFFF) | 0x40000000)); 
     894                *target_event = bswap_32((quadlet_t)((in & 0x00FFFFFF) | 0x40000000)); 
    887895                buffer++; 
    888896                target_event += m_dimension; 
     
    891899            for (j = 0;j < nevents; j += 1) 
    892900            { 
     901#if __BYTE_ORDER == __BIG_ENDIAN 
     902                *target_event = 0x40000000; 
     903#elif __BYTE_ORDER == __LITTLE_ENDIAN 
    893904                *target_event = 0x00000040; 
     905#else 
     906 
     907#error Unknown host byte order 
     908 
     909#endif 
    894910                target_event += m_dimension; 
    895911            } 
     
    933949 
    934950                tmp = ( tmp >> 8 ) | 0x40000000; 
    935                 *target_event = htonl((quadlet_t)tmp); 
     951                *target_event = bswap_32((quadlet_t)tmp); 
    936952                buffer++; 
    937953                target_event += m_dimension; 
     
    940956            for (j = 0;j < nevents; j += 1) 
    941957            { 
    942                 // hardcoded little endian 
     958#if __BYTE_ORDER == __BIG_ENDIAN 
     959                *target_event = 0x40000000; 
     960#elif __BYTE_ORDER == __LITTLE_ENDIAN 
    943961                *target_event = 0x00000040; 
     962#else 
     963 
     964#error Unknown host byte order 
     965 
     966#endif 
    944967                target_event += m_dimension; 
    945968            } 
     
    968991        for (j = p.location;j < nevents; j += 8) { 
    969992            target_event = (quadlet_t *) (data + ((j * m_dimension) + p.position)); 
    970             *target_event = htonl(IEC61883_AM824_SET_LABEL(0, IEC61883_AM824_LABEL_MIDI_NO_DATA)); 
     993            *target_event = bswap_32(IEC61883_AM824_SET_LABEL(0, IEC61883_AM824_LABEL_MIDI_NO_DATA)); 
    971994        } 
    972995    } 
     
    10011024                    tmpval = ((*buffer)<<16) & 0x00FF0000; 
    10021025                    tmpval = IEC61883_AM824_SET_LABEL(tmpval, IEC61883_AM824_LABEL_MIDI_1X); 
    1003                     *target_event = htonl(tmpval); 
     1026                    *target_event = bswap_32(tmpval); 
    10041027 
    10051028//                     debugOutput ( DEBUG_LEVEL_VERBOSE, "MIDI port %s, pos=%u, loc=%u, nevents=%u, dim=%d\n", 
     
    10111034                    // or because this would exceed the maximum rate 
    10121035                    // FIXME: this can be ifdef optimized since it's a constant 
    1013                     *target_event = htonl(IEC61883_AM824_SET_LABEL(0, IEC61883_AM824_LABEL_MIDI_NO_DATA)); 
     1036                    *target_event = bswap_32(IEC61883_AM824_SET_LABEL(0, IEC61883_AM824_LABEL_MIDI_NO_DATA)); 
    10141037                } 
    10151038                buffer+=8; 
     
    10191042                target_event = (quadlet_t *)(data + ((j * m_dimension) + p.position)); 
    10201043                __builtin_prefetch(target_event, 1, 0); // prefetch events for write, no temporal locality 
    1021                 *target_event = htonl(IEC61883_AM824_SET_LABEL(0, IEC61883_AM824_LABEL_MIDI_NO_DATA)); 
     1044                *target_event = bswap_32(IEC61883_AM824_SET_LABEL(0, IEC61883_AM824_LABEL_MIDI_NO_DATA)); 
    10221045            } 
    10231046        } 
  • trunk/libffado/src/libstreaming/motu/MotuReceiveStreamProcessor.cpp

    r1035 r1131  
    3636 
    3737#include <math.h> 
    38 #include <netinet/in.h> 
     38#include <byteswap.h> 
    3939#include <assert.h> 
    4040 
     
    131131        // for 2x rates, 32 for 4x rates). 
    132132        quadlet_t *quadlet = (quadlet_t *)data; 
    133         unsigned int dbs = get_bits(ntohl(quadlet[0]), 23, 8);  // Size of one event in terms of fdf_size 
    134         unsigned int fdf_size = get_bits(ntohl(quadlet[1]), 23, 8) == 0x22 ? 32:0; // Event unit size in bits 
     133        unsigned int dbs = get_bits(bswap_32(quadlet[0]), 23, 8);  // Size of one event in terms of fdf_size 
     134        unsigned int fdf_size = get_bits(bswap_32(quadlet[1]), 23, 8) == 0x22 ? 32:0; // Event unit size in bits 
    135135 
    136136        // Don't even attempt to process a packet if it isn't what 
     
    150150        // received.  Since every frame from the MOTU has its own timestamp 
    151151        // we can just pick it straight from the packet. 
    152         uint32_t last_sph = ntohl(*(quadlet_t *)(data+8+(n_events-1)*event_length)); 
     152        uint32_t last_sph = bswap_32(*(quadlet_t *)(data+8+(n_events-1)*event_length)); 
    153153        m_last_timestamp = sphRecvToFullTicks(last_sph, m_Parent.get1394Service().getCycleTimer()); 
    154154 
     
    174174    quadlet_t* quadlet = (quadlet_t*) data; 
    175175 
    176     unsigned int dbs = get_bits(ntohl(quadlet[0]), 23, 8);  // Size of one event in terms of fdf_size 
    177     unsigned int fdf_size = get_bits(ntohl(quadlet[1]), 23, 8) == 0x22 ? 32:0; // Event unit size in bits 
     176    unsigned int dbs = get_bits(bswap_32(quadlet[0]), 23, 8);  // Size of one event in terms of fdf_size 
     177    unsigned int fdf_size = get_bits(bswap_32(quadlet[1]), 23, 8) == 0x22 ? 32:0; // Event unit size in bits 
    178178    // this is only called for packets that return eCRV_OK on processPacketHeader 
    179179    // so event_length won't become 0 
  • trunk/libffado/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp

    r1097 r1131  
    3535#include "libieee1394/cycletimer.h" 
    3636 
    37 #include <netinet/in.h> 
     37#include <byteswap.h> 
    3838#include <assert.h> 
    3939 
     
    293293            // network byte order).  After byte order swap, the 24-bit 
    294294            // MSB is in the second byte of val. 
    295             signed int val = htonl(lrintf(0x7fffff*sin((1000.0*2.0*M_PI/24576000.0)*a_cx))); 
     295            signed int val = bswap_32(lrintf(0x7fffff*sin((1000.0*2.0*M_PI/24576000.0)*a_cx))); 
    296296            memcpy(sample,((char *)&val)+1,3); 
    297297            if ((a_cx+=int_tpf) >= 24576000) { 
     
    309309        for (int i=0; i < n_events; i++, quadlet += dbs) { 
    310310            int64_t ts_frame = addTicks(m_last_timestamp, (unsigned int)lrintf(i * ticks_per_frame)); 
    311             *quadlet = htonl(fullTicksToSph(ts_frame)); 
     311            *quadlet = bswap_32(fullTicksToSph(ts_frame)); 
    312312//fprintf(stderr,"tx: %d/%d\n", 
    313313//  CYCLE_TIMER_GET_CYCLES(fullTicksToSph(ts_frame)), 
     
    405405    for (int i=0; i < n_events; i++, quadlet += dbs) { 
    406406        int64_t ts_frame = addTicks(m_last_timestamp, (unsigned int)lrintf(i * ticks_per_frame)); 
    407         *quadlet = htonl(fullTicksToSph(ts_frame)); 
     407        *quadlet = bswap_32(fullTicksToSph(ts_frame)); 
    408408    } 
    409409 
     
    428428    // present.  For data-less packets the dbc is the same as the previously 
    429429    // transmitted block. 
    430     *quadlet = htonl(0x00000400 | ((m_Parent.get1394Service().getLocalNodeId()&0x3f)<<24) | m_tx_dbc | (dbs<<16)); 
     430    *quadlet = bswap_32(0x00000400 | ((m_Parent.get1394Service().getLocalNodeId()&0x3f)<<24) | m_tx_dbc | (dbs<<16)); 
    431431    quadlet++; 
    432     *quadlet = htonl(0x8222ffff); 
     432    *quadlet = bswap_32(0x8222ffff); 
    433433    quadlet++; 
    434434    return n_events; 
     
    445445    // present.  For data-less packets the dbc is the same as the previously 
    446446    // transmitted block. 
    447     *quadlet = htonl(0x00000400 | ((m_Parent.get1394Service().getLocalNodeId()&0x3f)<<24) | m_tx_dbc | (dbs<<16)); 
     447    *quadlet = bswap_32(0x00000400 | ((m_Parent.get1394Service().getLocalNodeId()&0x3f)<<24) | m_tx_dbc | (dbs<<16)); 
    448448    quadlet++; 
    449     *quadlet = htonl(0x8222ffff); 
     449    *quadlet = bswap_32(0x8222ffff); 
    450450    quadlet++; 
    451451    *length = 8; 
  • trunk/libffado/src/libstreaming/util/cip.h

    r864 r1131  
    4242struct iec61883_packet { 
    4343    /* First quadlet */ 
    44     uint8_t dbs      : 8; 
    4544    uint8_t eoh0     : 2; 
    4645    uint8_t sid      : 6; 
     46    uint8_t dbs      : 8; 
    4747 
    48     uint8_t dbc      : 8; 
    4948    uint8_t fn       : 2; 
    5049    uint8_t qpc      : 3; 
    5150    uint8_t sph      : 1; 
    5251    uint8_t reserved : 2; 
     52    uint8_t dbc      : 8; 
    5353 
    5454    /* Second quadlet */ 
    55     uint8_t fdf      : 8; 
    5655    uint8_t eoh1     : 2; 
    5756    uint8_t fmt      : 6; 
     57    uint8_t fdf      : 8; 
    5858 
    5959    uint16_t syt      : 16; 
  • trunk/libffado/src/libutil/ByteSwap.h

    r864 r1131  
    2525#define __FFADO_BYTESWAP__ 
    2626 
    27 #include <netinet/in.h> 
     27#include <byteswap.h> 
    2828#include <endian.h> 
    2929#include <assert.h> 
     
    6161    // Work input until data reaches 16 byte alignment 
    6262    while ((((unsigned long)data) & 0xF) && nb_elements > 0) { 
    63         *data = htonl(*data); 
     63        *data = bswap_32(*data); 
    6464        data++; 
    6565        nb_elements--; 
     
    9898    // and do the remaining ones 
    9999    while (nb_elements > 0) { 
    100         *data = htonl(*data); 
     100        *data = bswap_32(*data); 
    101101        data++; 
    102102        nb_elements--; 
     
    110110    // Work input until data reaches 16 byte alignment 
    111111    while ((((unsigned long)data) & 0xF) && nb_elements > 0) { 
    112         *data = htonl(*data); 
     112        *data = bswap_32(*data); 
    113113        data++; 
    114114        nb_elements--; 
     
    144144    // and do the remaining ones 
    145145    while (nb_elements > 0) { 
    146         *data = htonl(*data); 
     146        *data = bswap_32(*data); 
    147147        data++; 
    148148        nb_elements--; 
     
    157157    unsigned int i=0; 
    158158    for(; i<nb_elements; i++) { 
    159         *data = htonl(*data); 
     159        *data = bswap_32(*data); 
    160160        data++; 
    161161    } 
     
    167167    unsigned int i=0; 
    168168    for(; i<nb_elements; i++) { 
    169         *data = ntohl(*data); 
     169        *data = bswap_32(*data); 
    170170        data++; 
    171171    } 
  • trunk/libffado/src/libutil/cmd_serialize.cpp

    r864 r1131  
    2727#include <iomanip> 
    2828 
    29 #include <netinet/in.h> 
     29#include <byteswap.h> 
    3030 
    3131 
  • trunk/libffado/src/metrichalo/mh_avdevice.cpp

    r864 r1131  
    3636#include <stdint.h> 
    3737#include <assert.h> 
    38 #include <netinet/in.h> 
     38#include <byteswap.h> 
    3939#include <iostream> 
    4040#include <sstream> 
  • trunk/libffado/src/motu/motu_avdevice.cpp

    r1128 r1131  
    4444#include <stdint.h> 
    4545#include <assert.h> 
    46 #include <netinet/in.h> 
     46#include <byteswap.h> 
    4747#include <iostream> 
    4848#include <sstream> 
     
    13891389  } 
    13901390 
    1391   return ntohl(quadlet); 
     1391  return bswap_32(quadlet); 
    13921392} 
    13931393 
     
    13981398 
    13991399  unsigned int err = 0; 
    1400   data = htonl(data); 
     1400  data = bswap_32(data); 
    14011401 
    14021402  // Note: 1394Service::write() expects a physical ID, not the node id 
  • trunk/libffado/src/rme/rme_avdevice.cpp

    r1122 r1131  
    3535#include <stdint.h> 
    3636#include <assert.h> 
    37 #include <netinet/in.h> 
     37#include <byteswap.h> 
    3838 
    3939#include <iostream> 
     
    252252        debugError("Error doing RME read from register 0x%06x\n",reg); 
    253253    } 
    254     return ntohl(quadlet); 
     254    return bswap_32(quadlet); 
    255255} 
    256256 
     
    259259 
    260260    unsigned int err = 0; 
    261     data = htonl(data); 
     261    data = bswap_32(data); 
    262262    if (get1394Service().write(0xffc0 | getNodeId(), reg, 1, &data) <= 0) { 
    263263        err = 1; 
  • trunk/libffado/tests/dumpiso_mod.cpp

    r1084 r1131  
    2121#include "src/debugmodule/debugmodule.h" 
    2222#include "src/libstreaming/util/cip.h" 
    23 #include <netinet/in.h> 
     23#include <byteswap.h> 
    2424 
    2525#define BUFFER 1000 
     
    210210                    (length >= 2*sizeof(quadlet_t)); 
    211211        if(ok) { 
    212             timestamp = sytRecvToFullTicks((uint32_t)ntohs(packet->syt), 
     212            timestamp = sytRecvToFullTicks((uint32_t)bswap_16(packet->syt), 
    213213                                    cycle, cycle_timer); 
    214214        } 
  • trunk/libffado/tests/scan-devreg.cpp

    r1121 r1131  
    2525 
    2626#include <libraw1394/raw1394.h> 
    27 #include <netinet/in.h> 
     27#include <byteswap.h> 
    2828 
    2929#include "debugmodule/debugmodule.h" 
     
    284284                continue; 
    285285            } else { 
    286                 quadlet = ntohl(quadlet); 
     286                quadlet = bswap_32(quadlet); 
    287287            } 
    288288             
  • trunk/libffado/tests/streaming/test-isohandling.cpp

    r864 r1131  
    3333#include "src/debugmodule/debugmodule.h" 
    3434 
    35 #include <netinet/in.h> 
     35#include <byteswap.h> 
    3636 
    3737#include "src/libutil/PosixThread.h" 
  • trunk/libffado/tests/test-bufferops.cpp

    r1027 r1131  
    6565     
    6666    for (i=0; i<nb_quadlets; i++) { 
    67         buffer_ref[i] = htonl(buffer_1[i]); 
     67        buffer_ref[i] = bswap_32(buffer_1[i]); 
    6868    } 
    6969     
  • trunk/libffado/tests/test-ieee1394service.cpp

    r1018 r1131  
    3636#include "src/debugmodule/debugmodule.h" 
    3737 
    38 #include <netinet/in.h> 
     38#include <byteswap.h> 
    3939 
    4040#include "src/libieee1394/cycletimer.h" 
  • trunk/libffado/tests/test-timestampedbuffer.cpp

    r907 r1131  
    3535#include "src/debugmodule/debugmodule.h" 
    3636 
    37 #include <netinet/in.h> 
     37#include <byteswap.h> 
    3838 
    3939#include "src/libieee1394/cycletimer.h"