Lines Matching refs:p

103             ri.cw.p(f'free({var}->{ref}{self.c_name});')
116 ri.cw.p(f"unsigned int n_{self.c_name};")
120 ri.cw.p(f"{member} {ptr}{self.c_name};")
124 ri.cw.p(one + ';')
133 cw.p(f"\t[{self.enum_name}] = {spec},")
140 cw.p(f'[{self.enum_name}] = {"{"} .name = "{self.name}", {typol}{"}"},')
144 ri.cw.p(f"if ({var}->_present.{self.c_name})")
146 ri.cw.p(f"if ({var}->_present.{self.c_name}_len)")
147 ri.cw.p(f"{line};")
170 ri.cw.p(local)
174 ri.cw.p("if (ynl_attr_validate(yarg, attr))")
175 ri.cw.p("return MNL_CB_ERROR;")
177 ri.cw.p(f"{var}->_present.{self.c_name} = 1;")
182 ri.cw.p(line)
185 ri.cw.p(line)
355 ri.cw.p(f"char *{self.c_name};")
374 cw.p(f"\t[{self.enum_name}] = {spec},")
404 ri.cw.p(f"void *{self.c_name};")
444 ri.cw.p(f'{self.nested_render_name}_free(&{var}->{ref}{self.c_name});')
503 ri.cw.p(f"free({var}->{ref}{self.c_name});")
505 ri.cw.p(f"for (i = 0; i < {var}->{ref}n_{self.c_name}; i++)")
506 ri.cw.p(f'{self.nested_render_name}_free(&{var}->{ref}{self.c_name}[i]);')
507 ri.cw.p(f"free({var}->{ref}{self.c_name});")
523 ri.cw.p(f"for (unsigned int i = 0; i < {var}->n_{self.c_name}; i++)")
524 ri.cw.p(f"mnl_attr_put_{put_type}(nlh, {self.enum_name}, {var}->{self.c_name}[i]);")
526 ri.cw.p(f"for (unsigned int i = 0; i < {var}->n_{self.c_name}; i++)")
1080 def p(self, line, add_ind=0): member in CodeWriter
1108 self.p(line + '{')
1122 self.p('}' + line)
1129 self.p(line)
1134 self.p(line)
1141 self.p('/*')
1142 self.p(' * ' + doc)
1143 self.p(' */')
1151 self.p(oneline)
1156 self.p(v)
1170 self.p(v + ',')
1176 self.p(v + ')' + suffix)
1187 self.p(var)
1196 self.p(line)
1212 self.p(line)
1222 self.p(line)
1348 cw.p(f'.max_attr = {type_max},')
1349 cw.p(f'.table = {struct.render_name}_policy,')
1361 cw.p(f'{arg_name} = ffs({arg_name}) - 1;')
1362 cw.p(f'if ({arg_name} < 0 || {arg_name} >= (int)MNL_ARRAY_SIZE({map_name}))')
1363 cw.p('return NULL;')
1364 cw.p(f'return {map_name}[{arg_name}];')
1379 cw.p(f'[{op.enum_name}] = "{op_name}",')
1381 cw.p(f'[{op.rsp_value}] = "{op_name}",')
1399 cw.p(f'[{entry.value}] = "{entry.name}",')
1415 ri.cw.p("nest = mnl_attr_nest_start(nlh, attr_type);")
1420 ri.cw.p("mnl_attr_nest_end(nlh, nest);")
1423 ri.cw.p('return 0;')
1459 ri.cw.p(line)
1463 ri.cw.p(f'dst->{arg} = {arg};')
1467 ri.cw.p(f"if (dst->{aspec.c_name})")
1468 …ri.cw.p(f'return ynl_error_parse(yarg, "attribute already present ({struct.attr_set.name}.{aspec.n…
1472 ri.cw.p('unsigned int type = mnl_attr_get_type(attr);')
1488 ri.cw.p(f"dst->{aspec.c_name} = calloc({aspec.c_name}, sizeof(*dst->{aspec.c_name}));")
1489 ri.cw.p(f"dst->n_{aspec.c_name} = n_{aspec.c_name};")
1490 ri.cw.p('i = 0;')
1491 ri.cw.p(f"parg.rsp_policy = &{aspec.nested_render_name}_nest;")
1493 ri.cw.p(f"parg.data = &dst->{aspec.c_name}[i];")
1494 ri.cw.p(f"if ({aspec.nested_render_name}_parse(&parg, attr, mnl_attr_get_type(attr)))")
1495 ri.cw.p('return MNL_CB_ERROR;')
1496 ri.cw.p('i++;')
1504 ri.cw.p(f"dst->{aspec.c_name} = calloc(n_{aspec.c_name}, sizeof(*dst->{aspec.c_name}));")
1505 ri.cw.p(f"dst->n_{aspec.c_name} = n_{aspec.c_name};")
1506 ri.cw.p('i = 0;')
1508 ri.cw.p(f"parg.rsp_policy = &{aspec.nested_render_name}_nest;")
1512 ri.cw.p(f"parg.data = &dst->{aspec.c_name}[i];")
1513 ri.cw.p(f"if ({aspec.nested_render_name}_parse(&parg, attr))")
1514 ri.cw.p('return MNL_CB_ERROR;')
1519 ri.cw.p(f"dst->{aspec.c_name}[i] = mnl_attr_get_{t}(attr);")
1522 ri.cw.p('i++;')
1529 ri.cw.p('return 0;')
1531 ri.cw.p('return MNL_CB_OK;')
1570 ri.cw.p('return MNL_CB_OK;')
1592 ri.cw.p(f"nlh = ynl_gemsg_start_req(ys, {ri.nl.get_family_id()}, {ri.op.enum_name}, 1);")
1594 ri.cw.p(f"ys->req_policy = &{ri.struct['request'].render_name}_nest;")
1596 ri.cw.p(f"yrs.yarg.rsp_policy = &{ri.struct['reply'].render_name}_nest;")
1604 ri.cw.p('rsp = calloc(1, sizeof(*rsp));')
1605 ri.cw.p('yrs.yarg.data = rsp;')
1606 ri.cw.p(f"yrs.cb = {op_prefix(ri, 'reply')}_parse;")
1608 ri.cw.p(f'yrs.rsp_cmd = {ri.op.enum_name};')
1610 ri.cw.p(f'yrs.rsp_cmd = {ri.op.rsp_value};')
1613 ri.cw.p(f"err = ynl_exec(ys, nlh, {parse_arg});")
1614 ri.cw.p('if (err < 0)')
1616 ri.cw.p('goto err_free;')
1618 ri.cw.p('return -1;')
1621 ri.cw.p(f"return {ret_ok};")
1625 ri.cw.p('err_free:')
1626 ri.cw.p(f"{call_free(ri, rdir(direction), 'rsp')}")
1627 ri.cw.p(f"return {ret_err};")
1641 ri.cw.p(f'{var}')
1644 ri.cw.p('yds.ys = ys;')
1645 ri.cw.p(f"yds.alloc_sz = sizeof({type_name(ri, rdir(direction))});")
1646 ri.cw.p(f"yds.cb = {op_prefix(ri, 'reply', deref=True)}_parse;")
1648 ri.cw.p(f'yds.rsp_cmd = {ri.op.enum_name};')
1650 ri.cw.p(f'yds.rsp_cmd = {ri.op.rsp_value};')
1651 ri.cw.p(f"yds.rsp_policy = &{ri.struct['reply'].render_name}_nest;")
1653 ri.cw.p(f"nlh = ynl_gemsg_start_dump(ys, {ri.nl.get_family_id()}, {ri.op.enum_name}, 1);")
1656 ri.cw.p(f"ys->req_policy = &{ri.struct['request'].render_name}_nest;")
1662 ri.cw.p('err = ynl_exec_dump(ys, nlh, &yds);')
1663 ri.cw.p('if (err < 0)')
1664 ri.cw.p('goto free_list;')
1667 ri.cw.p('return yds.first;')
1669 ri.cw.p('free_list:')
1670 ri.cw.p(call_free(ri, rdir(direction), 'yds.first'))
1671 ri.cw.p('return NULL;')
1689 ri.cw.p(f'return calloc(1, sizeof(struct {name}));')
1720 ri.cw.p(line)
1726 ri.cw.p(f"__u32 {arg};")
1797 ri.cw.p(f"{type_name(ri, 'reply')} *next;")
1799 ri.cw.p('__u16 family;')
1800 ri.cw.p('__u8 cmd;')
1801 ri.cw.p('struct ynl_ntf_base_type *next;')
1802 ri.cw.p(f"void (*free)({type_name(ri, 'reply')} *ntf);")
1803 ri.cw.p(f"{type_name(ri, 'reply', deref=True)} obj __attribute__ ((aligned (8)));")
1813 ri.cw.p('unsigned int i;')
1831 ri.cw.p(f'free({var});')
1851 ri.cw.p(f"{sub_type} *next = rsp;")
1855 ri.cw.p('rsp = next;')
1856 ri.cw.p('next = rsp->next;')
1860 ri.cw.p(f'free(rsp);')
1871 ri.cw.p(f'free(rsp);')
1897 cw.p(f"{prefix}const struct nla_policy {name}_nl_policy[{max_attr.enum_name} + 1]{suffix}")
1904 cw.p("};")
1920 cw.p(f"/* Ops table for {family.name} */")
1942 cw.p(f"extern {line};")
2071 cw.p(grp_id)
2084 cw.p('[' + grp_id + '] = { "' + name + '", },')
2093 cw.p(f"extern struct genl_family {family.name}_nl_family;")
2102 cw.p('.name\t\t= ' + family.fam_key + ',')
2103 cw.p('.version\t= ' + family.ver_key + ',')
2104 cw.p('.netnsok\t= true,')
2105 cw.p('.parallel_ops\t= true,')
2106 cw.p('.module\t\t= THIS_MODULE,')
2108 cw.p(f'.ops\t\t= {family.name}_nl_ops,')
2109 cw.p(f'.n_ops\t\t= ARRAY_SIZE({family.name}_nl_ops),')
2111 cw.p(f'.split_ops\t= {family.name}_nl_ops,')
2112 cw.p(f'.n_split_ops\t= ARRAY_SIZE({family.name}_nl_ops),')
2114 cw.p(f'.mcgrps\t\t= {family.name}_nl_mcgrps,')
2115 cw.p(f'.n_mcgrps\t= ARRAY_SIZE({family.name}_nl_mcgrps),')
2131 cw.p('#ifndef ' + hdr_prot)
2132 cw.p('#define ' + hdr_prot)
2152 cw.p('/**')
2161 cw.p(' */')
2169 cw.p(entry.c_name + suffix)
2173 cw.p('/* private: */')
2177 cw.p(max_name + max_val)
2180 cw.p('__' + max_name + ',')
2181 cw.p(max_name + ' = (__' + max_name + ' - 1)')
2210 cw.p(attr.enum_name + suffix)
2212 cw.p(cnt_name + ('' if max_by_define else ','))
2214 cw.p(f"{attr_set.max_name} = {max_value}")
2217 cw.p(f"#define {attr_set.max_name} {max_value}")
2237 cw.p(op.enum_name + suffix)
2240 cw.p(cnt_name + ('' if max_by_define else ','))
2242 cw.p(f"{max_name} = {max_value}")
2245 cw.p(f"#define {max_name} {max_value}")
2257 cw.p(op.enum_name + suffix)
2272 cw.p(f'#endif /* {hdr_prot} */')
2277 ri.cw.p(f".alloc_sz\t= sizeof({type_name(ri, 'event')}),")
2278 ri.cw.p(f".cb\t\t= {op_prefix(ri, 'reply', deref=True)}_parse,")
2279 ri.cw.p(f".policy\t\t= &{ri.struct['reply'].render_name}_nest,")
2280 ri.cw.p(f".free\t\t= (void *){op_prefix(ri, 'notify')}_free,")
2287 cw.p(f'extern {symbol};')
2310 cw.p(f'.name\t\t= "{family.name}",')
2312 cw.p(f".ntf_info\t= {family['name']}_ntf_info,")
2313 cw.p(f".ntf_info_size\t= MNL_ARRAY_SIZE({family['name']}_ntf_info),")
2365 cw.p(f'/* SPDX-License-Identifier: {parsed.license} */')
2367 cw.p(f'// SPDX-License-Identifier: {parsed.license}')
2368 cw.p("/* Do not edit directly, auto-generated from: */")
2369 cw.p(f"/*\t{spec_kernel} */")
2370 cw.p(f"/* YNL-GEN {args.mode} {'header' if args.header else 'source'} */")
2375 cw.p(f'/* YNL-ARG{line} */')
2384 cw.p('#ifndef ' + hdr_prot)
2385 cw.p('#define ' + hdr_prot)
2389 cw.p('#include <net/netlink.h>')
2390 cw.p('#include <net/genetlink.h>')
2394 cw.p(f'#include "{os.path.basename(args.out_file[:-2])}.h"')
2398 cw.p('#include <stdlib.h>')
2399 cw.p('#include <string.h>')
2401 cw.p('#include <linux/types.h>')
2403 cw.p(f'#include "{parsed.name}-user.h"')
2404 cw.p('#include "ynl.h"')
2410 cw.p(f"#include <{one}>")
2415 cw.p("#include <libmnl/libmnl.h>")
2416 cw.p("#include <linux/genetlink.h>")
2419 cw.p(f'#include "{one}"')
2421 cw.p('struct ynl_sock;')
2430 cw.p('/* Common nested types */')
2438 cw.p(f"/* Global operation policy for {parsed.name} */")
2457 cw.p('/* Common nested types */')
2465 cw.p(f"/* Global operation policy for {parsed.name} */")
2475 cw.p(f"/* {op.enum_name} - {op_mode} */")
2486 cw.p('/* Enums */')
2494 cw.p('/* Common nested types */')
2500 cw.p(f"/* ============== {op.enum_name} ============== */")
2503 cw.p(f"/* {op.enum_name} - do */")
2515 cw.p(f"/* {op.enum_name} - dump */")
2527 cw.p(f"/* {op.enum_name} - notify */")
2536 cw.p(f"/* {op.enum_name} - event */")
2542 cw.p('/* Enums */')
2550 cw.p('/* Policies */')
2558 cw.p('/* Common nested types */')
2569 cw.p(f"/* ============== {op.enum_name} ============== */")
2571 cw.p(f"/* {op.enum_name} - do */")
2580 cw.p(f"/* {op.enum_name} - dump */")
2589 cw.p(f"/* {op.enum_name} - notify */")
2597 cw.p(f"/* {op.enum_name} - event */")
2608 cw.p(f'#endif /* {hdr_prot} */')