Projects
Browse Source     Search     Timeline     Wiki

Changeset 23558

Show
Ignore:
Timestamp:
2008-03-18 14:32:54 (7 months ago)
Author:
zarzycki@…
Message:

Swap the byte-order of IPC.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/launchd/src/liblaunch.c

    r23556 r23558  
    6767extern void __OSBogusByteSwap__(void); 
    6868 
    69 #define host2big(x)                             \ 
     69#define host2wire(x)                            \ 
    7070        ({ typeof (x) _X, _x = (x);             \ 
    7171         switch (sizeof(_x)) {                  \ 
    7272         case 8:                                \ 
    73                 _X = OSSwapHostToBigInt64(_x);  \ 
     73                _X = OSSwapHostToLittleInt64(_x);       \ 
    7474                break;                          \ 
    7575         case 4:                                \ 
    76                 _X = OSSwapHostToBigInt32(_x);  \ 
     76                _X = OSSwapHostToLittleInt32(_x);       \ 
    7777                break;                          \ 
    7878         case 2:                                \ 
    79                 _X = OSSwapHostToBigInt16(_x);  \ 
     79                _X = OSSwapHostToLittleInt16(_x);       \ 
    8080                break;                          \ 
    8181         case 1:                                \ 
     
    9090 
    9191 
    92 #define big2host(x)                             \ 
     92#define big2wire(x)                             \ 
    9393        ({ typeof (x) _X, _x = (x);             \ 
    9494         switch (sizeof(_x)) {                  \ 
    9595         case 8:                                \ 
    96                 _X = OSSwapBigToHostInt64(_x);  \ 
     96                _X = OSSwapLittleToHostInt64(_x);       \ 
    9797                break;                          \ 
    9898         case 4:                                \ 
    99                 _X = OSSwapBigToHostInt32(_x);  \ 
     99                _X = OSSwapLittleToHostInt32(_x);       \ 
    100100                break;                          \ 
    101101         case 2:                                \ 
    102                 _X = OSSwapBigToHostInt16(_x);  \ 
     102                _X = OSSwapLittleToHostInt16(_x);       \ 
    103103                break;                          \ 
    104104         case 1:                                \ 
     
    613613        where += total_data_len; 
    614614 
    615         o_in_w->type = host2big(d->type); 
     615        o_in_w->type = host2wire(d->type); 
    616616 
    617617        switch (d->type) { 
    618618        case LAUNCH_DATA_INTEGER: 
    619                 o_in_w->number = host2big(d->number); 
     619                o_in_w->number = host2wire(d->number); 
    620620                break; 
    621621        case LAUNCH_DATA_REAL: 
    622                 o_in_w->float_num = host2big(d->float_num); 
     622                o_in_w->float_num = host2wire(d->float_num); 
    623623                break; 
    624624        case LAUNCH_DATA_BOOL: 
    625                 o_in_w->boolean = host2big(d->boolean); 
     625                o_in_w->boolean = host2wire(d->boolean); 
    626626                break; 
    627627        case LAUNCH_DATA_ERRNO: 
    628                 o_in_w->err = host2big(d->err); 
     628                o_in_w->err = host2wire(d->err); 
    629629                break; 
    630630        case LAUNCH_DATA_FD: 
    631                 o_in_w->fd = host2big(d->fd); 
     631                o_in_w->fd = host2wire(d->fd); 
    632632                if (fd_where && d->fd != -1) { 
    633633                        fd_where[*fd_cnt] = d->fd; 
     
    636636                break; 
    637637        case LAUNCH_DATA_STRING: 
    638                 o_in_w->string_len = host2big(d->string_len); 
     638                o_in_w->string_len = host2wire(d->string_len); 
    639639                total_data_len += ROUND_TO_64BIT_WORD_SIZE(strlen(d->string) + 1); 
    640640                if (total_data_len > len) { 
     
    644644                break; 
    645645        case LAUNCH_DATA_OPAQUE: 
    646                 o_in_w->opaque_size = host2big(d->opaque_size); 
     646                o_in_w->opaque_size = host2wire(d->opaque_size); 
    647647                total_data_len += ROUND_TO_64BIT_WORD_SIZE(d->opaque_size); 
    648648                if (total_data_len > len) { 
     
    653653        case LAUNCH_DATA_DICTIONARY: 
    654654        case LAUNCH_DATA_ARRAY: 
    655                 o_in_w->_array_cnt = host2big(d->_array_cnt); 
     655                o_in_w->_array_cnt = host2wire(d->_array_cnt); 
    656656                total_data_len += d->_array_cnt * sizeof(uint64_t); 
    657657                if (total_data_len > len) { 
     
    687687        *data_offset += sizeof(struct _launch_data); 
    688688 
    689         switch (big2host(r->type)) { 
     689        switch (big2wire(r->type)) { 
    690690        case LAUNCH_DATA_DICTIONARY: 
    691691        case LAUNCH_DATA_ARRAY: 
    692                 tmpcnt = big2host(r->_array_cnt); 
     692                tmpcnt = big2wire(r->_array_cnt); 
    693693                if ((data_size - *data_offset) < (tmpcnt * sizeof(uint64_t))) { 
    694694                        errno = EAGAIN; 
     
    705705                break; 
    706706        case LAUNCH_DATA_STRING: 
    707                 tmpcnt = big2host(r->string_len); 
     707                tmpcnt = big2wire(r->string_len); 
    708708                if ((data_size - *data_offset) < (tmpcnt + 1)) { 
    709709                        errno = EAGAIN; 
     
    715715                break; 
    716716        case LAUNCH_DATA_OPAQUE: 
    717                 tmpcnt = big2host(r->opaque_size); 
     717                tmpcnt = big2wire(r->opaque_size); 
    718718                if ((data_size - *data_offset) < tmpcnt) { 
    719719                        errno = EAGAIN; 
     
    731731                break; 
    732732        case LAUNCH_DATA_INTEGER: 
    733                 r->number = big2host(r->number); 
     733                r->number = big2wire(r->number); 
    734734                break; 
    735735        case LAUNCH_DATA_REAL: 
    736                 r->float_num = big2host(r->float_num); 
     736                r->float_num = big2wire(r->float_num); 
    737737                break; 
    738738        case LAUNCH_DATA_BOOL: 
    739                 r->boolean = big2host(r->boolean); 
     739                r->boolean = big2wire(r->boolean); 
    740740                break; 
    741741        case LAUNCH_DATA_ERRNO: 
    742                 r->err = big2host(r->err); 
     742                r->err = big2wire(r->err); 
    743743        case LAUNCH_DATA_MACHPORT: 
    744744                break; 
     
    749749        } 
    750750 
    751         r->type = big2host(r->type); 
     751        r->type = big2wire(r->type); 
    752752 
    753753        return r; 
     
    789789                lh->sendfdcnt = fd_slots_used; 
    790790 
    791                 msglen = lh->sendlen + sizeof(struct launch_msg_header); /* type promotion to make the host2big() macro work right */ 
    792                 lmh.len = host2big(msglen); 
    793                 lmh.magic = host2big(LAUNCH_MSG_HEADER_MAGIC); 
     791                msglen = lh->sendlen + sizeof(struct launch_msg_header); /* type promotion to make the host2wire() macro work right */ 
     792                lmh.len = host2wire(msglen); 
     793                lmh.magic = host2wire(LAUNCH_MSG_HEADER_MAGIC); 
    794794 
    795795                iov[0].iov_base = &lmh; 
     
    10201020                        goto need_more_data; 
    10211021 
    1022                 tmplen = big2host(lmhp->len); 
    1023  
    1024                 if (big2host(lmhp->magic) != LAUNCH_MSG_HEADER_MAGIC || tmplen <= sizeof(struct launch_msg_header)) { 
     1022                tmplen = big2wire(lmhp->len); 
     1023 
     1024                if (big2wire(lmhp->magic) != LAUNCH_MSG_HEADER_MAGIC || tmplen <= sizeof(struct launch_msg_header)) { 
    10251025                        errno = EBADRPC; 
    10261026                        goto out_bad;