-/*
-
-static void accept_conn_cb(struct evconnlistener *listener, evutil_socket_t fd, struct sockaddr *address, int socklen, void *ctx)
-{
- struct session_s *s = (struct session_s*)ctx;
- struct timeval tv = {1, 0};
-
- s->fd = fd;
- s->ev = event_new(base, fd, EV_READ | EV_PERSIST , event_handler, s);
- event_add(s->ev, &tv);
-}
-
-static int jtagremote_new(void **sess, char *args)
-{
- int ret = RC_OK;
- struct session_s *s = NULL;
- char *cport = NULL;
- int port;
- struct evconnlistener *listener;
- struct sockaddr_in sin;
-
- if(!sess) {
- ret = RC_INVARG;
- goto out;
- }
-
- ret = litex_sim_module_get_args(args, "port", &cport);
- if(RC_OK != ret)
- goto out;
-
- printf("Found port %s\n", cport);
- sscanf(cport, "%d", &port);
- free(cport);
- if(!port) {
- ret = RC_ERROR;
- fprintf(stderr, "Invalid port selected!\n");
- goto out;
- }
-
- s=(struct session_s*)malloc(sizeof(struct session_s));
- if(!s) {
- ret = RC_NOENMEM;
- goto out;
- }
- memset(s, 0, sizeof(struct session_s));
-
- memset(&sin, 0, sizeof(sin));
- sin.sin_family = AF_INET;
- sin.sin_addr.s_addr = htonl(0);
- sin.sin_port = htons(port);
- listener = evconnlistener_new_bind(base, accept_conn_cb, s, LEV_OPT_CLOSE_ON_FREE|LEV_OPT_REUSEABLE, -1, (struct sockaddr*)&sin, sizeof(sin));
- if (!listener) {
- ret=RC_ERROR;
- eprintf("Can't bind port %d\n!\n", port);
- goto out;
- }
- evconnlistener_set_error_cb(listener, accept_error_cb);
-
-out:
- *sess=(void*)s;
- return ret;
-}
-
-*/
-