1 /* 2 * lib/idiag/idiagnl_meminfo_obj.c Inet Diag Meminfo Object 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation version 2.1 7 * of the License. 8 * 9 * Copyright (c) 2013 Sassano Systems LLC <joe (at) sassanosystems.com> 10 */ 11 12 #include <netlink-private/netlink.h> 13 #include <netlink/idiag/meminfo.h> 14 15 /** 16 * @ingroup idiag 17 * @defgroup idiagnl_meminfo Inet Diag Memory Info 18 * 19 * @details 20 * @idiagnl_doc{idiagnl_meminfo, Inet Diag Memory Info Documentation} 21 * @{ 22 */ 23 struct idiagnl_meminfo *idiagnl_meminfo_alloc(void) 24 { 25 return (struct idiagnl_meminfo *) nl_object_alloc(&idiagnl_meminfo_obj_ops); 26 } 27 28 void idiagnl_meminfo_get(struct idiagnl_meminfo *minfo) 29 { 30 nl_object_get((struct nl_object *) minfo); 31 } 32 33 void idiagnl_meminfo_put(struct idiagnl_meminfo *minfo) 34 { 35 nl_object_put((struct nl_object *) minfo); 36 } 37 38 /** 39 * @name Attributes 40 * @{ 41 */ 42 uint32_t idiagnl_meminfo_get_rmem(const struct idiagnl_meminfo *minfo) 43 { 44 return minfo->idiag_rmem; 45 } 46 47 void idiagnl_meminfo_set_rmem(struct idiagnl_meminfo *minfo, uint32_t rmem) 48 { 49 minfo->idiag_rmem = rmem; 50 } 51 52 uint32_t idiagnl_meminfo_get_wmem(const struct idiagnl_meminfo *minfo) 53 { 54 return minfo->idiag_wmem; 55 } 56 57 void idiagnl_meminfo_set_wmem(struct idiagnl_meminfo *minfo, uint32_t wmem) 58 { 59 minfo->idiag_wmem = wmem; 60 } 61 62 uint32_t idiagnl_meminfo_get_fmem(const struct idiagnl_meminfo *minfo) 63 { 64 return minfo->idiag_fmem; 65 } 66 67 void idiagnl_meminfo_set_fmem(struct idiagnl_meminfo *minfo, uint32_t fmem) 68 { 69 minfo->idiag_fmem = fmem; 70 } 71 72 uint32_t idiagnl_meminfo_get_tmem(const struct idiagnl_meminfo *minfo) 73 { 74 return minfo->idiag_tmem; 75 } 76 77 void idiagnl_meminfo_set_tmem(struct idiagnl_meminfo *minfo, uint32_t tmem) 78 { 79 minfo->idiag_tmem = tmem; 80 } 81 /** @} */ 82 83 static int idiagnl_meminfo_clone(struct nl_object *_dst, struct nl_object *_src) 84 { 85 struct idiagnl_meminfo *dst = (struct idiagnl_meminfo *) _dst; 86 struct idiagnl_meminfo *src = (struct idiagnl_meminfo *) _src; 87 88 memcpy(dst, src, sizeof(struct idiagnl_meminfo)); 89 90 return 0; 91 } 92 93 /** @cond SKIP */ 94 struct nl_object_ops idiagnl_meminfo_obj_ops = { 95 .oo_name = "idiag/idiag_meminfo", 96 .oo_size = sizeof(struct idiagnl_meminfo), 97 .oo_clone = idiagnl_meminfo_clone, 98 }; 99 /** @endcond */ 100 /** @} */ 101