tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

dummy_io_fwd.cc (5492B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #include "prio.h"
      6 
      7 #include "dummy_io.h"
      8 
      9 static DummyIOLayerMethods *ToMethods(PRFileDesc *f) {
     10  return reinterpret_cast<DummyIOLayerMethods *>(f->secret);
     11 }
     12 
     13 static PRStatus DummyClose(PRFileDesc *f) { return ToMethods(f)->Close(f); }
     14 
     15 static int32_t DummyRead(PRFileDesc *f, void *buf, int32_t length) {
     16  return ToMethods(f)->Read(f, buf, length);
     17 }
     18 
     19 static int32_t DummyWrite(PRFileDesc *f, const void *buf, int32_t length) {
     20  return ToMethods(f)->Write(f, buf, length);
     21 }
     22 
     23 static int32_t DummyAvailable(PRFileDesc *f) {
     24  return ToMethods(f)->Available(f);
     25 }
     26 
     27 static int64_t DummyAvailable64(PRFileDesc *f) {
     28  return ToMethods(f)->Available64(f);
     29 }
     30 
     31 static PRStatus DummySync(PRFileDesc *f) { return ToMethods(f)->Sync(f); }
     32 
     33 static int32_t DummySeek(PRFileDesc *f, int32_t offset, PRSeekWhence how) {
     34  return ToMethods(f)->Seek(f, offset, how);
     35 }
     36 
     37 static int64_t DummySeek64(PRFileDesc *f, int64_t offset, PRSeekWhence how) {
     38  return ToMethods(f)->Seek64(f, offset, how);
     39 }
     40 
     41 static PRStatus DummyFileInfo(PRFileDesc *f, PRFileInfo *info) {
     42  return ToMethods(f)->FileInfo(f, info);
     43 }
     44 
     45 static PRStatus DummyFileInfo64(PRFileDesc *f, PRFileInfo64 *info) {
     46  return ToMethods(f)->FileInfo64(f, info);
     47 }
     48 
     49 static int32_t DummyWritev(PRFileDesc *f, const PRIOVec *iov, int32_t iov_size,
     50                           PRIntervalTime to) {
     51  return ToMethods(f)->Writev(f, iov, iov_size, to);
     52 }
     53 
     54 static PRStatus DummyConnect(PRFileDesc *f, const PRNetAddr *addr,
     55                             PRIntervalTime to) {
     56  return ToMethods(f)->Connect(f, addr, to);
     57 }
     58 
     59 static PRFileDesc *DummyAccept(PRFileDesc *f, PRNetAddr *addr,
     60                               PRIntervalTime to) {
     61  return ToMethods(f)->Accept(f, addr, to);
     62 }
     63 
     64 static PRStatus DummyBind(PRFileDesc *f, const PRNetAddr *addr) {
     65  return ToMethods(f)->Bind(f, addr);
     66 }
     67 
     68 static PRStatus DummyListen(PRFileDesc *f, int32_t depth) {
     69  return ToMethods(f)->Listen(f, depth);
     70 }
     71 
     72 static PRStatus DummyShutdown(PRFileDesc *f, int32_t how) {
     73  return ToMethods(f)->Shutdown(f, how);
     74 }
     75 
     76 static int32_t DummyRecv(PRFileDesc *f, void *buf, int32_t buflen,
     77                         int32_t flags, PRIntervalTime to) {
     78  return ToMethods(f)->Recv(f, buf, buflen, flags, to);
     79 }
     80 
     81 static int32_t DummySend(PRFileDesc *f, const void *buf, int32_t amount,
     82                         int32_t flags, PRIntervalTime to) {
     83  return ToMethods(f)->Send(f, buf, amount, flags, to);
     84 }
     85 
     86 static int32_t DummyRecvfrom(PRFileDesc *f, void *buf, int32_t amount,
     87                             int32_t flags, PRNetAddr *addr,
     88                             PRIntervalTime to) {
     89  return ToMethods(f)->Recvfrom(f, buf, amount, flags, addr, to);
     90 }
     91 
     92 static int32_t DummySendto(PRFileDesc *f, const void *buf, int32_t amount,
     93                           int32_t flags, const PRNetAddr *addr,
     94                           PRIntervalTime to) {
     95  return ToMethods(f)->Sendto(f, buf, amount, flags, addr, to);
     96 }
     97 
     98 static int16_t DummyPoll(PRFileDesc *f, int16_t in_flags, int16_t *out_flags) {
     99  return ToMethods(f)->Poll(f, in_flags, out_flags);
    100 }
    101 
    102 static int32_t DummyAcceptRead(PRFileDesc *f, PRFileDesc **nd,
    103                               PRNetAddr **raddr, void *buf, int32_t amount,
    104                               PRIntervalTime t) {
    105  return ToMethods(f)->AcceptRead(f, nd, raddr, buf, amount, t);
    106 }
    107 
    108 static int32_t DummyTransmitFile(PRFileDesc *sd, PRFileDesc *f,
    109                                 const void *headers, int32_t hlen,
    110                                 PRTransmitFileFlags flags, PRIntervalTime t) {
    111  return ToMethods(f)->TransmitFile(sd, f, headers, hlen, flags, t);
    112 }
    113 
    114 static PRStatus DummyGetpeername(PRFileDesc *f, PRNetAddr *addr) {
    115  return ToMethods(f)->Getpeername(f, addr);
    116 }
    117 
    118 static PRStatus DummyGetsockname(PRFileDesc *f, PRNetAddr *addr) {
    119  return ToMethods(f)->Getsockname(f, addr);
    120 }
    121 
    122 static PRStatus DummyGetsockoption(PRFileDesc *f, PRSocketOptionData *opt) {
    123  return ToMethods(f)->Getsockoption(f, opt);
    124 }
    125 
    126 static PRStatus DummySetsockoption(PRFileDesc *f,
    127                                   const PRSocketOptionData *opt) {
    128  return ToMethods(f)->Setsockoption(f, opt);
    129 }
    130 
    131 static int32_t DummySendfile(PRFileDesc *f, PRSendFileData *in,
    132                             PRTransmitFileFlags flags, PRIntervalTime to) {
    133  return ToMethods(f)->Sendfile(f, in, flags, to);
    134 }
    135 
    136 static PRStatus DummyConnectContinue(PRFileDesc *f, int16_t flags) {
    137  return ToMethods(f)->ConnectContinue(f, flags);
    138 }
    139 
    140 static int32_t DummyReserved(PRFileDesc *f) {
    141  return ToMethods(f)->Reserved(f);
    142 }
    143 
    144 extern const struct PRIOMethods DummyMethodsForward = {
    145    PR_DESC_LAYERED,    DummyClose,
    146    DummyRead,          DummyWrite,
    147    DummyAvailable,     DummyAvailable64,
    148    DummySync,          DummySeek,
    149    DummySeek64,        DummyFileInfo,
    150    DummyFileInfo64,    DummyWritev,
    151    DummyConnect,       DummyAccept,
    152    DummyBind,          DummyListen,
    153    DummyShutdown,      DummyRecv,
    154    DummySend,          DummyRecvfrom,
    155    DummySendto,        DummyPoll,
    156    DummyAcceptRead,    DummyTransmitFile,
    157    DummyGetsockname,   DummyGetpeername,
    158    DummyReserved,      DummyReserved,
    159    DummyGetsockoption, DummySetsockoption,
    160    DummySendfile,      DummyConnectContinue,
    161    DummyReserved,      DummyReserved,
    162    DummyReserved,      DummyReserved};