Thank you Ionut, i miss read the rlshell structure and thought it&#39;s first member was a swcli_context  :)<br><br><div class="gmail_quote">On Mon, Mar 11, 2013 at 11:38 AM, Ionut Nicu <span dir="ltr">&lt;<a href="mailto:ionut.nicu@mindbit.ro" target="_blank">ionut.nicu@mindbit.ro</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Victor,<br>
<div class="im"><br>
On Mon, 2013-03-11 at 10:43 -0400, Victor Duta wrote:<br>
&gt; I think that the API should also include the swcli_context in order to<br>
&gt; use the message qeues to comunicate with the daemons and the AF_SWITCH<br>
&gt; sockets . I also have a question regarding the MACRO SWCLI_CTX wich<br>
&gt; seems to cast (struct cli_context *) to (struct swcli_context *).I&#39;ve<br>
&gt; inspected the 2 structures and it seems that they don&#39;t have anything<br>
&gt; in common . Could i get a brief explanation of why this is<br>
&gt; possible .<br>
<br>
<br>
</div>Putting back the mailing list into CC. Please hit the reply-all button<br>
when replying so that we keep a clean history on the mailing list.<br>
<br>
If you look more closely at the structures, swcli_context&#39;s first member<br>
is a struct rlshell_context. rlshell_context&#39;s first member is a struct<br>
cli_context. If you think how things are layed out in memory, the first<br>
memory area of a swcli_context is in fact a cli_context structure.<br>
<br>
This is a well know pattern for doing OOP in C. If you think OOP, you<br>
could say that rshell_context is a class derived from cli_context and<br>
swcli_context is class derived from rlshell_context. If you keep a<br>
pointer to a swcli_context structure you can safely &quot;upcast&quot; it to a<br>
pointer to a cli_context which is the &quot;base object&quot;.<br>
<br>
I hope this answers your question.<br>
<span class="HOEnZb"><font color="#888888"><br>
Ionut.<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
&gt;<br>
&gt; On Mon, Mar 11, 2013 at 8:28 AM, Ionut Nicu &lt;<a href="mailto:ionut.nicu@mindbit.ro">ionut.nicu@mindbit.ro</a>&gt;<br>
&gt; wrote:<br>
&gt;         Hi Andreea,<br>
&gt;<br>
&gt;         On Mon, 2013-03-11 at 13:58 +0200, Andreea-Cristina Hodea<br>
&gt;         wrote:<br>
&gt;         &gt; On Mon, Mar 11, 2013 at 1:38 PM, Andreea-Cristina Hodea<br>
&gt;         &gt; &lt;<a href="mailto:andreea.cristina.hodea@gmail.com">andreea.cristina.hodea@gmail.com</a>&gt; wrote:<br>
&gt;         &gt; &gt; Hi,<br>
&gt;         &gt; &gt;<br>
&gt;         &gt; &gt; Now the cli makes ioctl calls and communicates with<br>
&gt;         daemons (cdp,<br>
&gt;         &gt; &gt; rstp) by using queues and shared memory. In both cases<br>
&gt;         (kernel calls<br>
&gt;         &gt; &gt; and daemons), the cli context is used and data structures<br>
&gt;         defined in<br>
&gt;         &gt; &gt; cli implementation. Should we consider that all<br>
&gt;         implementations of the<br>
&gt;         &gt; &gt; API would make use of the data structures defined in cli<br>
&gt;         &gt; &gt; implementation?<br>
&gt;         &gt;<br>
&gt;         &gt; After a discussion with Victor, we realized that some of the<br>
&gt;         &gt; structures in cli implementation would be better moved to<br>
&gt;         switch API.<br>
&gt;         &gt; We&#39;re thinking that some of the data structures, like<br>
&gt;         swcfgreq<br>
&gt;         &gt; shouldn&#39;t be part of the cli at all, because it will depend<br>
&gt;         on the<br>
&gt;         &gt; implementation of the Switch API which structures to use.<br>
&gt;         For ioctl<br>
&gt;         &gt; calls, swcfgreq and ifreq structures are being used for<br>
&gt;         setting the<br>
&gt;         &gt; parameters used by the the lisa kernel implementation, but<br>
&gt;         are these<br>
&gt;         &gt; structures also useful for the other proposed<br>
&gt;         implementations?<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;         My opinion is that those structures (e.g. swcfgreq which is<br>
&gt;         defined as<br>
&gt;         far as I recall in a kernel header) should only be used by the<br>
&gt;         LiSA<br>
&gt;         specific implementation of the switch API. The switch API<br>
&gt;         itself should<br>
&gt;         be more generic and hide the particularities of the underlying<br>
&gt;         implementation (be it LiSA, bridge/8021q or any other).<br>
&gt;<br>
&gt;         In any case, as I&#39;ve discussed with Radu a while ago, some of<br>
&gt;         the<br>
&gt;         information that is now kept into the lisa switch kernel<br>
&gt;         module should<br>
&gt;         be taken out to user space. I&#39;m thinking of information such<br>
&gt;         as<br>
&gt;         interface or vlan descriptions. This way you&#39;ll be able to<br>
&gt;         support other<br>
&gt;         implementations (bridge/8021q) without doing any weird stuff<br>
&gt;         in<br>
&gt;         userspace.<br>
&gt;<br>
&gt;         Regards,<br>
&gt;         Ionut.<br>
&gt;<br>
&gt;         _______________________________________________<br>
&gt;         LiSA-Devel mailing list<br>
&gt;         <a href="mailto:LiSA-Devel@lisa.mindbit.ro">LiSA-Devel@lisa.mindbit.ro</a><br>
&gt;         <a href="http://lisa.mindbit.ro/mailman/listinfo/lisa-devel" target="_blank">http://lisa.mindbit.ro/mailman/listinfo/lisa-devel</a><br>
&gt;<br>
&gt;<br>
<br>
<br>
</div></div></blockquote></div><br>