New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use API/function to get informations #312
Comments
Look at |
For my understanding, I think that lldpd has been installed already and I can use |
The structures are opaque. The documentation on how to use them is |
I wrote a test program to get neighbor's ip reffering to
Could you hlep me to fix it?
|
You are iterating on neighbors, but never use |
Use a for loop instead of an iterator (otherwise, you should keep the static declarations): iface_list = lldpctl_get_interfaces(conn);
lldpctl_atom_foreach(iface, iface_list) {
/* ... */
}
lldpctl_atom_dec_ref(iface_list); |
You cannot build an iterator if you remove the |
Thanks for your reply.I modified the code using
|
You decrement the reference count for |
I fixed like below:
the result still is
|
No clue here. Are you sure you did recompile (see last warning)? |
I am sure .And I execute below code:
The terminal shows ::
|
It looks like it segault on the outer for loop, not the inner. This doesn't match your gdb session. I don't see anything wrong with your code. |
I cropped the code and just reserve the main framework to make sure the main framework is correct.But it still occured segmentation fault. |
I found that if one |
That's odd. Could you try to add: #define lldpctl_atom_foreach2(atom, value) \
for (lldpctl_atom_iter_t *iter2 = lldpctl_atom_iter(atom); \
iter2 && (value = lldpctl_atom_iter_value(atom, iter2)); \
iter2 = lldpctl_atom_iter_next(atom, iter2), \
lldpctl_atom_dec_ref(value)) And use |
It works by modified |
That's quite odd. Which compiler are you using? Which version? |
This lessen the chance of the `iter` variable to shadow a user-defined variable. This is also a tentative to help #312, even if the scope of the `iter` variable should ensure we can nest two loops without any issue.
GCC: (crosstool-NG crosstool-ng-1.23.0-280-g01e3290) 7.3.0. |
I have committed your fix some time ago. Let's close this issue. |
Hi,vincent:
I want to use API/function to get some informations what I want .There's a parameter confuse me that is
lldpctl_atom_t
.I can get it with a function or I need to set it by myselt .Here is a simple test program to get ip address.What should I do to deal withlldpctl_atom_t
???The text was updated successfully, but these errors were encountered: