Example #1
0
static int addr_peer(void)
{
    ne_socket *sock = ne_sock_create();
    ne_inet_addr *ia, *ia2;
    unsigned int port = 9999, realport;
    int ret;

    ia = ne_iaddr_make(ne_iaddr_ipv4, raw_127);
    ONN("ne_iaddr_make returned NULL", ia == NULL);
    
    CALL(new_spawn_server(1, serve_close, NULL, &realport));
    ONN("could not connect", ne_sock_connect(sock, ia, realport));

    ia2 = ne_sock_peer(sock, &port);
    ret = ne_iaddr_cmp(ia, ia2);
    ONV(ret != 0,
        ("comparison of peer with server address was %d", ret));

    ONV(port != realport, ("got peer port %u, expected %u", port, realport));
 
    ne_sock_close(sock);
    CALL(await_server());

    ne_iaddr_free(ia);
    ne_iaddr_free(ia2);
    return OK;
}
Example #2
0
static int blocking(void)
{
    ne_socket *sock;
    int ret;
    
    CALL(begin(&sock, echo_server, NULL));
    CALL(expect_block_timeout(sock, 1, "with non-zero timeout"));
         
    WRITEL("Hello, world.\n");
    
    /* poll for data */
    do {
        ret = ne_sock_block(sock, 1);
    } while (ret == NE_SOCK_TIMEOUT);

    ONV(ret != 0, ("ne_sock_block never got data: %d", ret));

    PEEK("Hello,");
    ret = ne_sock_block(sock, 1);
    ONV(ret != 0, ("ne_sock_block failed after peek: %d", ret));

    LINE("Hello, world.\n");

    return finish(sock, 0);
}
Example #3
0
static int copy_overwrite(void)
{
    PRECOND(copy_ok);

    /* Do it again with Overwrite: F to check that fails. */
    ONN("COPY on existing resource with Overwrite: F should fail (RFC2518:S8.8.4)",
	ne_copy(i_session, 0, NE_DEPTH_INFINITE, src, dest) != NE_ERROR);

    if (STATUS(412)) {
	t_warning("COPY-on-existing fails with 412");
    }
    
    ONV(ne_copy(i_session, 1, NE_DEPTH_INFINITE, src, dest),
	("COPY-on-existing with 'Overwrite: T' should succeed (RFC2518:S8.8.4): %s", ne_get_error(i_session)));

    /* tricky one this, I didn't think it should work, but the spec
     * makes it look like it should. */
    ONV(ne_copy(i_session, 1, NE_DEPTH_INFINITE, src, coll),
	("COPY overwrites collection: %s", ne_get_error(i_session)));
    
    if (STATUS(204)) {
	t_warning("COPY to existing resource didn't give 204 (RFC2518:S8.8.5)");
    }

    return OK;
}
Example #4
0
void
my_mkcol2_proppatch(char* uri, int depth, const ne_propname pops[])
{
	char tmp[256] = "/tmp/Davtest-XXXXXX";
	char myuri[128];
	int i, fd;

	if ( (fd=mkstemp(tmp)) < 0){
		perror("mkstemp() :");
		return ;
	}

	for( i=0; i<4; i++)
		write(fd, tmp, sizeof(tmp));

	if ( depth > 1){
		memset(myuri, 0, sizeof(myuri));
		strcpy( myuri, uri);
		sprintf( myuri, "%ssub/", myuri);
    		ONV(ne_mkcol(i_session, myuri), 
			("MKCOL %s: %s", myuri, ne_get_error(i_session)));
		ONMREQ("PROPPATCH",myuri, ne_proppatch(i_session, myuri, pops));
		my_mkcol2( myuri, depth-1);
	}else if ( depth == 1)
		for ( i=0; i<pget_option.width; i++){
			memset(myuri, 0, sizeof(myuri));
			strcpy( myuri, uri);
			sprintf( myuri, "%sfile%d", myuri, i);
    			ONV(ne_put(i_session, myuri, fd),
				("PUT of %s: %s", myuri, ne_get_error(i_session)));
		}

	return;
}
Example #5
0
/* Exect a read() to return EOF */
static int expect_close(ne_socket *sock)
{
    ssize_t n = ne_sock_read(sock, buffer, 1);
    ONV(n > 0, ("read got %" NE_FMT_SSIZE_T " bytes not closure", n));
    ONV(n < 0 && n != NE_SOCK_CLOSED,
	("read got error not closure: `%s'", ne_sock_error(sock)));
    return OK;
}
Example #6
0
/* do a sock_read() on sock for 'len' bytes, and expect 'str'. */
static int fullread_expect(ne_socket *sock, const char *str, size_t len)
{
    ssize_t ret = ne_sock_fullread(sock, buffer, len);
    ONV(ret, ("fullread failed (%" NE_FMT_SSIZE_T "): %s", 
              ret, ne_sock_error(sock)));
    ONV(memcmp(str, buffer, len),
	("fullread mismatch: `%.*s' not `%.*s'", 
	 (int)len, buffer, (int)len, str));    
    return OK;
}
Example #7
0
/* do a sock_read() on sock for 'len' bytes, and expect 'str'. */
static int read_expect(ne_socket *sock, const char *str, size_t len)
{
    ssize_t ret = ne_sock_read(sock, buffer, len);
    ONV((ssize_t)len != ret,
	("read got %" NE_FMT_SSIZE_T " bytes not %" NE_FMT_SIZE_T, ret, len));
    ONV(memcmp(str, buffer, len),
	("read mismatch: `%.*s' not `%.*s'", 
	 (int)len, buffer, (int)len, str));    
    return OK;
}
Example #8
0
static int addr_make_v6(void)
{
#ifdef TEST_IPV6   
    struct {
	const unsigned char *addr;
	const char *rep;
    } as[] = {
	{ raw6_cafe, "feed::cafe" },
	{ raw6_babe, "cafe:babe::" },
	{ raw6_nuls, "::" },
	{ NULL, NULL }
    };
    int n;
    
    for (n = 0; as[n].rep != NULL; n++) {
	ne_inet_addr *ia = ne_iaddr_make(ne_iaddr_ipv6, as[n].addr);
	char pr[128];
        unsigned char raw[17];

	ONV(ia == NULL, ("could not make address for '%s'", 
                         as[n].rep));

	ne_iaddr_print(ia, pr, sizeof pr);
	ONV(strcmp(pr, as[n].rep), 
	    ("address %d was '%s' not '%s'", n, pr, as[n].rep));
	
        ONN("bogus ne_iaddr_typeof return", ne_iaddr_typeof(ia) != ne_iaddr_ipv6);

        raw[16] = 'Z';
        ONN("ne_iaddr_raw gave bad retval", ne_iaddr_raw(ia, raw) != raw);
        ONN("raw address mismatch", memcmp(raw, as[n].addr, 4) != 0);
        ONN("ne_iaddr_raw buffer overflow", raw[16] != 'Z');
        
	ne_iaddr_free(ia);
        
        ia = ne_iaddr_parse(as[n].rep, ne_iaddr_ipv6);
        ONV(ia == NULL, ("ne_iaddr_parse failed for %s", as[n].rep));
        ONN("bogus ne_iaddr_typeof return", ne_iaddr_typeof(ia) != ne_iaddr_ipv6);
        ONN("ne_iaddr_raw gave bad retval", ne_iaddr_raw(ia, raw) != raw);
        ONN("raw address mismatch", memcmp(raw, as[n].addr, 4) != 0);
        ONN("ne_iaddr_raw buffer overflow", raw[16] != 'Z');

        ne_iaddr_free(ia);
   }

    return OK;
#else
    /* should fail when lacking IPv6 support. */
    ne_inet_addr *ia = ne_iaddr_make(ne_iaddr_ipv6, raw6_nuls);
    ONN("ne_iaddr_make did not return NULL", ia != NULL);
    ONN("ne_iaddr_parse did not return NULL", ne_iaddr_parse("127.0.0.1", ne_iaddr_ipv6));
#endif
    return OK;
}
Example #9
0
static int line_expect(ne_socket *sock, const char *line)
{
    ssize_t ret = ne_sock_readline(sock, buffer, BUFSIZ);
    size_t len = strlen(line);
    NE_DEBUG(NE_DBG_SOCKET, " -> expected=%s -> actual=%s", line, buffer);
    ONV(ret == NE_SOCK_CLOSED, ("socket closed, expecting `%s'", line));
    ONV(ret < 0, ("socket error `%s', expecting `%s'", 
		  ne_sock_error(sock), line));
    ONV((size_t)ret != len || strcmp(line, buffer),
	("readline mismatch: `%s' not `%s'", buffer, line));
    return OK;
}
static int strnzcpy(void)
{
    char buf[5];

    ne_strnzcpy(buf, "abcdefghi", sizeof buf);
    ONV(strcmp(buf, "abcd"), ("result was `%s' not `abcd'", buf));
    
    ne_strnzcpy(buf, "ab", sizeof buf);
    ONV(strcmp(buf, "ab"), ("result was `%s' not `ab'", buf));    

    return OK;    
}
Example #11
0
static int resolve_numeric(void)
{
    ne_sock_addr *addr = ne_addr_resolve("127.0.0.1", 0);
    ONV(ne_addr_result(addr),
	("failed to resolve 127.0.0.1: %s",
	 ne_addr_error(addr, buffer, sizeof buffer)));
    ONN("ne_addr_first returned NULL", ne_addr_first(addr) == NULL);
    ONN("ne_iaddr_print didn't return buffer", 
	ne_iaddr_print(ne_addr_first(addr), buffer, sizeof buffer) != buffer);
    ONV(strcmp(buffer, "127.0.0.1"), ("ntop gave `%s' not 127.0.0.1", buffer));
    ne_addr_destroy(addr);
    return OK;
}
Example #12
0
static int lock_collection(void)
{
    struct ne_lock dummy;
    char *tmp,*tmp2;
    
    CALL(getlock(ne_lockscope_exclusive, NE_DEPTH_INFINITE));
    
    PRECOND(gotlock);

    memcpy(&dummy, &reslock, sizeof(reslock));
    dummy.token = NULL;
    dummy.uri.path = collZ;
    dummy.owner = ne_strdup("litmus: owner lock");
    dummy.depth = NE_DEPTH_INFINITE;
    dummy.type = ne_locktype_write;
    dummy.scope = ne_lockscope_exclusive;
    
    ONNREQ2("LOCK on second collection for further tests", 
	    ne_lock(i_session, &dummy));
    gotlock = ne_lock_copy(&dummy);
    ne_lockstore_add(store, gotlock);

    /* Testing creation of directories under a collection */ 
    ONV(ne_mkcol(i_session, collX),
        ("MKCOL %s: %s", collX, ne_get_error(i_session)));
    ONV(ne_mkcol(i_session, collY),
        ("MKCOL %s: %s", collY, ne_get_error(i_session)));

    upload_foo("lockcoll/collX/temp");
    tmp = ne_concat(collY,"copy-temp",NULL);	
    ONV(ne_copy(i_session, 0, NE_DEPTH_INFINITE, res3,tmp),
	("collection COPY `%s' to `%s': %s", res2, tmp,
	 ne_get_error(i_session)));
    free(tmp);
    
    tmp2=ne_concat(collZ,"testing",NULL);
    ONV(ne_copy(i_session, 0, NE_DEPTH_INFINITE, res3,tmp2),
	("collection COPY `%s' to `%s': %s", res2, tmp2,
	 ne_get_error(i_session)));

    ne_free(res3);	
    res3 = ne_concat(i_path,"not-existing",NULL);

 
    /* change res to point to a normal resource for subsequent
     * {not_,}owner_modify tests */
    res = ne_concat(coll, "lockme.txt", NULL);
    return upload_foo("lockcoll/lockme.txt");
}
Example #13
0
/* do a sock_peek() on sock for 'len' bytes, and expect 'str'. */
static int peek_expect(ne_socket *sock, const char *str, size_t len)
{
    ssize_t ret;
    memset(buffer, '@', sizeof buffer);
    ret = ne_sock_peek(sock, buffer, len);
    ONV((ssize_t)len != ret, 
	("peek got %" NE_FMT_SSIZE_T " bytes not %" NE_FMT_SIZE_T, ret, len));
    ONV(memcmp(str, buffer, len),
	("peek mismatch: `%.*s' not `%.*s'", 
	 (int)len, buffer, (int)len, str));
    ONV(buffer[len] != '@',
        ("buffer overrun: %" NE_FMT_SSIZE_T "nth byte was '%c' not '@'", 
         len, buffer[len]));
    return OK;
}
Example #14
0
int discard_request(ne_socket *sock)
{
    char buffer[1024];
    size_t offset = want_header?strlen(want_header):0;

    clength = 0;

    NE_DEBUG(NE_DBG_HTTP, "Discarding request...\n");
    do {
	ONV(ne_sock_readline(sock, buffer, 1024) < 0,
	    ("error reading line: %s", ne_sock_error(sock)));
	NE_DEBUG(NE_DBG_HTTP, "[req] %s", buffer);
	if (strncasecmp(buffer, "content-length:", 15) == 0) {
	    clength = atoi(buffer + 16);
	}
	if (got_header != NULL && want_header != NULL &&
	    strncasecmp(buffer, want_header, offset) == 0 &&
	    buffer[offset] == ':') {
	    char *value = buffer + offset + 1;
	    if (*value == ' ') value++;
	    got_header(ne_shave(value, "\r\n"));
	}
    } while (strcmp(buffer, "\r\n") != 0);

    return OK;
}
Example #15
0
static int addr_reverse(void)
{
    ne_inet_addr *ia = ne_iaddr_make(ne_iaddr_ipv4, raw_127);
    char buf[128], *syshost = NULL;

#ifdef HAVE_GETHOSTNAME
    char host[128];

    if (gethostname(host, sizeof host) == 0) {
        syshost = host;
    }
#endif

    ONN("ne_iaddr_make returned NULL", ia == NULL);

    ONN("reverse lookup for 127.0.0.1 failed",
        ne_iaddr_reverse(ia, buf, sizeof buf) != 0);

    ONV(!(strcmp(buf, "localhost.localdomain") == 0
          || strcmp(buf, "localhost") == 0
          || (syshost && strcmp(buf, syshost) == 0)),
        ("reverse lookup for 127.0.0.1 got %s", buf));

    ne_iaddr_free(ia);

    return OK;
}
static int cleaner(void)
{
    static const char *strings[] = {
        "alpha", "alpha",
        "pretty\033[41mcolours", "pretty [41mcolours",
        "beta\n", "beta ",
        "del\rt\na", "del t a",
        FOX_STRING, FOX_STRING,
        "0123456789", "0123456789",
        PUNC_STRING, PUNC_STRING,
        "\01blah blee\05bloo", " blah blee bloo",
        NULL,
    };
    unsigned int n;
    
    for (n = 0; strings[n]; n+=2) {
        char *act = ne_strclean(ne_strdup(strings[n]));
        
        ONV(strcmp(act, strings[n+1]), 
            ("cleansed to `%s' not `%s'", act, strings[n+1]));
        
        ne_free(act);
    }

    return OK;
}
Example #17
0
static int full_writev(ne_socket *sock, struct ne_iovec *vec, int count)
{
    int ret = ne_sock_fullwritev(sock, vec, count);
    NE_DEBUG(NE_DBG_SOCKET, "wrote vector (%d)\n", count);
    ONV(ret, ("writev failed (%d): %s", ret, ne_sock_error(sock)));
    return OK;
}
static int printing(void)
{
    struct {
        const char *in, *out;
        size_t pass, ret;
    } ts[] = {
        { "alpha", "alpha", 10, 5 },
        { "alpha", "alph", 5, 4 },
        { "foobar", "", 1, 0 },
        { NULL, NULL, 0, 0}
    };
    size_t n;

    for (n = 0; ts[n].in; n++) {
        char buf[512];
        size_t ret;

        memset(buf, 'A', sizeof buf);

        ret = ne_snprintf(buf, ts[n].pass, "%s", ts[n].in);
        
        ONCMP(buf, ts[n].out);
        ONV(ret != ts[n].ret, 
            ("got return value %" NE_FMT_SIZE_T " not %" NE_FMT_SIZE_T,
             ret, ts[n].ret));

        /* byte past the NUL must still be 'A' */
        ONN("buffer over-ran!", buf[ret + 1] != 'A');
    }
    
    return OK;
}
Example #19
0
static int large_get(void)
{
    ne_request *req = ne_request_create(i_session, "GET", path);
    char buffer[BLOCKSIZE], origin[BLOCKSIZE * 2];
    long long progress = 0;
    ssize_t offset = 0;
    ssize_t bytes;

    memcpy(origin, block, BLOCKSIZE);
    memcpy(origin + BLOCKSIZE, block, BLOCKSIZE);

    ONNREQ("begin large GET request", ne_begin_request(req));

    ONNREQ("failed GET request", ne_get_status(req)->klass != 2);

    while ((bytes = ne_read_response_block(req, buffer, BLOCKSIZE)) > 0) {
        ONV(memcmp(origin + offset, buffer, bytes),
            ("byte mismatch at %" NE_FMT_LONG_LONG, progress));
        offset = (offset + bytes) % BLOCKSIZE;
        progress += bytes;
    }

    ONNREQ("failed reading GET response", bytes < 0);

    ONNREQ("end large GET request", ne_end_request(req));

    ne_request_destroy(req);
    return OK;
}
Example #20
0
int full_write(ne_socket *sock, const char *data, size_t len)
{
    int ret = ne_sock_fullwrite(sock, data, len);
    NE_DEBUG(NE_DBG_SOCKET, "wrote: [%.*s]\n", (int)len, data);
    ONV(ret, ("write failed (%d): %s", ret, ne_sock_error(sock)));
    return OK;
}
Example #21
0
/* check that locks don't follow copies. */
static int copy(void)
{
    char *dest;
    int count = 0;
    
    PRECOND(gotlock);

    dest = ne_concat(res, "-copydest", NULL);

    ne_delete(i_session2, dest);

    ONNREQ2("could not COPY locked resource",
	    ne_copy(i_session2, 1, NE_DEPTH_ZERO, res, dest));
    
    ONNREQ2("LOCK discovery failed",
	    ne_lock_discover(i_session2, dest, count_discover, &count));
    
    ONV(count != 0,
	("found %d locks on copied resource", count));

    ONNREQ2("could not delete copy of locked resource",
	    ne_delete(i_session2, dest));

    free(dest);

    return OK;
}
Example #22
0
static int owner_modify(void)
{
    char *tmp;
    ne_propname pname = { "http://webdav.org/neon/litmus/", "random" };
    ne_proppatch_operation pops[] = { 
	{ NULL, ne_propset, "foobar" },
	{ NULL }
    };
    PRECOND(gotlock);

    ONV(ne_put(i_session, res, i_foo_fd),
	("PUT on locked resource failed: %s", ne_get_error(i_session)));
    
    tmp = ne_concat(i_path, "whocares", NULL);
    ONN("COPY of locked resource", 
	ne_copy(i_session, 1, NE_DEPTH_ZERO, res, tmp) == NE_ERROR);
    
   if (STATUS(201))
	t_warning("COPY failed with %d not 201", GETSTATUS);
    
    ONN("DELETE of locked resource by owner", 
	ne_delete(i_session, tmp) == NE_ERROR);

    if (STATUS(204)) 
	t_warning("DELETE of %s failed with %d not 200", tmp, GETSTATUS);
    free(tmp);
    
    ONN("PROPPATCH of locked resource",
	ne_proppatch(i_session, res, pops) == NE_ERROR);
    
    if (STATUS(207))
	t_warning("PROPPATCH failed with %d", GETSTATUS);

    return OK;
}
Example #23
0
static int socks_proxy(void)
{
    static const struct {
        enum ne_sock_sversion version;
        int addr;
        const char *fqdn;
        unsigned int port;
        const char *username, *password;
    } ts[] = {
        { NE_SOCK_SOCKSV4, 4, NULL, 55555, NULL, NULL },
        { NE_SOCK_SOCKSV4, 4, NULL, 55555, "foobar", NULL },
        { NE_SOCK_SOCKSV4A, 0, "www.example.com", 55555, NULL, NULL },
        { NE_SOCK_SOCKSV5, 0, "www.example.com", 55555, NULL, NULL },
        { NE_SOCK_SOCKSV5, 4, NULL, 55555, NULL, NULL },
#ifdef TEST_IPV6
        { NE_SOCK_SOCKSV5, 6, NULL, 55555, NULL, NULL },
#endif
        { NE_SOCK_SOCKSV5, 0, "www.example.com", 55555, "norman", "foobar" }
    };
    unsigned n;

    for (n = 0; n < sizeof(ts)/sizeof(ts[n]); n++) {
        ne_socket *sock;
        struct socks_server arg = {0};
        int ret;

        arg.version = ts[n].version;
        arg.expect_port = ts[n].port;
        if (ts[n].addr == 4)
            arg.expect_addr = ne_iaddr_make(ne_iaddr_ipv4, raw_127);
#ifdef TEST_IPV6
        else if (ts[n].addr == 6)
            arg.expect_addr = ne_iaddr_make(ne_iaddr_ipv4, raw6_cafe);
#endif
        else
            arg.expect_fqdn = ts[n].fqdn;
        arg.username = ts[n].username;
        arg.password = ts[n].password;
        
        CALL(begin_socks(&sock, &arg, echo_server, NULL));

        ret = ne_sock_proxy(sock, ts[n].version, arg.expect_addr, 
                            ts[n].fqdn, ts[n].port,
                            ts[n].username, ts[n].password);
        ONV(ret, ("proxy connect #%u gave %d", n, ret));
        FULLREAD("ok!\n");
        ECHO("hello,\n");
        ECHO("\n");
        ECHO("world\n");
        
        if (ts[n].addr)
            ne_iaddr_free(arg.expect_addr);

        CALL(finish(sock, 0));
    }

    return OK;
}
Example #24
0
static int expect_block_timeout(ne_socket *sock, int timeout, const char *msg)
{
    int ret;
    NE_DEBUG(NE_DBG_SOCKET, "blocking for %d\n", timeout);
    ret = ne_sock_block(sock, timeout);
    ONV(ret != NE_SOCK_TIMEOUT, (
            "ne_sock_block got %d not timeout: %s", ret, msg));
    return OK;
}
Example #25
0
static int resolve_ipv6(void)
{
    char err[256];
    ne_sock_addr *addr = ne_addr_resolve("[::1]", 0);
    ONV(ne_addr_result(addr),
	("could not resolve `[::1]': %s",
	 ne_addr_error(addr, err, sizeof err)));
    ne_addr_destroy(addr);
    return OK;
}
Example #26
0
int any_2xx_request(ne_session *sess, const char *uri)
{
    ne_request *req = ne_request_create(sess, "GET", uri);
    int ret = ne_request_dispatch(req);
    int klass = ne_get_status(req)->klass;
    ne_request_destroy(req);
    ONV(ret != NE_OK || klass != 2,
	("request failed: %s", ne_get_error(sess)));
    return ret;
}
static int casencmp(void)
{
    static const struct {
        const char *left, *right;
        size_t n;
        int expect;
    } ts[] = {
        { "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 30, 0 },
        { "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 10, 0 }, 
        { "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz", 0, 0 },
        { "foo", "bar", 3, 1 },
        { "bar", "foo", 4, -1 },
        { "bar", "foo", 3, -1 },
        { "foop", "foo", 4, 1 },
        { "foo", "foop", 4, -1 },
        { "bee", "bar", 0, 0},
        { NULL, NULL, 0, 0 }
    };
    size_t n;
    
    for (n = 0; ts[n].left; n++) {
        int actual;

        actual = ne_strncasecmp(ts[n].left, ts[n].right, ts[n].n);
        
        ONV(ts[n].expect == 0 && actual != 0,
            ("strncasecmp(%s, %s, %" NE_FMT_SIZE_T ") gave %d, expected 0",
             ts[n].left, ts[n].right, ts[n].n, actual));

        ONV(ts[n].expect > 0 && actual <= 0,
            ("strncasecmp(%s, %s, %" NE_FMT_SIZE_T ") gave %d, expected > 0",
             ts[n].left, ts[n].right, ts[n].n, actual));

        ONV(ts[n].expect < 0 && actual >= 0,
            ("strncasecmp(%s, %s, %" NE_FMT_SIZE_T ") gave %d, expected < 0",
             ts[n].left, ts[n].right, ts[n].n, actual));
    }

    ONN("comparison of identical pointers did not give zero",
        ne_strncasecmp(ts[0].left, ts[0].left, 5) != 0);

    return OK;
}
Example #28
0
static int resolve(void)
{
    char buf[256];
    localhost = ne_addr_resolve("localhost", 0);
    ONV(ne_addr_result(localhost),
	("could not resolve `localhost': %s", 
	 ne_addr_error(localhost, buf, sizeof buf)));
    /* and again for child.c */
    return lookup_localhost();
}
Example #29
0
/* when an EOF is received without a clean shutdown (close_notify
   message). */
static int ssl_truncate(void)
{
    ne_socket *sock; int ret;

    CALL(begin(&sock, serve_truncate, NULL));
    ret = ne_sock_read(sock, buffer, 1);
    ONV(ret != NE_SOCK_TRUNC,
	("socket got error %d not truncation: `%s'", ret,
	 ne_sock_error(sock)));
    return finish(sock, 0);
}
Example #30
0
static int begin(ne_socket **sock, server_fn fn, void *ud)
{
    struct serve_pair pair;
    pair.fn = fn;
    pair.userdata = ud;
    CALL(spawn_server(7777, wrap_serve, &pair));
    CALL(do_connect(sock, localhost, 7777));
    ONV(ne_sock_connect_ssl(*sock, client_ctx, NULL),
	("SSL negotation failed: %s", ne_sock_error(*sock)));
    return OK;
}