[olsr-dev] Question plugin - olsr_event()
Daniel Jaskiewicz
(spam-protected)
Tue Jan 18 09:46:17 CET 2005
Hello again I have a question about the power plugin example, more
specifically the olsr_event() function. What is exactly passed to it, in the
code it has olsr_event(void *foo), is this a pointer or implicit function
that is called. In the olsr_event function this foo parameter is not used at
all. The reason for this question is that Im trying to initiate this
function when information arrives on a socket and not using the scheduler
for a scheduled event, but for some reason its, not printing out the
arriving entries. Everything in the code is the same except the following,
which is inside a function which is registared with the socket parser to
initiate this function when information arrives:
add_olsr_socket(ipc_socket_di, &ipc_action_di);
void
ipc_action_di(int fd)
{
struct sockaddr_in pin;
socklen_t addrlen;
char *addr;
addrlen = sizeof(struct sockaddr_in);
if ((ipc_accept_connection_di = accept(ipc_socket_di, (struct sockaddr *)
&pin, &addrlen)) == -1)
{
perror("IPC accept");
exit(1);
}
else
{
addr = inet_ntoa(pin.sin_addr);
if(ntohl(pin.sin_addr.s_addr) != INADDR_LOOPBACK)
{
olsr_printf(1, "Front end-connection from foregin host(%s) not
allowed!\n", addr);
close(ipc_accept_connection_di);
return;
}
else
{
ipc_listening_di = 1;
olsr_printf(1, "DI: Incoming DI Connection from %s\n",addr);
olsr_event();
}
} /*end of else*/
}/*end of function */
Thanks
Daniel
>From: Andreas Tønnesen <(spam-protected)>
>Reply-To: OLSR development <(spam-protected)>
>To: OLSR development <(spam-protected)>
>Subject: Re: [olsr-dev] Question plugin
>Date: Fri, 07 Jan 2005 17:46:39 +0100
>
>Hi Daniel,
>
>If you want a function called when data is available on a socket you
>should register your callback function and your socket with the socket
>parser using the add_olsr_socket call.
>To answer your second question, yes the callback function can loop
>trough interfaces and generate a message(s) that are pushed onto
>the olsrd net buffers.
>
>So all in all you only need the socket parser callback function and
>no scheduler registered function.
>
>- Andreas
>
>Daniel Jaskiewicz wrote:
>>Hello everyone I got a question about registering a function with the
>>olsrd scheduler. If I want an event to tigger based on information
>>recieved through a socket and not based on a time interval like the
>>function olsr_registar_scheduler_event() is provided, what is the best way
>>to implement this in a plugin.
>>When I registar a socket to the socket parser and information is recieved
>>and triggers a corresponding function, in that function can I have the
>>nessecary code to:
>>Loop through interfaces
>>generate a message
>>write message to buffer for interface
>>
>>Will olsrd restrict this solution in anyway, will I have to registar this
>>kind of action with OLSRD, even if the function
>>olsr_registar_scheduler_event() is not needed?
>>
>>Thanks again
>>Daniel
>>
>>
>>_______________________________________________
>>olsr-dev mailing list
>>(spam-protected)
>>https://www.olsr.org/mailman/listinfo/olsr-dev
>
>--
>Andreas Tønnesen
>http://www.olsr.org
>_______________________________________________
>olsr-dev mailing list
>(spam-protected)
>https://www.olsr.org/mailman/listinfo/olsr-dev
More information about the Olsr-dev
mailing list