Get all VLAN interfaces of a real interface - networking

I create a VLAN interface with the following command in shell.
ip link add link port-1 name port-1.10 type vlan id 10
and I want my netdevice driver kernel module be able to get all the information of VLAN interfaces I create including vlan ID.
What struct member should I look into or kernel code should I call?
I tried to look into linux/netdevice.h and got no idea what function should I call.
I wish there is a list of VLAN interfaces of a real interface for me to look up.

I realized that I do not need to check ALL the VLAN interfaces that I've created. Instead I check whether the VLAN tag in the packet has a match VLAN interface with the following code.
struct net_device *vlan_dev;
...
vlan_dev = __vlan_find_dev_deep_rcu(dev, svlan ? htons(ETH_P_8021AD) : htons(ETH_P_8021Q), vid);
if (vlan_dev == NULL) {
/* There's no match VLAN interface. */
...
}
/* There's a match VLAN interface */
...

Related

Initialize a constant array of std_logic_vector from binary file in VHDL

I have packaged an IP and in its top module I have a constant array of std_logic_vector for some purpose. If I need to use only a single instance of this IP in the design, I can edit this constant array for my needs and voila, however if I need multiple instances of this IP (this constant array should be different for each of those instances) I have to find another way to do that because when I change the constant array for one of these IP instances, others are also changed because they are using the same VHDL source file obviously. How can I overcome this issue? One way I think about is introducing an input port for the top wrapper of my IP so that it takes this array from outside, and when I instantiate it in the design top level I can create multiple constant arrays and connect them to the IP instances accordingly. Do you have any other suggestions to accomplish this task?
Here is my code with X = 4, Y = 32 (they are much more larger in real case). Up to this point I was using python to find my comments -- DO NOT CHANGE BETWEEN COMMENTS -- and -- COMMENT END HERE --, and change what is inside according to another text file automatically.
type myarray_t is array (X - 1 downto 0) of std_logic_vector(Y - 1 downto 0);
-- DO NOT CHANGE BETWEEN COMMENTS --
constant myarray : myarray_t := (x"01234567",
x"89abcdef",
x"01234567",
x"89abcdef");
-- COMMENT END HERE --
Pack your constants into a VHDL package and use them from there. Create several files, which all contain the same VHDL-package. Then you can have in each of these files a different version of your constants. You include the constants by "use work.package_name.all" in your design. At compile time you compile your design and 1 of the packages in a single library, but create as much different compiled libraries as you have different versions of the package file. When you instantiate your design, you then must define from which library the instance has to be taken.
You can define this by a embedded configuration in the architecture declaration area of your toplevel like:
for instance1: use entity library1.your_design;
for instance2: use entity library2.your_design;
Or you can define it at the instantiation in your toplevel design:
instance1: entity library1.your_design port map ...
instance2: entity library2.your_design port map ...

How can I retrieve data from custom tables in Corda ?

I want to retrieve data from Custom tables that I have created using Queryable State but the database port keeps on changing after every deployment .
Can I assign specific ports for every Node database same as web service and RPC ports ?
Setting the h2 database port
It depends on how you are creating your nodes;
Manually created nodes
Edit the node.conf file that must exist for every node by setting the property h2Port = x, where x is your port number.
Cordformation (in your build.gradle)
For each node { } block you can set the property h2Port x
Driver
You can add any arbitrary configuration to a node you create via startNode by providing the parameter configOverrides. For example with Kotlin you can do;
startNode(<NodeName>, customOverrides = mapOf("h2Port" to x))
In Java you can do the same by specifying it as the 5th parameter.
NodeBasedTest
In a NodeBasedTest you can provide the configOverrides parameter in the same manner as in the Driver but as the 4th parameter of startNode.

DirectShow transform filter - how to get source filter IBaseFilter that connected to my filter input pin?

I want to check how to get source filter IBaseFilter that connected to my filter input pin?
In CheckInputType method I can allow or deny connection by media type, but I need to know more information about source filter.
Transform filter is simple, 1 inout pin and 1 output pin, based on CTransformFilter.
You derive from CTransformFilter, from there:
m_pInput is your input pin
m_pInput->m_Connected is your input pin's connected peer
IPin::QueryPinInfo gets you pin data including IBaseFilter pointer you are looking for
I've found a correct way.
In CheckConnect method you can return E_FAIL to deny connection.
You can get IBaseFilter interface from IPin using PIN_INFO struct.

Broadcast TCP-Server with libevent

I am looking for some sample code of a dead simple libevent-based TCP-Server which broadcasts incoming Messages to all connected clients. On the Web I only found TCP-Servers which echoes back messages.
One echo example if found is on the bottom of this page http://www.wangafu.net/~nickm/libevent-book/Ref8_listener.html
I am sure that its not so difficult to change the code provided on this Site, so that messages are brodcast to all connected clients, but I don't know how.
Could someone advise me?
EDIT: Yes, some kind of a chat server. It seams i need to do sth like this:
void server_read_cb(struct bufferevent *bev, void *data)
{
struct evbuffer *input = bufferevent_get_input(bev);
struct evbuffer *output = bufferevent_get_output(bev);
char *mem = malloc(len); /* XXX: check for malloc failure */
evbuffer_remove(input, mem, len);
"for every connection conn" {
/* XXX you'll need to implement a real connection list;
the above isn't real C. */
evbuffer_add(bufferevent_get_output(conn), mem, len);
}
free(mem);
}
But i can't put this to work.
Seems you want something similar to a chat server. One example is here. Basically, when you receive data from one connection, you just go through the list of connections and send that same data to each one (including/excluding the original).

How to create a pseudo-tty for reading output and writing to input

I am using fork() and execvp() to spawn a process that must believe it is connected to an interactive terminal for it to function properly.
Once spawned, I want to capture all the output from the process, as well as be able to send input to the process.
I suspect psuedo-ttys may help here. Does anyone have a snippet on how to do this?
You want to call forkpty(). From the man page:
#include <pty.h> /* for openpty and forkpty */
pid_t forkpty(int *amaster, char *name, struct termios *termp, struct
winsize *winp);
Link with -lutil.
The forkpty() function combines openpty(), fork(), and login_tty() to
create a new process operating in a pseudo-terminal. The file descrip‐
tor of the master side of the pseudo-terminal is returned in amaster,
and the filename of the slave in name if it is not NULL. The termp and
winp parameters, if not NULL, will determine the terminal attributes
and window size of the slave side of the pseudo-terminal.
Your parent process talks to the child by reading and writing from the file descriptor that forkpty stores in "amaster" - this is called the master pseudo-terminal device. The child just talks to stdin and stdout, which are connected to the slave pseudo-terminal device.
Expect was already mentioned for use via Tcl, but it can also be used without Tcl by treating it as a C library and calling the API documented here
There's a package called "expect" which you should use. It uses a scripting language called tcl (pronounced tickle).
https://core.tcl-lang.org/expect/

Resources