Changeset 508:1129ff87dd1e in roaraudio
- Timestamp:
- 08/15/08 00:40:31 (16 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
include/libroar/socket.h
r502 r508 36 36 int roar_socket_new_udp (void); 37 37 int roar_socket_new_unix (void); 38 int roar_socket_new_decnet_seqpacket (void); 39 int roar_socket_new_decnet_stream (void); 40 38 41 int roar_socket_open (int mode, int type, char * host, int port); 39 42 int roar_socket_open_fork (int mode, char * host, int port); 40 43 int roar_socket_open_file (int mode, char * host, int port); 41 44 int roar_socket_open_proxy (int mode, int type, char * host, int port, char * proxy_type); 45 46 int roar_socket_listen_decnet (char * object, int num); 42 47 43 48 int roar_socket_nonblock(int fh, int state); -
include/roaraudio.h
r480 r508 52 52 #include <libroar/libroar.h> 53 53 54 // IP 54 55 #define ROAR_DEFAULT_PORT 16002 55 56 #define ROAR_DEFAULT_HOST "localhost" 56 57 58 // UNIX Domain Sockets 57 59 #define ROAR_DEFAULT_SOCK_GLOBAL "/tmp/roar" 58 60 #define ROAR_DEFAULT_SOCK_USER ".roar" 61 62 // DECnet 63 #define ROAR_DEFAULT_OBJECT "roar" 64 #define ROAR_DEFAULT_NUM 0 65 #define ROAR_DEFAULT_LISTEN_OBJECT "LISTEN::" ROAR_DEFAULT_OBJECT 59 66 60 67 #define ROAR_DEFAULT_SOCKGRP "audio" … … 118 125 #define ROAR_HOST2NET16(x) (x) 119 126 127 #ifdef ROAR_HAVE_LIBDNET 128 #define ROAR_dn_ntohs(x) ((((x)&0x0ff)<<8) | (((x)&0xff00)>>8)) 129 #define ROAR_dn_ntohl(x) ( ((dn_ntohs((x)&0xffff))<<16) |\ 130 ((dn_ntohs(((x)>>16)))) ) 131 #define ROAR_dn_htonl(x) ROAR_dn_ntohl(x) 132 #define ROAR_dn_htons(x) ROAR_dn_ntohs(x) 133 #endif 134 120 135 //#elif BYTE_ORDER == LITTLE_ENDIAN 121 136 #else … … 126 141 #define ROAR_HOST2NET16(x) htons((x)) 127 142 143 #ifdef ROAR_HAVE_LIBDNET 144 #if BYTE_ORDER == LITTLE_ENDIAN 145 #define ROAR_dn_ntohs(x) (x) 146 #define ROAR_dn_htons(x) (x) 147 148 #define ROAR_dn_ntohl(x) (x) 149 #define ROAR_dn_htonl(x) (x) 150 #else 151 #error can not build on this architecture with DECnet support enabled 152 #endif 153 #endif 154 128 155 #endif 129 156 -
libroar/socket.c
r503 r508 42 42 return fh; 43 43 } 44 45 int roar_socket_new_decnet_seqpacket (void) { 46 #ifdef ROAR_HAVE_LIBDNET 47 int fh; 48 49 fh = socket(AF_DECnet, SOCK_SEQPACKET, DNPROTO_NSP); 50 51 return fh; 52 #else 53 return -1; 54 #endif 55 } 56 57 58 int roar_socket_new_decnet_stream (void) { 59 #ifdef ROAR_HAVE_LIBDNET 60 int fh; 61 62 fh = socket(AF_DECnet, SOCK_STREAM, DNPROTO_NSP); 63 64 return fh; 65 #else 66 return -1; 67 #endif 68 } 69 44 70 45 71 int roar_socket_nonblock(int fh, int state) { … … 119 145 return roar_socket_open_proxy(MODE_CONNECT, ROAR_SOCKET_TYPE_UNKNOWN, host, port, proxy_type); 120 146 } 147 } 148 149 150 int roar_socket_listen_decnet (char * object, int num) { 151 #ifdef ROAR_HAVE_LIBDNET 152 int fh = roar_socket_new_decnet_stream(); 153 struct sockaddr_dn bind_sockaddr; 154 155 if ( fh == -1 ) 156 return -1; 157 158 if ( !*object ) 159 object = NULL; 160 161 if ( (object && num) || (!*object && !num) ) { 162 ROAR_WARN("roar_socket_listen_decnet(object='%s', num=%i): illegal address!", object, num); 163 close(fh); 164 return -1; 165 } 166 167 memset((void*)&bind_sockaddr, 0, sizeof(struct sockaddr_dn)); 168 169 bind_sockaddr.sdn_family = AF_DECnet; 170 bind_sockaddr.sdn_flags = 0; 171 bind_sockaddr.sdn_objnum = num; 172 173 if ( num ) { 174 bind_sockaddr.sdn_objnamel = 0; 175 } else { 176 bind_sockaddr.sdn_objnamel = ROAR_dn_htons(strlen(object)); 177 strcpy((char*)bind_sockaddr.sdn_objname, object); // FIXME: shouldn't we use strncpy()? 178 } 179 180 if ( bind(fh, (struct sockaddr *) &bind_sockaddr, sizeof(bind_sockaddr)) == -1 ) { 181 close(fh); 182 return -1; 183 } 184 185 if ( listen(fh, 8) == -1 ) { 186 close(fh); 187 return -1; 188 } 189 190 return fh; 191 #else 192 return -1; 193 #endif 121 194 } 122 195 … … 153 226 154 227 if ( type == ROAR_SOCKET_TYPE_DECNET ) { 155 if ( mode == MODE_LISTEN ) {156 return -1; // listen sockets on DECnet are not supportet at the moment157 } else {158 228 #ifdef ROAR_HAVE_LIBDNET 159 // There is nothing wrong in this case to use dnet_conn() so we do.229 ROAR_DBG("roar_socket_open(*): hostname for DECnet: host(%p)=%s", host, host); 160 230 del = strstr(host, "::"); 231 ROAR_DBG("roar_socket_open(*): hostname for DECnet: del(%p)=%s", del, del); 232 233 if ( del == NULL ) { 234 ROAR_WARN("roar_socket_open(*): invalid hostname for DECnet: %s", host); 235 return -1; 236 } 237 161 238 *del = 0; 162 239 … … 172 249 } 173 250 251 if ( mode == MODE_LISTEN ) { 252 fh = roar_socket_listen_decnet(obj, port); 253 *del = ':'; 254 return fh; 255 // return -1; // listen sockets on DECnet are not supportet at the moment 256 } else { 257 // There is nothing wrong in this case to use dnet_conn() so we do. 174 258 fh = dnet_conn(host, obj, SOCK_STREAM, 0 ,0 ,0 , 0); 175 259 *del = ':'; -
roard/roard.c
r501 r508 46 46 printf(" -t --tcp - Use TCP listen socket\n" 47 47 " -u --unix - Use UNIX Domain listen socket (default)\n" 48 #ifdef ROAR_HAVE_LIBDNET 49 " -n --decnet - use DECnet listen socket\n" 50 #endif 48 51 " -p --port - TCP Port to bind to\n" 49 52 " -b --bind - IP/Hostname to bind to\n" … … 92 95 DRIVER_USERDATA_T drvinst; 93 96 struct roar_client * self = NULL; 97 #ifdef ROAR_HAVE_LIBDNET 98 char decnethost[80]; 99 #endif 94 100 95 101 g_listen_socket = -1; … … 217 223 } else if ( strcmp(k, "-u") == 0 ) { 218 224 // ignore this case as it is the default behavor. 225 } else if ( strcmp(k, "-n") == 0 ) { 226 #ifdef ROAR_HAVE_LIBDNET 227 port = ROAR_DEFAULT_NUM; 228 strcpy(decnethost, ROAR_DEFAULT_LISTEN_OBJECT); 229 server = decnethost; 230 #else 231 ROAR_ERR("No DECnet support compiled in!"); 232 return 1; 233 #endif 219 234 } else if ( strcmp(k, "-G") == 0 ) { 220 235 sock_grp = argv[++i]; -
roard/streams.c
r495 r508 522 522 int streams_check (int id) { 523 523 int fh; 524 ssize_t req ;524 ssize_t req, realreq, done; 525 525 struct roar_stream * s; 526 526 struct roar_stream_server * ss; … … 557 557 558 558 if ( ss->codecfilter == -1 ) { 559 realreq = req; 560 /* 559 561 req = read(fh, buf, req); 562 if ( req < realreq ) { // we can do this as the stream is in nonblocking mode! 563 if ( (realreq = read(fh, buf+req, realreq-req)) > 0 ) 564 req += realreq; 565 } 566 */ 567 done = 0; 568 while (req > 0 && done != realreq) { 569 if ( (req = read(fh, buf+done, realreq-done)) > 0 ) 570 done += req; 571 } 572 req = done; 560 573 } else { 561 574 req = codecfilter_read(ss->codecfilter_inst, ss->codecfilter, buf, req);
Note: See TracChangeset
for help on using the changeset viewer.