how to get the timetamp for the linux kernel?
-
int netif_rx(struct sk_buff *skb) { if(skb -> stamp.tv_sec ==0) do_gettimeofday(&skb->stamp); } the above api is the receiver side api, which receives the data from the sender. I want to calculate t he time when it receives the data and store it in a buffer. the above api at line number 2993 is available in kernel source code at: /linux/net/core/dev.c but I am getting ERROR: as struct sk_buff has no member named stamp. http://lxr.free-electrons.com/source/include/linux/skbuff.h Could someone please help me : how to get the timestamp for linux kernel. Later I changed my code to : int netif_rx(struct sk_buff *skb) { if(skb -> tstamp.off_sec ==0) do_gettimeofday(&skb->tstamp); } now I am getting error as : ktime_t has no memeber named "tv_sec". struct timeval but argument is of type unio ktime_t.
-
Answer:
sk_buff->tstamp is variable of ktime_t type. do_gettimeofday sets time to variable of struct timeval. You have different types here and so you need a conversion. A simple one would be: int netif_rx(struct sk_buff *skb) { if(skb -> tstamp.off_sec ==0) { struct timespec now; getnstimeofday(&now); skb->tstamp = timespec_to_ktime(now); } }
user3458454 at Stack Overflow Visit the source
Other answers
Try to use tstamp instead of stamp.
Mahonri Moriancumer
Related Q & A:
- How to reconnect to Ethernet interface on Linux computer?Best solution by Super User
- How to boot linux kernel without bootloader?Best solution by Super User
- How can I setup Canon MF5550 on Linux box?Best solution by Ask Ubuntu
- How to artificially cause a page fault in linux kernel?Best solution by Stack Overflow
- How to create some virtual machines in linux?Best solution by howtogeek.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.