netlink_compat.c (4f6b838c378a52ea3ae0b15f12ca8a20849072fa) netlink_compat.c (872f690341948b502c93318f806d821c56772c42)
1/*
2 * Copyright (c) 2014, Ericsson AB
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 104 unchanged lines hidden (view full) ---

113{
114 struct tlv_desc *tlv = (struct tlv_desc *)skb->data;
115
116 TLV_SET_LEN(tlv, 0);
117 TLV_SET_TYPE(tlv, type);
118 skb_put(skb, sizeof(struct tlv_desc));
119}
120
1/*
2 * Copyright (c) 2014, Ericsson AB
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 104 unchanged lines hidden (view full) ---

113{
114 struct tlv_desc *tlv = (struct tlv_desc *)skb->data;
115
116 TLV_SET_LEN(tlv, 0);
117 TLV_SET_TYPE(tlv, type);
118 skb_put(skb, sizeof(struct tlv_desc));
119}
120
121static int tipc_tlv_sprintf(struct sk_buff *skb, const char *fmt, ...)
121static __printf(2, 3) int tipc_tlv_sprintf(struct sk_buff *skb,
122 const char *fmt, ...)
122{
123 int n;
124 u16 len;
125 u32 rem;
126 char *buf;
127 struct tlv_desc *tlv;
128 va_list args;
129

--- 453 unchanged lines hidden (view full) ---

583 len = min_t(int, len, TIPC_MAX_LINK_NAME);
584 if (!string_is_valid(name, len))
585 return -EINVAL;
586
587 if (strcmp(name, nla_data(link[TIPC_NLA_LINK_NAME])) != 0)
588 return 0;
589
590 tipc_tlv_sprintf(msg->rep, "\nLink <%s>\n",
123{
124 int n;
125 u16 len;
126 u32 rem;
127 char *buf;
128 struct tlv_desc *tlv;
129 va_list args;
130

--- 453 unchanged lines hidden (view full) ---

584 len = min_t(int, len, TIPC_MAX_LINK_NAME);
585 if (!string_is_valid(name, len))
586 return -EINVAL;
587
588 if (strcmp(name, nla_data(link[TIPC_NLA_LINK_NAME])) != 0)
589 return 0;
590
591 tipc_tlv_sprintf(msg->rep, "\nLink <%s>\n",
591 nla_data(link[TIPC_NLA_LINK_NAME]));
592 (char *)nla_data(link[TIPC_NLA_LINK_NAME]));
592
593 if (link[TIPC_NLA_LINK_BROADCAST]) {
594 __fill_bc_link_stat(msg, prop, stats);
595 return 0;
596 }
597
598 if (link[TIPC_NLA_LINK_ACTIVE])
599 tipc_tlv_sprintf(msg->rep, " ACTIVE");

--- 90 unchanged lines hidden (view full) ---

690
691 err = nla_parse_nested_deprecated(link, TIPC_NLA_LINK_MAX,
692 attrs[TIPC_NLA_LINK], NULL, NULL);
693 if (err)
694 return err;
695
696 link_info.dest = nla_get_flag(link[TIPC_NLA_LINK_DEST]);
697 link_info.up = htonl(nla_get_flag(link[TIPC_NLA_LINK_UP]));
593
594 if (link[TIPC_NLA_LINK_BROADCAST]) {
595 __fill_bc_link_stat(msg, prop, stats);
596 return 0;
597 }
598
599 if (link[TIPC_NLA_LINK_ACTIVE])
600 tipc_tlv_sprintf(msg->rep, " ACTIVE");

--- 90 unchanged lines hidden (view full) ---

691
692 err = nla_parse_nested_deprecated(link, TIPC_NLA_LINK_MAX,
693 attrs[TIPC_NLA_LINK], NULL, NULL);
694 if (err)
695 return err;
696
697 link_info.dest = nla_get_flag(link[TIPC_NLA_LINK_DEST]);
698 link_info.up = htonl(nla_get_flag(link[TIPC_NLA_LINK_UP]));
698 nla_strlcpy(link_info.str, link[TIPC_NLA_LINK_NAME],
699 nla_strscpy(link_info.str, link[TIPC_NLA_LINK_NAME],
699 TIPC_MAX_LINK_NAME);
700
701 return tipc_add_tlv(msg->rep, TIPC_TLV_LINK_INFO,
702 &link_info, sizeof(link_info));
703}
704
705static int __tipc_add_link_prop(struct sk_buff *skb,
706 struct tipc_nl_compat_msg *msg,

--- 669 unchanged lines hidden ---
700 TIPC_MAX_LINK_NAME);
701
702 return tipc_add_tlv(msg->rep, TIPC_TLV_LINK_INFO,
703 &link_info, sizeof(link_info));
704}
705
706static int __tipc_add_link_prop(struct sk_buff *skb,
707 struct tipc_nl_compat_msg *msg,

--- 669 unchanged lines hidden ---