Beispiel #1
0
static void atarisys2_init_machine (int slapstic)
{
	int ch;


	atarigen_init_machine (atarisys2_soundint, slapstic);
	last_sound_reset = 0;
	irq_hold0 = irq_hold2 = irq_hold3 = 1;
	tms5220_data_strobe = 1;
	/* set panning for the two pokey chips */
	for (ch = 0;ch < MAX_STREAM_CHANNELS;ch++)
	{
		if (stream_get_name(ch) != 0 &&
				!strcmp(stream_get_name(ch),"Pokey #0"))
			stream_set_pan(ch,OSD_PAN_LEFT);
		if (stream_get_name(ch) != 0 &&
				!strcmp(stream_get_name(ch),"Pokey #1"))
			stream_set_pan(ch,OSD_PAN_RIGHT);
	}
	which_adc = 0;
	pedal_value[0] = pedal_value[1] = pedal_value[2] = 0;
	pedal_count = 0;
}
Beispiel #2
0
int main()
{

    struct pstream* p_pstream; 
    struct stream* p_stream;
    const char* pstream_name = "ptcp:1234";
    char buffer[50];
    uint8_t dscp = 1;
    int actualrecv = 0;


    if(pstream_open(pstream_name,&p_pstream,dscp))
        printf("pstream open failure!\n");
    else
    {
        while(1)
        {  
    
	    while(pstream_accept(p_pstream, &p_stream))
                ;
            printf("\nget one steam connect success!\n");

            printf("p_pstream name:%s\n", pstream_get_name(p_pstream));
            printf("p_pstream bound_port:%d\n", pstream_get_bound_port(p_pstream));
	    printf("p_stream name:%s\n", stream_get_name(p_stream));


            printf("<remote_ip,remote_port> : <%d,%d>\n", stream_get_remote_ip(p_stream),stream_get_remote_port(p_stream));
            printf("<local_ip,local_port> : <%d,%d>\n", stream_get_local_ip(p_stream),stream_get_local_port(p_stream));

            actualrecv = stream_recv(p_stream,buffer,sizeof(buffer));
 
           if(actualrecv < 0)
              printf("pstream receive failure!\n");
           else if(actualrecv == 0)
               printf("pstream receive 0 bytes!\n");
           else
               printf("pstream actual receive %d bytes,buffer:%s\n\n",actualrecv,buffer);

         }


        stream_close(p_stream);
        pstream_close(p_pstream);

    }   
 
    return 0;
}
Beispiel #3
0
/* Returns a new JSON-RPC stream that uses 'stream' for input and output.  The
 * new jsonrpc object takes ownership of 'stream'. */
struct jsonrpc *
jsonrpc_open(struct stream *stream)
{
    struct jsonrpc *rpc;

    ovs_assert(stream != NULL);

    rpc = xzalloc(sizeof *rpc);
    rpc->name = xstrdup(stream_get_name(stream));
    rpc->stream = stream;
    byteq_init(&rpc->input, rpc->input_buffer, sizeof rpc->input_buffer);
    list_init(&rpc->output);

    return rpc;
}
static struct vconn *
vconn_stream_new(struct stream *stream, int connect_status,
                 uint32_t allowed_versions)
{
    struct vconn_stream *s;

    s = xmalloc(sizeof *s);
    vconn_init(&s->vconn, &stream_vconn_class, connect_status,
               stream_get_name(stream), allowed_versions);
    s->stream = stream;
    s->txbuf = NULL;
    s->rxbuf = NULL;
    s->n_packets = 0;
    return &s->vconn;
}
Beispiel #5
0
static struct vconn *
vconn_stream_new(struct stream *stream, int connect_status)
{
    struct vconn_stream *s;

    s = malloc(sizeof *s);
    vconn_init(&s->vconn, &stream_vconn_class, connect_status,
               stream_get_name(stream));
    s->stream = stream;
    s->txbuf = NULL;
    s->rxbuf = NULL;
    s->n_packets = 0;
    s->vconn.remote_ip = stream_get_remote_ip(stream);
    s->vconn.remote_port = stream_get_remote_port(stream);
    s->vconn.local_ip = stream_get_local_ip(stream);
    s->vconn.local_port = stream_get_local_port(stream);
    return &s->vconn;
}
Beispiel #6
0
static int
ssl_connect(struct stream *stream)
{
    struct ssl_stream *sslv = ssl_stream_cast(stream);
    int retval;

    switch (sslv->state) {
    case STATE_TCP_CONNECTING:
        retval = check_connection_completion(sslv->fd);
        if (retval) {
            return retval;
        }
        sslv->state = STATE_SSL_CONNECTING;
        setsockopt_tcp_nodelay(sslv->fd);
        /* Fall through. */

    case STATE_SSL_CONNECTING:
        /* Capture the first few bytes of received data so that we can guess
         * what kind of funny data we've been sent if SSL negotiation fails. */
        if (sslv->n_head <= 0) {
            sslv->n_head = recv(sslv->fd, sslv->head, sizeof sslv->head,
                                MSG_PEEK);
        }

        retval = (sslv->type == CLIENT
                   ? SSL_connect(sslv->ssl) : SSL_accept(sslv->ssl));
        if (retval != 1) {
            int error = SSL_get_error(sslv->ssl, retval);
            if (retval < 0 && ssl_wants_io(error)) {
                return EAGAIN;
            } else {
                int unused;

                interpret_ssl_error((sslv->type == CLIENT ? "SSL_connect"
                                     : "SSL_accept"), retval, error, &unused);
                shutdown(sslv->fd, SHUT_RDWR);
                stream_report_content(sslv->head, sslv->n_head, STREAM_SSL,
                                      &this_module, stream_get_name(stream));
                return EPROTO;
            }
        } else if (bootstrap_ca_cert) {
            return do_ca_cert_bootstrap(stream);
        } else if (verify_peer_cert
                   && ((SSL_get_verify_mode(sslv->ssl)
                       & (SSL_VERIFY_NONE | SSL_VERIFY_PEER))
                       != SSL_VERIFY_PEER)) {
            /* Two or more SSL connections completed at the same time while we
             * were in bootstrap mode.  Only one of these can finish the
             * bootstrap successfully.  The other one(s) must be rejected
             * because they were not verified against the bootstrapped CA
             * certificate.  (Alternatively we could verify them against the CA
             * certificate, but that's more trouble than it's worth.  These
             * connections will succeed the next time they retry, assuming that
             * they have a certificate against the correct CA.) */
            VLOG_INFO("rejecting SSL connection during bootstrap race window");
            return EPROTO;
        } else {
            return 0;
        }
    }

    OVS_NOT_REACHED();
}