Lines Matching refs:attrs
52 static struct wg_device *lookup_interface(struct nlattr **attrs, in lookup_interface() argument
57 if (!attrs[WGDEVICE_A_IFINDEX] == !attrs[WGDEVICE_A_IFNAME]) in lookup_interface()
59 if (attrs[WGDEVICE_A_IFINDEX]) in lookup_interface()
61 nla_get_u32(attrs[WGDEVICE_A_IFINDEX])); in lookup_interface()
62 else if (attrs[WGDEVICE_A_IFNAME]) in lookup_interface()
64 nla_data(attrs[WGDEVICE_A_IFNAME])); in lookup_interface()
203 wg = lookup_interface(genl_info_dump(cb)->attrs, cb->skb); in wg_get_device_start()
329 static int set_allowedip(struct wg_peer *peer, struct nlattr **attrs) in set_allowedip() argument
335 if (!attrs[WGALLOWEDIP_A_FAMILY] || !attrs[WGALLOWEDIP_A_IPADDR] || in set_allowedip()
336 !attrs[WGALLOWEDIP_A_CIDR_MASK]) in set_allowedip()
338 family = nla_get_u16(attrs[WGALLOWEDIP_A_FAMILY]); in set_allowedip()
339 cidr = nla_get_u8(attrs[WGALLOWEDIP_A_CIDR_MASK]); in set_allowedip()
342 nla_len(attrs[WGALLOWEDIP_A_IPADDR]) == sizeof(struct in_addr)) in set_allowedip()
345 nla_data(attrs[WGALLOWEDIP_A_IPADDR]), cidr, peer, in set_allowedip()
348 nla_len(attrs[WGALLOWEDIP_A_IPADDR]) == sizeof(struct in6_addr)) in set_allowedip()
351 nla_data(attrs[WGALLOWEDIP_A_IPADDR]), cidr, peer, in set_allowedip()
357 static int set_peer(struct wg_device *wg, struct nlattr **attrs) in set_peer() argument
365 if (attrs[WGPEER_A_PUBLIC_KEY] && in set_peer()
366 nla_len(attrs[WGPEER_A_PUBLIC_KEY]) == NOISE_PUBLIC_KEY_LEN) in set_peer()
367 public_key = nla_data(attrs[WGPEER_A_PUBLIC_KEY]); in set_peer()
370 if (attrs[WGPEER_A_PRESHARED_KEY] && in set_peer()
371 nla_len(attrs[WGPEER_A_PRESHARED_KEY]) == NOISE_SYMMETRIC_KEY_LEN) in set_peer()
372 preshared_key = nla_data(attrs[WGPEER_A_PRESHARED_KEY]); in set_peer()
374 if (attrs[WGPEER_A_FLAGS]) in set_peer()
375 flags = nla_get_u32(attrs[WGPEER_A_FLAGS]); in set_peer()
381 if (attrs[WGPEER_A_PROTOCOL_VERSION]) { in set_peer()
382 if (nla_get_u32(attrs[WGPEER_A_PROTOCOL_VERSION]) != 1) in set_peer()
387 nla_data(attrs[WGPEER_A_PUBLIC_KEY])); in set_peer()
398 !memcmp(nla_data(attrs[WGPEER_A_PUBLIC_KEY]), in set_peer()
436 if (attrs[WGPEER_A_ENDPOINT]) { in set_peer()
437 struct sockaddr *addr = nla_data(attrs[WGPEER_A_ENDPOINT]); in set_peer()
438 size_t len = nla_len(attrs[WGPEER_A_ENDPOINT]); in set_peer()
454 if (attrs[WGPEER_A_ALLOWEDIPS]) { in set_peer()
458 nla_for_each_nested(attr, attrs[WGPEER_A_ALLOWEDIPS], rem) { in set_peer()
469 if (attrs[WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL]) { in set_peer()
471 attrs[WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL]); in set_peer()
487 if (attrs[WGPEER_A_PRESHARED_KEY]) in set_peer()
488 memzero_explicit(nla_data(attrs[WGPEER_A_PRESHARED_KEY]), in set_peer()
489 nla_len(attrs[WGPEER_A_PRESHARED_KEY])); in set_peer()
495 struct wg_device *wg = lookup_interface(info->attrs, skb); in wg_set_device()
507 if (info->attrs[WGDEVICE_A_FLAGS]) in wg_set_device()
508 flags = nla_get_u32(info->attrs[WGDEVICE_A_FLAGS]); in wg_set_device()
513 if (info->attrs[WGDEVICE_A_LISTEN_PORT] || info->attrs[WGDEVICE_A_FWMARK]) { in wg_set_device()
525 if (info->attrs[WGDEVICE_A_FWMARK]) { in wg_set_device()
528 wg->fwmark = nla_get_u32(info->attrs[WGDEVICE_A_FWMARK]); in wg_set_device()
533 if (info->attrs[WGDEVICE_A_LISTEN_PORT]) { in wg_set_device()
535 nla_get_u16(info->attrs[WGDEVICE_A_LISTEN_PORT])); in wg_set_device()
543 if (info->attrs[WGDEVICE_A_PRIVATE_KEY] && in wg_set_device()
544 nla_len(info->attrs[WGDEVICE_A_PRIVATE_KEY]) == in wg_set_device()
546 u8 *private_key = nla_data(info->attrs[WGDEVICE_A_PRIVATE_KEY]); in wg_set_device()
583 if (info->attrs[WGDEVICE_A_PEERS]) { in wg_set_device()
587 nla_for_each_nested(attr, info->attrs[WGDEVICE_A_PEERS], rem) { in wg_set_device()
604 if (info->attrs[WGDEVICE_A_PRIVATE_KEY]) in wg_set_device()
605 memzero_explicit(nla_data(info->attrs[WGDEVICE_A_PRIVATE_KEY]), in wg_set_device()
606 nla_len(info->attrs[WGDEVICE_A_PRIVATE_KEY])); in wg_set_device()