Changeset 508:1129ff87dd1e in roaraudio


Ignore:
Timestamp:
08/15/08 00:40:31 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added DECnet listen support, introused -n/--decnet to roard, added woraround to Linux DECnet stack bugs on streams and added some helpfull DECnet macros, puh...

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/socket.h

    r502 r508  
    3636int roar_socket_new_udp    (void); 
    3737int roar_socket_new_unix   (void); 
     38int roar_socket_new_decnet_seqpacket (void); 
     39int roar_socket_new_decnet_stream (void); 
     40 
    3841int roar_socket_open       (int mode, int type, char * host, int port); 
    3942int roar_socket_open_fork  (int mode, char * host, int port); 
    4043int roar_socket_open_file  (int mode, char * host, int port); 
    4144int roar_socket_open_proxy (int mode, int type, char * host, int port, char * proxy_type); 
     45 
     46int roar_socket_listen_decnet (char * object, int num); 
    4247 
    4348int roar_socket_nonblock(int fh, int state); 
  • include/roaraudio.h

    r480 r508  
    5252#include <libroar/libroar.h> 
    5353 
     54// IP 
    5455#define ROAR_DEFAULT_PORT        16002 
    5556#define ROAR_DEFAULT_HOST        "localhost" 
    5657 
     58// UNIX Domain Sockets 
    5759#define ROAR_DEFAULT_SOCK_GLOBAL "/tmp/roar" 
    5860#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 
    5966 
    6067#define ROAR_DEFAULT_SOCKGRP     "audio" 
     
    118125#define ROAR_HOST2NET16(x) (x) 
    119126 
     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 
    120135//#elif BYTE_ORDER == LITTLE_ENDIAN 
    121136#else 
     
    126141#define ROAR_HOST2NET16(x) htons((x)) 
    127142 
     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 
    128155#endif 
    129156 
  • libroar/socket.c

    r503 r508  
    4242 return fh; 
    4343} 
     44 
     45int 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 
     58int 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 
    4470 
    4571int roar_socket_nonblock(int fh, int state) { 
     
    119145  return roar_socket_open_proxy(MODE_CONNECT, ROAR_SOCKET_TYPE_UNKNOWN, host, port, proxy_type); 
    120146 } 
     147} 
     148 
     149 
     150int 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 
    121194} 
    122195 
     
    153226 
    154227 if ( type == ROAR_SOCKET_TYPE_DECNET ) { 
    155   if ( mode == MODE_LISTEN ) { 
    156    return -1; // listen sockets on DECnet are not supportet at the moment 
    157   } else { 
    158228#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); 
    160230   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 
    161238   *del = 0; 
    162239 
     
    172249   } 
    173250 
     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. 
    174258   fh = dnet_conn(host, obj, SOCK_STREAM, 0 ,0 ,0 , 0); 
    175259   *del = ':'; 
  • roard/roard.c

    r501 r508  
    4646 printf(" -t  --tcp             - Use TCP listen socket\n" 
    4747        " -u  --unix            - Use UNIX Domain listen socket (default)\n" 
     48#ifdef ROAR_HAVE_LIBDNET 
     49        " -n  --decnet          - use DECnet listen socket\n" 
     50#endif 
    4851        " -p  --port            - TCP Port to bind to\n" 
    4952        " -b  --bind            - IP/Hostname to bind to\n" 
     
    9295 DRIVER_USERDATA_T drvinst; 
    9396 struct roar_client * self = NULL; 
     97#ifdef ROAR_HAVE_LIBDNET 
     98 char decnethost[80]; 
     99#endif 
    94100 
    95101 g_listen_socket = -1; 
     
    217223  } else if ( strcmp(k, "-u") == 0 ) { 
    218224   // 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 
    219234  } else if ( strcmp(k, "-G") == 0 ) { 
    220235   sock_grp  = argv[++i]; 
  • roard/streams.c

    r495 r508  
    522522int streams_check  (int id) { 
    523523 int fh; 
    524  ssize_t req; 
     524 ssize_t req, realreq, done; 
    525525 struct roar_stream        *   s; 
    526526 struct roar_stream_server *  ss; 
     
    557557 
    558558 if ( ss->codecfilter == -1 ) { 
     559  realreq = req; 
     560/* 
    559561  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; 
    560573 } else { 
    561574  req = codecfilter_read(ss->codecfilter_inst, ss->codecfilter, buf, req); 
Note: See TracChangeset for help on using the changeset viewer.