3 # The MIT License (MIT)
5 # Copyright (C) 2015 - Julien Desfossez <jdesfossez@efficios.com>
6 # 2015 - Antoine Busque <abusque@efficios.com>
8 # Permission is hereby granted, free of charge, to any person obtaining a copy
9 # of this software and associated documentation files (the "Software"), to deal
10 # in the Software without restriction, including without limitation the rights
11 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 # copies of the Software, and to permit persons to whom the Software is
13 # furnished to do so, subject to the following conditions:
15 # The above copyright notice and this permission notice shall be included in
16 # all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 from linuxautomaton
import sp
, sv
29 class NetStateProvider(sp
.StateProvider
):
30 def __init__(self
, state
):
32 'net_dev_xmit': self
._process
_net
_dev
_xmit
,
33 'netif_receive_skb': self
._process
_netif
_receive
_skb
,
37 self
._register
_cbs
(cbs
)
39 def process_event(self
, ev
):
40 self
._process
_event
_cb
(ev
)
42 def _process_net_dev_xmit(self
, event
):
43 self
._state
.send_notification_cb('net_dev_xmit',
44 iface_name
=event
['name'],
45 sent_bytes
=event
['len'])
47 cpu_id
= event
['cpu_id']
48 if cpu_id
not in self
._state
.cpus
:
51 cpu
= self
._state
.cpus
[cpu_id
]
52 if cpu
.current_tid
is None:
55 proc
= self
._state
.tids
[cpu
.current_tid
]
56 current_syscall
= proc
.current_syscall
57 if current_syscall
is None:
60 if proc
.pid
is not None and proc
.pid
!= proc
.tid
:
61 proc
= self
._state
.tids
[proc
.pid
]
63 if current_syscall
.name
in sv
.SyscallConsts
.WRITE_SYSCALLS
:
64 # TODO: find a way to set fd_type on the write rq to allow
65 # setting FD Type if FD hasn't yet been created
66 fd
= current_syscall
.io_rq
.fd
67 if fd
in proc
.fds
and proc
.fds
[fd
].fd_type
== sv
.FDType
.unknown
:
68 proc
.fds
[fd
].fd_type
= sv
.FDType
.maybe_net
70 def _process_netif_receive_skb(self
, event
):
71 self
._state
.send_notification_cb('netif_receive_skb',
72 iface_name
=event
['name'],
73 recv_bytes
=event
['len'])
This page took 0.034124 seconds and 5 git commands to generate.