Hi Eric,
I mis-read your initial message and didn't notice you were looking to
connect to the topology server. I had also set up something similar
(code below). Your call back routines should be getting called, I am
not sure why they do not get called.
I did not seem to have to call tipc_connect2port() in this example (as
Jon says, this is done for you).
See if this might help.
Elmer
The following code was used to detect the withdrawl of a TIPC name in
the system.
Notes:
- Remove the higprintf() calls which I used for debugging at one point.
- address_family and quitFlag are global variables
/**
* mon_shutdown_event - handle connection termination message
*/
static void mon_shutdown_cb(void *usr_handle,
u32 port_ref,
struct sk_buff **buf,
unsigned char const *data,
unsigned int size,
int reason)
{
/* Record reason for connection termination */
higprintf("mon_shutdown_event: connection terminated on port %d to
top srv.\n", port_ref);
/* TIPC has already disconnected port, so just delete it */
tipc_deleteport(port_ref);
quitFlag = 1; /* signal main task that we are done */
}
/*****************************************************************
*
* mon_msg_event_cb - call back for a message event
*
* Used in this code to receive any topology server message based
* on monitoring of the relevant {type,instance}.
*
* where:
*
* buf = data packet
* size = number of bytes per "blast"
*
* RETURNS: N/A
*/
static void mon_conn_msg_event_cb(void *usr_handle,
u32 port_ref,
struct sk_buff **buf,
unsigned char const *data,
unsigned int size,
unsigned int importance,
struct tipc_portid const *orig,
struct tipc_name_seq const *destination)
{
struct tipc_event * event; /* topology events
(subscription) */
int res; /* result of an operation */
higprintf("mon_conn_msg_event_cb: received a message of %d bytes on
port %d\n", size, port_ref);
event = (struct tipc_event *)data; /*
point event to data */
printf("mon_conn_msg_event_cb: received subscription event
(event=%d)\n", event->event);
if (event->event == TIPC_SUBSCR_TIMEOUT)
{
minprintf ("mon_conn_msg_event_cb: Subscription timed out?? (was
forever)\n");
goto monitorExit;
}
if (event->event == TIPC_WITHDRAWN)
{
minprintf ("mon_conn_msg_event_cb: Subscription was withdrawn,
cannot continue. (shutdown of port %d)\n", port_ref);
goto monitorExit;
}
higprintf("mon_conn_msg_event_cb: event information:\n");
higprintf(" event = %d, event lower=%d, upper=%d\n",
event->event,
event->found_lower, event->found_upper);
higprintf(" portid.ref=%d, portid.node=0x%x\n",
event->port.ref,
event->port.node);
/* signal main that it can go ahead */
eventSend(callTask, VXEV01);
/* keep monitoring for a withdrawl */
return;
monitorExit:
/* set global to stop this run */
quitFlag = 1;
res = tipc_shutdown(port_ref);
if (res)
{
higprintf("mon_conn_msg_event_cb: shutdown of port %d had
result=%d (errno=%d)\n",
port_ref, res, errno);
}
if (address_family == NATIVE_TIPC)
{
/* wake up other routine to let it gracefully exit */
SEND_TRIGGER;
higprintf("mon_conn_msg_event_cb: giving semNativeSend\n");
}
res = tipc_deleteport(port_ref);
if (res)
{
higprintf("mon_conn_msg_event_cb: deleteport of port %d had
result=%d (errno=%d)\n",
port_ref, res, errno);
}
return;
}
/*****************************************************************
*
* monitorBlastTask - Monitor the publication of the receiver of msgs
*
* In this version, the monitor sets up a connection to the topology
* server using the Native API. No sockets used.
*
* monitorBlastTask (void)
*
* where:
* callingTask = Task ID of caller
*
* RETURNS: STATUS
*/
STATUS monitorBlastTask (int callingTask)
{
struct tipc_subscr subscr; /* subscription of interest
*/
struct tipc_name name; /* name to send to */
int res; /* result of operations */
u32 port_ref; /* port for communications
to top srv */
struct iovec msg_sect; /* iovec for data */
/* start */
/* now set up and begin */
/* set up subscription */
subscr.seq.type = TIPC_EXPERIMENT_TYPE;
subscr.seq.lower = TIPC_EXPERIMENT_INSTANCE;
subscr.seq.upper = TIPC_EXPERIMENT_INSTANCE;
subscr.timeout = TIPC_WAIT_FOREVER;
subscr.filter = TIPC_SUB_PORTS;
/* set up addressing */
name.type = TIPC_TOP_SRV;
name.instance = TIPC_TOP_SRV;
res = tipc_attach(&port_ref, NULL, NULL);
if (res)
higprintf("monitorBlastTask: tipc_attach returned %d
(errno=%d)\n", res, errno);
res = tipc_createport(port_ref, NULL, TIPC_LOW_IMPORTANCE,
NULL, NULL, mon_shutdown_cb,
NULL, NULL,
mon_conn_msg_event_cb, NULL, &port_ref);
if (res)
return res;
/* send first message to port */
msg_sect.iov_base = (char *)&subscr;
msg_sect.iov_len = sizeof(subscr);
tipc_send2name(port_ref,
&name,
0 /* domain of 0:own zone */,
1 /* num_sect */,
msg_sect);
return OK;
}
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Erich Focht
Sent: Friday, February 22, 2008 1:22 PM
To: Horvath, Elmer
Cc: [email protected]
Subject: Re: [tipc-discussion] port name -> port_id ?
Dear Elmer,
thanks for your reply. I roughly know how to deal with the port ref in a
callback. My problem is: I'd like to use the subscription service from a
kernel module and monitor the publishing of a certain set of ports.
What I tried (and didn't work) is listed below. The documentation on
subscriptions says that one needs to connect to the subscription
service, so I was looking for a way to do tipc_connect2port (meaning {1,
1}, the local subscription service).
static int __init subscr_monitor_init(void) {
struct tipc_name_seq seq;
struct iovec my_iov;
struct tipc_subscr sub;
struct tipc_name subsvc = { TIPC_TOP_SRV, TIPC_TOP_SRV };
u32 port_ref;
int res;
res = tipc_attach(&user_ref, NULL, NULL);
if (res)
return res;
res = tipc_createport(user_ref, NULL, TIPC_LOW_IMPORTANCE,
NULL, NULL, NULL,
msg_event_cb, named_msg_event,
c_named_msg_event_cb,
NULL, &port_ref);
if (res)
return res;
//tipc_connect2port(port_ref, ??);
sub.seq.type = 65;
sub.seq.lower = 0;
sub.seq.upper = 256;
sub.timeout = TIPC_WAIT_FOREVER;
sub.filter = TIPC_SUB_PORTS;
my_iov.iov_base = ⊂
my_iov.iov_len = sizeof(sub);
//res = tipc_send2name(port_ref, &subsvc, tipc_get_addr(), 1,
&my_iov);
res = tipc_send2name(port_ref, &subsvc, 0, 1, &my_iov);
return res;
}
I never see anything spit out by the module though I publish ports in
the range that should be monitored :-(
What am I doing wrong?
Best regards,
Erich
------------------------------------------------------------------------
-
This SF.net email is sponsored by: Microsoft Defy all challenges.
Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
tipc-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tipc-discussion
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
tipc-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tipc-discussion