>> in
strs @ [ str ] in
- (* Finally a publicly exposed follower function. *)
+ (* Finally a publicly exposed follower function for each structure. *)
let strs =
let fs =
List.map (
let body =
tuple_generate_extract follower_tuple struct_name
<:patt< f >> <:expr< followers >>
- <:expr<
- f load followers AddrMap.empty addr
- >> in
+ <:expr< f load followers AddrMap.empty addr >> in
<:str_item<
let $lid:fname$ kernel_version load addr =
(string -> Virt_mem_mmap.addr -> int -> Bitstring.bitstring) ->
Virt_mem_mmap.addr ->
(string * int) AddrMap.t
- >>
+ >>
) xs in
concat_str_items strs, concat_sig_items sigs
};
]
+(*----------------------------------------------------------------------
+ * These are the code fragments which run over kernel structures.
+ *----------------------------------------------------------------------*)
+
+let fragments = [
+ <:str_item<
+ let get_net_devices net_device =
+ let rec loop dev acc =
+ let ipv4 = net_device.ip_ptr.ifa_list in
+ let ipv4_addresses =
+ let rec loop2 ipv4 acc =
+ let addr = ipv4.ifa_address :: acc in
+ let ipv4 = ipv4.ifa_next in
+ loop2 ipv4
+ in
+ loop ipv4 [] in
+ let acc = ipv4_addresses :: acc in
+ let next = get_net_devices net_device.dev_list'next in
+ if next <> net_device then loop next
+ else acc
+ >>;
+
+ <:str_item<
+ let get_net_devices_from_init_net net =
+ get_net_devices net.dev_base_head'next
+ >>;
+
+]
+
let debug = false
open Camlp4.PreCast