discussion
[Top] [All Lists]

Re: [Discussion] Retrieving a CID

To: discussion@xxxxxxxxxx
Subject: Re: [Discussion] Retrieving a CID
From: Martin Röhricht <ml@xxxxxxxxxxx>
Date: Mon, 24 Oct 2005 18:38:24 +0200
Am Montag, 24. Oktober 2005 16:21 schrieb John Heffner:
> web100_connection_find() only returns a single connection, not a list
> of connections, so it required a full match on the spec.  What you need
> to do is step through the list of all connections in a loop doing a
> match on just the parts of the spec you want.  See below for an
> example.  (You seem not to have a remote port, but I'm assuming you
> do.)

Okay, that's something I already worried about. Currently the local port 
number is the only field that I do not know the value of in advance. I use 
iperf to establish a transfer between two hosts, but I couldn't figure out 
how to set the outgoing port for iperf. Maybe somebody does know how to do 
that?

> Incidentally, the equivalent python code is:
>
> import Web100
> agent = Web100.Web100Agent()
> cl = agent.connection_match('192.168.0.17', None, '192.168.0.18',
> RemotePort)
> cid = cl[0].cid
>
> It works pretty well for this if you can use it. :-)

Mmh, I would like to use only one small C program ;-)

> conn = web100_connection_head(agent);
> while (conn) {
>       spec2 = web100_get_connection_spec(conn);
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I think this has to be
        web100_get_connection_spec(conn, spec2);

>       if (spec->src_addr == spec2->src_addr && spec->dst_addr ==
> spec2->dst_addr && spec->dst_port == spec2->dst_port)
>               break;
> }
> if (conn == NULL) {
>       printf("connection not found\n");
>       return 1;
> }

Unfortunately I never get to the point "connection not found" -- it looks like 
I'm stuck in an infinite loop ...

Is this part here right to set the spec information:
-----------------------8<----------------------
const unsigned int      LocalPort = 0;
const char              LocalAddress[16] = "141.3.17.217";
const unsigned int      RemotePort = 1980;
const char              RemoteAddress[16] = "84.163.232.249";

struct web100_connection_spec   *spec;
struct  in_addr src_t, dst_t;
[...]
inet_aton(LocalAddress, &src_t);
spec->src_addr = ntohl(src_t.s_addr);
inet_aton(RemoteAddress, &dst_t);
spec->dst_addr = ntohl(dst_t.s_addr);
spec->src_port = LocalPort;
spec->dst_port = RemotePort;
-----------------------8<----------------------

Mmh, the only thing I would like to do is to get the CID for given addresses 
and ports. What can I do?

Martin

_______________________________________________
Discussion mailing list
Discussion@xxxxxxxxxx
http://internal.web100.org/mailman/listinfo/discussion

<Prev in Thread] Current Thread [Next in Thread>