libnm, examples: fix some annotations and update python examples (bgo 740145)

This commit is contained in:
Dan Winship 2014-11-15 09:31:49 -05:00
commit fb773f6b2f
19 changed files with 275 additions and 177 deletions

View file

@ -1,6 +1,7 @@
EXTRA_DIST = \
nm-state.py \
add-connection.py \
add-connection-compat.py \
add-system-wifi-connection.py \
vpn.py \
update-secrets.py \

View file

@ -0,0 +1,66 @@
#!/usr/bin/env python
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright (C) 2010 - 2012 Red Hat, Inc.
#
#
# This example adds a new ethernet connection via the AddConnection()
# D-Bus call, using backward-compatible settings, so it will work with
# both old and new versions of NetworkManager. Compare
# add-connection.py, which only supports NM 1.0 and later.
#
# Configuration settings are described at
# https://developer.gnome.org/NetworkManager/1.0/ref-settings.html
#
import socket, struct, dbus, uuid
# Helper functions
def ip_to_int(ip_string):
return struct.unpack("=I", socket.inet_aton(ip_string))[0]
def int_to_ip(ip_int):
return socket.inet_ntoa(struct.pack("=I", ip_int))
s_wired = dbus.Dictionary({'duplex': 'full'})
s_con = dbus.Dictionary({
'type': '802-3-ethernet',
'uuid': str(uuid.uuid4()),
'id': 'MyConnectionExample'})
addr1 = dbus.Array([ip_to_int("10.1.2.3"), dbus.UInt32(8L), ip_to_int("10.1.2.1")], signature=dbus.Signature('u'))
s_ip4 = dbus.Dictionary({
'addresses': dbus.Array([addr1], signature=dbus.Signature('au')),
'method': 'manual'})
s_ip6 = dbus.Dictionary({'method': 'ignore'})
con = dbus.Dictionary({
'802-3-ethernet': s_wired,
'connection': s_con,
'ipv4': s_ip4,
'ipv6': s_ip6})
print "Creating connection:", s_con['id'], "-", s_con['uuid']
bus = dbus.SystemBus()
proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/Settings")
settings = dbus.Interface(proxy, "org.freedesktop.NetworkManager.Settings")
settings.AddConnection(con)

View file

@ -18,20 +18,17 @@
#
#
# This example adds a new ethernet connection via AddConnection() D-Bus call.
# This example adds a new ethernet connection via the AddConnection()
# D-Bus call, using the new 'ipv4.address-data' and 'ipv4.gateway'
# settings introduced in NetworkManager 1.0. Compare
# add-connection-compat.py, which will work against older versions of
# NetworkManager as well.
#
# Configuration settings are described at
# https://developer.gnome.org/NetworkManager/0.9/ref-settings.html
# https://developer.gnome.org/NetworkManager/1.0/ref-settings.html
#
import socket, struct, dbus, uuid
# Helper functions
def ip_to_int(ip_string):
return struct.unpack("=I", socket.inet_aton(ip_string))[0]
def int_to_ip(ip_int):
return socket.inet_ntoa(struct.pack("=I", ip_int))
import dbus, uuid
s_wired = dbus.Dictionary({'duplex': 'full'})
s_con = dbus.Dictionary({
@ -39,9 +36,12 @@ s_con = dbus.Dictionary({
'uuid': str(uuid.uuid4()),
'id': 'MyConnectionExample'})
addr1 = dbus.Array([ip_to_int("10.1.2.3"), dbus.UInt32(8L), ip_to_int("10.1.2.1")], signature=dbus.Signature('u'))
addr1 = dbus.Dictionary({
'address': '10.1.2.3',
'prefix': dbus.UInt32(8L)})
s_ip4 = dbus.Dictionary({
'addresses': dbus.Array([addr1], signature=dbus.Signature('au')),
'address-data': dbus.Array([addr1], signature=dbus.Signature('a{sv}')),
'gateway': '10.1.2.1',
'method': 'manual'})
s_ip6 = dbus.Dictionary({'method': 'ignore'})

View file

@ -28,6 +28,8 @@ NM_SERVICE_NAME = "org.freedesktop.NetworkManager"
NM_MANAGER_IFACE = "org.freedesktop.NetworkManager"
DBUS_PROPS_IFACE = "org.freedesktop.DBus.Properties"
NM_ACTIVE_CONNECTION_INTERFACE = "org.freedesktop.NetworkManager.Connection.Active"
bus = dbus.SystemBus()
# Exit early if NetworkManager is not running
@ -42,34 +44,54 @@ proxy = bus.get_object(NM_SERVICE_NAME, "/org/freedesktop/NetworkManager")
manager = dbus.Interface(proxy, NM_MANAGER_IFACE)
props = dbus.Interface(proxy, DBUS_PROPS_IFACE)
default_is_wwan = False
def found_connection_type(ctype):
if ctype == '':
print "No active connection"
elif ctype in ["gsm", "cdma", "bluetooth"]:
print "WWAN is default"
else:
print "WWAN is not default"
sys.exit(0)
# Look through all active network connections for the default one
# Shortcut #1, for NM 1.0
try:
ctype = props.Get(NM_MANAGER_IFACE, "PrimaryConnectionType")
found_connection_type(ctype)
except KeyError:
pass
# Shortcut #2, for NM 0.9.10
try:
primary = props.Get(NM_MANAGER_IFACE, "PrimaryConnection")
if not primary:
found_connection_type('')
primary_proxy = bus.get_object(NM_SERVICE_NAME, primary)
primary_props = dbus.Interface(primary_proxy, DBUS_PROPS_IFACE)
ctype = primary_props.Get(NM_ACTIVE_CONNECTION_INTERFACE, "Type")
found_connection_type(ctype)
except KeyError:
pass
# Fallback for NM 0.9.8 and earlier; look through all active network
# connections for the default one
default_is_wwan = False
active = props.Get(NM_MANAGER_IFACE, "ActiveConnections")
for a in active:
a_proxy = bus.get_object(NM_SERVICE_NAME, a)
a_props = dbus.Interface(a_proxy, DBUS_PROPS_IFACE)
all_props = a_props.GetAll("org.freedesktop.NetworkManager.Connection.Active")
all_props = a_props.GetAll(NM_ACTIVE_CONNECTION_INTERFACE)
# Ignore this network connection if it's not default for IPv4 or IPv6
if all_props["Default"] == False and all_props["Default6"] == False:
continue
# Shortcut: check for Type property (only present in NM 0.9.9+)
try:
ctype = all_props["Type"]
if ctype in ["gsm", "cdma", "bluetooth"]:
default_is_wwan = True
break
except KeyError:
# Fall back to checking the type of the network connection's device
dev_path = all_props["Devices"][0]
dev_proxy = bus.get_object(NM_SERVICE_NAME, dev_path)
dev_props = dbus.Interface(dev_proxy, DBUS_PROPS_IFACE)
devtype = dev_props.Get("org.freedesktop.NetworkManager.Device", "DeviceType")
if devtype == NM_DEVICE_TYPE_MODEM or devtype == NM_DEVICE_TYPE_BLUETOOTH:
default_is_wwan = True
break
dev_path = all_props["Devices"][0]
dev_proxy = bus.get_object(NM_SERVICE_NAME, dev_path)
dev_props = dbus.Interface(dev_proxy, DBUS_PROPS_IFACE)
devtype = dev_props.Get("org.freedesktop.NetworkManager.Device", "DeviceType")
if devtype == NM_DEVICE_TYPE_MODEM or devtype == NM_DEVICE_TYPE_BLUETOOTH:
default_is_wwan = True
break
if default_is_wwan:
print "WWAN is default"

View file

@ -21,15 +21,14 @@
#
# This example updates a connection's IPv4 method with the Update() method.
#
# This uses the new NM 1.0 setting properties. See add-connection-compat.py
# for a similar example using the backward-compatible properties
#
# Configuration settings are described at
# https://developer.gnome.org/NetworkManager/0.9/ref-settings.html
# https://developer.gnome.org/NetworkManager/1.0/ref-settings.html
#
import socket, struct, dbus, sys
def ip_to_int(ip_string):
return struct.unpack("=I", socket.inet_aton(ip_string))[0]
import dbus, sys
if len(sys.argv) < 3:
print "Usage: %s <uuid> <auto|static> [address prefix gateway]" % sys.argv[0]
@ -61,18 +60,22 @@ for c_path in settings.ListConnections():
if 'ipv4' not in c_settings:
c_settings['ipv4'] = {}
# clear existing address info
if c_settings['ipv4'].has_key('addresses'):
del c_settings['ipv4']['addresses']
if c_settings['ipv4'].has_key('address-data'):
del c_settings['ipv4']['address-data']
if c_settings['ipv4'].has_key('gateway'):
del c_settings['ipv4']['gateway']
# set the method and change properties
c_settings['ipv4']['method'] = method
if method == "auto":
# remove addresses
c_settings['ipv4']['addresses'] = dbus.Array([], signature=dbus.Signature('au'))
elif method == "manual":
if method == "manual":
# Add the static IP address, prefix, and (optional) gateway
gw = 0
addr = dbus.Dictionary({'address': sys.argv[3], 'prefix': dbus.UInt32(int(sys.argv[4]))})
c_settings['ipv4']['address-data'] = dbus.Array([addr], signature=dbus.Signature('a{sv}'))
if len(sys.argv) == 6:
gw = ip_to_int(sys.argv[5])
addr = dbus.Array([ip_to_int(sys.argv[3]), dbus.UInt32(int(sys.argv[4])), gw], signature=dbus.Signature('u'))
c_settings['ipv4']['addresses'] = dbus.Array([addr], signature=dbus.Signature('au'))
c_settings['ipv4']['gateway'] = sys.argv[5]
# Save all the updated settings back to NetworkManager
c_obj.Update(c_settings)

View file

@ -48,10 +48,10 @@ def create_profile(name):
s_wired = NM.SettingWired.new()
s_ip4 = NM.SettingIP4Config.new()
s_ip4.set_property(NM.SETTING_IP4_CONFIG_METHOD, "auto")
s_ip4.set_property(NM.SETTING_IP_CONFIG_METHOD, "auto")
s_ip6 = NM.SettingIP6Config.new()
s_ip6.set_property(NM.SETTING_IP6_CONFIG_METHOD, "auto")
s_ip6.set_property(NM.SETTING_IP_CONFIG_METHOD, "auto")
profile.add_setting(s_con)
profile.add_setting(s_ip4)
@ -64,11 +64,12 @@ def create_profile(name):
return profile
# callback function
def added_cb(settings, con, error, data):
if error is (None):
def added_cb(client, result, data):
try:
client.add_connection_finish(result)
print("The connection profile has been succesfully added to NetworkManager.")
else:
print(error)
except Exception, e:
print("Error: %s" % e)
main_loop.quit()
if __name__ == "__main__":
@ -85,17 +86,14 @@ if __name__ == "__main__":
main_loop = GLib.MainLoop()
# create RemoteSettings object
settings = NM.RemoteSettings.new(None)
# create Client object
client = NM.Client.new(None)
# create a connection profile for NM
con = create_profile(profile_name)
# send the connection to NM
if persistent:
settings.add_connection(con, added_cb, None)
else:
settings.add_connection_unsaved(con, added_cb, None)
client.add_connection_async(con, persistent, None, added_cb, None)
main_loop.run()

View file

@ -48,8 +48,8 @@ if __name__ == "__main__":
sys.exit('Usage: %s <connection name or UUID> [new zone]' % sys.argv[0])
main_loop = GLib.MainLoop()
settings = NM.RemoteSettings.new(None)
connections = settings.list_connections()
client = NM.Client.new(None)
connections = client.get_connections()
con_name = sys.argv[1]
if len(sys.argv) == 3:

View file

@ -20,7 +20,7 @@
# Copyright 2014 Red Hat, Inc.
#
import sys, socket, struct
import sys, socket
from gi.repository import GLib, NM
#
@ -28,11 +28,11 @@ from gi.repository import GLib, NM
# from NMIP4Config and NMIP6Config (got out of NMDevice)
#
def show_addresses(self, family):
def show_addresses(dev, family):
if (family == socket.AF_INET):
ip_cfg = self.get_ip4_config()
ip_cfg = dev.get_ip4_config()
else:
ip_cfg = self.get_ip6_config()
ip_cfg = dev.get_ip6_config()
if ip_cfg is None:
print("None")
@ -46,24 +46,29 @@ def show_addresses(self, family):
for nm_address in nm_addresses:
addr = nm_address.get_address()
prefix = nm_address.get_prefix()
gateway = nm_address.get_gateway()
if (family == socket.AF_INET):
addr_struct = struct.pack("=I", addr)
gateway_struct = struct.pack("=I", gateway)
else:
addr_struct = addr
gateway_struct = gateway
print("%s/%d %s") % (socket.inet_ntop(family, addr_struct),
prefix,
socket.inet_ntop(family, gateway_struct))
print("%s/%d") % (addr, prefix)
def show_routes(self, family):
def show_gateway(dev, family):
if (family == socket.AF_INET):
ip_cfg = self.get_ip4_config()
ip_cfg = dev.get_ip4_config()
else:
ip_cfg = self.get_ip6_config()
ip_cfg = dev.get_ip6_config()
if ip_cfg is None:
gw = "None"
else:
gw = ip_cfg.get_gateway()
if gw == '':
gw = "None"
print(gw)
def show_routes(dev, family):
if (family == socket.AF_INET):
ip_cfg = dev.get_ip4_config()
else:
ip_cfg = dev.get_ip6_config()
if ip_cfg is None:
print("None")
@ -80,23 +85,14 @@ def show_routes(self, family):
next_hop = nm_route.get_next_hop()
metric = nm_route.get_metric()
if (family == socket.AF_INET):
dest_struct = struct.pack("=I", dest)
next_hop_struct = struct.pack("=I", next_hop)
else:
dest_struct = dest
next_hop_struct = next_hop
print("%s/%d %s %d") % (socket.inet_ntop(family, dest_struct),
prefix,
socket.inet_ntop(family, next_hop_struct),
metric)
print("%s/%d %s %d") % (dest, prefix, next_hop, metric)
def show_dns(self, family):
def show_dns(dev, family):
if (family == socket.AF_INET):
ip_cfg = self.get_ip4_config()
ip_cfg = dev.get_ip4_config()
else:
ip_cfg = self.get_ip6_config()
ip_cfg = dev.get_ip6_config()
if ip_cfg is None:
print("None")
@ -126,6 +122,11 @@ if __name__ == "__main__":
show_addresses(dev, socket.AF_INET)
print
print("IPv4 gateway:")
print("-------------")
show_gateway(dev, socket.AF_INET)
print
print("IPv4 routes:")
print("------------")
show_routes(dev, socket.AF_INET)
@ -136,6 +137,11 @@ if __name__ == "__main__":
show_addresses(dev, socket.AF_INET6)
print
print("IPv6 gateway:")
print("-------------")
show_gateway(dev, socket.AF_INET6)
print
print "IPv6 routes:"
print("------------")
show_routes(dev, socket.AF_INET6)

View file

@ -23,21 +23,16 @@
from gi.repository import NM
# This example asks settings service for all configured connections.
# Unfortunately, at this time since libnm still makes heavy use of
# GValue and GHashTable (rather than GVariant), libnm isn't fully
# usable from GObject Introspection-ready languages. Most functions will
# work fine, but e.g. nm_connection_to_dbus() causes failures.
def print_values(setting, key, value, flags, data):
print " %s.%s: %s" % (setting.get_name(), key, value)
if __name__ == "__main__":
# create RemoteSettings object
settings = NM.RemoteSettings.new(None)
# create Client object
client = NM.Client.new(None)
# get all connections
connections = settings.list_connections()
connections = client.get_connections()
# print the connections' details
for c in connections:

View file

@ -20,6 +20,7 @@
# Copyright (C) 2013 Red Hat, Inc.
#
import locale
from gi.repository import NM
#
@ -31,22 +32,20 @@ from gi.repository import NM
# an error without it: http://www.python.org/dev/peps/pep-0263/
#
signal_bars = {
0 : "____",
1 : "▂___",
2 : "▂▄__",
3 : "▂▄▆_",
4 : "▂▄▆█"
}
def clamp(value, minvalue, maxvalue):
return max(minvalue, min(value, maxvalue))
def ssid_to_utf8(ap):
ssid = ap.get_ssid()
if not ssid:
return ""
return NM.utils_ssid_to_utf8(ap.get_ssid().get_data())
def print_device_info(device):
active_ap = dev.get_active_access_point()
ssid = None
if active_ap is not None:
ssid = active_ap.get_ssid()
ssid = ssid_to_utf8(active_ap)
info = "Device: %s | Driver: %s | Active AP: %s" % (dev.get_iface(), dev.get_driver(), ssid)
print info
print '=' * len(info)
@ -54,14 +53,19 @@ def print_device_info(device):
def print_ap_info(ap):
strength = ap.get_strength()
frequency = ap.get_frequency()
print "SSID: %s" % (ap.get_ssid())
print "SSID: %s" % (ssid_to_utf8(ap))
print "BSSID: %s" % (ap.get_bssid())
print "Frequency: %s" % (frequency)
print "Channel: %s" % (NM.utils_wifi_freq_to_channel(frequency))
print "Strength: %s %s%%" % (signal_bars[(clamp(strength-5, 0, 99)+24)/25], strength)
print "Strength: %s %s%%" % (NM.utils_wifi_strength_bars(strength), strength)
print
if __name__ == "__main__":
# Python apparently doesn't call setlocale() on its own? We have to call this or else
# NM.utils_wifi_strength_bars() will think the locale is ASCII-only, and return the
# fallback characters rather than the unicode bars
locale.setlocale(locale.LC_ALL, '')
nmc = NM.Client.new(None)
devs = nmc.get_devices()

View file

@ -24,22 +24,11 @@
# using the libnm GObject-based convenience APIs.
#
# Configuration settings are described at
# https://developer.gnome.org/NetworkManager/0.9/ref-settings.html
# https://developer.gnome.org/NetworkManager/1.0/ref-settings.html
#
from gi.repository import GLib, NM
import sys, struct, socket
def ip_to_int(ip_string):
return struct.unpack("=I", socket.inet_aton(ip_string))[0]
# callback function
def commit_cb(connection, error, data):
if error is (None):
print("The connection profile has been updated.")
else:
print(error)
main_loop.quit()
import sys, socket
if __name__ == "__main__":
# parse and validate arguments
@ -48,7 +37,7 @@ if __name__ == "__main__":
sys.exit(1)
method = sys.argv[2]
if method == "static" or method == "manual" and len(sys.argv) < 5:
if (method == "static" or method == "manual") and len(sys.argv) < 5:
print "Usage: %s %s static address prefix [gateway]" % (sys.argv[0], sys.argv[1])
sys.exit(1)
@ -60,10 +49,10 @@ if __name__ == "__main__":
main_loop = GLib.MainLoop()
# create RemoteSettings object
settings = NM.RemoteSettings.new(None)
# create Client object
client = NM.Client.new(None)
all_connections = settings.list_connections()
all_connections = client.get_connections()
for c in all_connections:
if c.get_uuid() != uuid:
continue
@ -75,21 +64,22 @@ if __name__ == "__main__":
c.add_setting(s_ip4)
# set the method and change properties
s_ip4.set_property(NM.SETTING_IP4_CONFIG_METHOD, method)
s_ip4.set_property(NM.SETTING_IP_CONFIG_METHOD, method)
if method == "auto":
# remove addresses
# remove addresses and gateway
s_ip4.clear_addresses()
s_ip4.props.gateway = None
elif method == "manual":
# Add the static IP address, prefix, and (optional) gateway
addr = NM.IP4Address.new()
addr.set_address(ip_to_int(sys.argv[3]))
addr.set_prefix(int(sys.argv[4]))
if len(sys.argv) == 6:
addr.set_gateway(ip_to_int(sys.argv[5]))
addr = NM.IPAddress.new(socket.AF_INET, sys.argv[3], int(sys.argv[4]))
s_ip4.add_address(addr)
if len(sys.argv) == 6:
s_ip4.props.gateway = sys.argv[5]
c.commit_changes(commit_cb, None)
# run main loop
main_loop.run()
try:
c.commit_changes(True, None)
print("The connection profile has been updated.")
except Exception, e:
print("Error: %s" % e)
break

View file

@ -27,8 +27,13 @@ require 'ipaddr'
# It also shows how to specify D-Bus signature for properties like "addresses"
# and "clone-mac-address".
#
# This uses the old, backwards-compatible settings properties. The new 1.0
# properties (eg, 'address-data' rather than 'addresses') would make this simpler;
# see the python add-connection.py and add-connection-compat.py examples for
# details
#
# Configuration settings are described here:
# https://developer.gnome.org/NetworkManager/0.9/ref-settings.html
# https://developer.gnome.org/NetworkManager/1.0/ref-settings.html
#
# Helper functions

View file

@ -448,7 +448,7 @@ nm_setting_802_1x_get_ca_cert_scheme (NMSetting8021x *setting)
* reduces security by allowing man-in-the-middle attacks, because the identity
* of the network cannot be confirmed by the client.
*
* Returns: the CA certificate data
* Returns: (transfer none): the CA certificate data
**/
GBytes *
nm_setting_802_1x_get_ca_cert_blob (NMSetting8021x *setting)
@ -777,7 +777,7 @@ nm_setting_802_1x_get_client_cert_scheme (NMSetting8021x *setting)
* when EAP-TLS is used as either the "phase 1" or "phase 2" 802.1x
* authentication method.
*
* Returns: the client certificate data
* Returns: (transfer none): the client certificate data
**/
GBytes *
nm_setting_802_1x_get_client_cert_blob (NMSetting8021x *setting)
@ -1043,7 +1043,7 @@ nm_setting_802_1x_get_phase2_ca_cert_scheme (NMSetting8021x *setting)
* reduces security by allowing man-in-the-middle attacks, because the identity
* of the network cannot be confirmed by the client.
*
* Returns: the "phase 2" CA certificate data
* Returns: (transfer none): the "phase 2" CA certificate data
**/
GBytes *
nm_setting_802_1x_get_phase2_ca_cert_blob (NMSetting8021x *setting)
@ -1360,7 +1360,7 @@ nm_setting_802_1x_get_phase2_client_cert_scheme (NMSetting8021x *setting)
* when EAP-TLS is used as either the "phase 1" or "phase 2" 802.1x
* authentication method.
*
* Returns: the "phase 2" client certificate data
* Returns: (transfer none): the "phase 2" client certificate data
**/
GBytes *
nm_setting_802_1x_get_phase2_client_cert_blob (NMSetting8021x *setting)
@ -1530,7 +1530,7 @@ nm_setting_802_1x_get_password_flags (NMSetting8021x *setting)
* nm_setting_802_1x_get_password_raw:
* @setting: the #NMSetting8021x
*
* Returns: the password used by the authentication method as a
* Returns: (transfer none): the password used by the authentication method as a
* UTF-8-encoded array of bytes, as specified by the
* #NMSetting8021x:password-raw property
**/
@ -1619,7 +1619,7 @@ nm_setting_802_1x_get_private_key_scheme (NMSetting8021x *setting)
* unencrypted private key data may be readable by unprivileged users. Private
* keys should always be encrypted with a private key password.
*
* Returns: the private key data
* Returns: (transfer none): the private key data
**/
GBytes *
nm_setting_802_1x_get_private_key_blob (NMSetting8021x *setting)
@ -1954,7 +1954,7 @@ nm_setting_802_1x_get_phase2_private_key_scheme (NMSetting8021x *setting)
* unencrypted private key data may be readable by unprivileged users. Private
* keys should always be encrypted with a private key password.
*
* Returns: the "phase 2" private key data
* Returns: (transfer none): the "phase 2" private key data
**/
GBytes *
nm_setting_802_1x_get_phase2_private_key_blob (NMSetting8021x *setting)

View file

@ -136,10 +136,11 @@ nm_setting_bond_get_num_options (NMSettingBond *setting)
* @setting: the #NMSettingBond
* @idx: index of the desired option, from 0 to
* nm_setting_bond_get_num_options() - 1
* @out_name: (out): on return, the name of the bonding option; this
* value is owned by the setting and should not be modified
* @out_value: (out): on return, the value of the name of the bonding
* option; this value is owned by the setting and should not be modified
* @out_name: (out) (transfer none): on return, the name of the bonding option;
* this value is owned by the setting and should not be modified
* @out_value: (out) (transfer none): on return, the value of the name of the
* bonding option; this value is owned by the setting and should not be
* modified
*
* Given an index, return the value of the bonding option at that index. Indexes
* are *not* guaranteed to be static across modifications to options done by

View file

@ -71,6 +71,11 @@ nm_setting_olpc_mesh_init (NMSettingOlpcMesh *setting)
{
}
/**
* nm_setting_olpc_mesh_get_ssid:
*
* Returns: (transfer none):
*/
GBytes *
nm_setting_olpc_mesh_get_ssid (NMSettingOlpcMesh *setting)
{

View file

@ -412,10 +412,11 @@ nm_setting_wired_get_num_s390_options (NMSettingWired *setting)
* @setting: the #NMSettingWired
* @idx: index of the desired option, from 0 to
* nm_setting_wired_get_num_s390_options() - 1
* @out_key: (out): on return, the key name of the s390 specific option; this
* value is owned by the setting and should not be modified
* @out_value: (out): on return, the value of the key of the s390 specific
* option; this value is owned by the setting and should not be modified
* @out_key: (out) (transfer none): on return, the key name of the s390 specific
* option; this value is owned by the setting and should not be modified
* @out_value: (out) (transfer none): on return, the value of the key of the
* s390 specific option; this value is owned by the setting and should not be
* modified
*
* Given an index, return the value of the s390 option at that index. indexes
* are *not* guaranteed to be static across modifications to options done by

View file

@ -295,7 +295,7 @@ nm_setting_wireless_new (void)
* nm_setting_wireless_get_ssid:
* @setting: the #NMSettingWireless
*
* Returns: the #NMSettingWireless:ssid property of the setting
* Returns: (transfer none): the #NMSettingWireless:ssid property of the setting
**/
GBytes *
nm_setting_wireless_get_ssid (NMSettingWireless *setting)

View file

@ -275,7 +275,7 @@ nm_utils_deinit (void)
/**
* nm_utils_ssid_to_utf8:
* @ssid: pointer to a buffer containing the SSID data
* @ssid: (array length=len): pointer to a buffer containing the SSID data
* @len: length of the SSID data in @ssid
*
* Wi-Fi SSIDs are byte arrays, they are _not_ strings. Thus, an SSID may
@ -347,7 +347,7 @@ nm_utils_ssid_to_utf8 (const guint8 *ssid, gsize len)
/* Shamelessly ripped from the Linux kernel ieee80211 stack */
/**
* nm_utils_is_empty_ssid:
* @ssid: pointer to a buffer containing the SSID data
* @ssid: (array length=len): pointer to a buffer containing the SSID data
* @len: length of the SSID data in @ssid
*
* Different manufacturers use different mechanisms for not broadcasting the
@ -375,7 +375,7 @@ nm_utils_is_empty_ssid (const guint8 *ssid, gsize len)
/**
* nm_utils_escape_ssid:
* @ssid: pointer to a buffer containing the SSID data
* @ssid: (array length=len): pointer to a buffer containing the SSID data
* @len: length of the SSID data in @ssid
*
* This function does a quick printable character conversion of the SSID, simply
@ -414,9 +414,9 @@ nm_utils_escape_ssid (const guint8 *ssid, gsize len)
/**
* nm_utils_same_ssid:
* @ssid1: the first SSID to compare
* @ssid1: (array length=len1): the first SSID to compare
* @len1: length of the SSID data in @ssid1
* @ssid2: the second SSID to compare
* @ssid2: (array length=len2): the second SSID to compare
* @len2: length of the SSID data in @ssid2
* @ignore_trailing_null: %TRUE to ignore one trailing NULL byte
*
@ -2063,19 +2063,19 @@ make_key (const char *cipher,
/**
* nm_utils_rsa_key_encrypt_helper:
* @cipher: cipher to use for encryption ("DES-EDE3-CBC" or "AES-128-CBC")
* @data: RSA private key data to be encrypted
* @data: (array length=len): RSA private key data to be encrypted
* @len: length of @data
* @in_password: (allow-none): existing password to use, if any
* @out_password: (out) (allow-none): if @in_password was %NULL, a random password will be generated
* and returned in this argument
* @out_password: (out) (allow-none): if @in_password was %NULL, a random
* password will be generated and returned in this argument
* @error: detailed error information on return, if an error occurred
*
* Encrypts the given RSA private key data with the given password (or generates
* a password if no password was given) and converts the data to PEM format
* suitable for writing to a file.
*
* Returns: (transfer full): on success, PEM-formatted data suitable for writing to a PEM-formatted
* certificate/private key file.
* Returns: (transfer full): on success, PEM-formatted data suitable for writing
* to a PEM-formatted certificate/private key file.
**/
static GByteArray *
nm_utils_rsa_key_encrypt_helper (const char *cipher,
@ -2173,19 +2173,19 @@ out:
/**
* nm_utils_rsa_key_encrypt:
* @data: RSA private key data to be encrypted
* @data: (array length=len): RSA private key data to be encrypted
* @len: length of @data
* @in_password: (allow-none): existing password to use, if any
* @out_password: (out) (allow-none): if @in_password was %NULL, a random password will be generated
* and returned in this argument
* @out_password: (out) (allow-none): if @in_password was %NULL, a random
* password will be generated and returned in this argument
* @error: detailed error information on return, if an error occurred
*
* Encrypts the given RSA private key data with the given password (or generates
* a password if no password was given) and converts the data to PEM format
* suitable for writing to a file. It uses Triple DES cipher for the encryption.
*
* Returns: (transfer full): on success, PEM-formatted data suitable for writing to a PEM-formatted
* certificate/private key file.
* Returns: (transfer full): on success, PEM-formatted data suitable for writing
* to a PEM-formatted certificate/private key file.
**/
GByteArray *
nm_utils_rsa_key_encrypt (const guint8 *data,
@ -2205,19 +2205,19 @@ nm_utils_rsa_key_encrypt (const guint8 *data,
/**
* nm_utils_rsa_key_encrypt_aes:
* @data: RSA private key data to be encrypted
* @data: (array length=len): RSA private key data to be encrypted
* @len: length of @data
* @in_password: (allow-none): existing password to use, if any
* @out_password: (out) (allow-none): if @in_password was %NULL, a random password will be generated
* and returned in this argument
* @out_password: (out) (allow-none): if @in_password was %NULL, a random
* password will be generated and returned in this argument
* @error: detailed error information on return, if an error occurred
*
* Encrypts the given RSA private key data with the given password (or generates
* a password if no password was given) and converts the data to PEM format
* suitable for writing to a file. It uses AES cipher for the encryption.
*
* Returns: (transfer full): on success, PEM-formatted data suitable for writing to a PEM-formatted
* certificate/private key file.
* Returns: (transfer full): on success, PEM-formatted data suitable for writing
* to a PEM-formatted certificate/private key file.
**/
GByteArray *
nm_utils_rsa_key_encrypt_aes (const guint8 *data,
@ -2635,7 +2635,7 @@ nm_utils_hwaddr_aton (const char *asc, gpointer buffer, gsize length)
/**
* nm_utils_hwaddr_ntoa:
* @addr: a binary hardware address
* @addr: (type guint8) (array length=length): a binary hardware address
* @length: the length of @addr
*
* Converts @addr to textual form.
@ -2881,8 +2881,8 @@ _nm_utils_hwaddr_from_dbus (GVariant *dbus_value,
/**
* nm_utils_bin2hexstr:
* @src: an array of bytes
* @len: the length of the @bytes array
* @src: (type guint8) (array length=len): an array of bytes
* @len: the length of the @src array
* @final_len: an index where to cut off the returned string, or -1
*
* Converts the byte array @src into a hexadecimal string. If @final_len is

View file

@ -122,7 +122,8 @@ nm_access_point_get_rsn_flags (NMAccessPoint *ap)
*
* Gets the SSID of the access point.
*
* Returns: the #GBytes containing the SSID, or %NULL if the SSID is unknown.
* Returns: (transfer none): the #GBytes containing the SSID, or %NULL if the
* SSID is unknown.
**/
GBytes *
nm_access_point_get_ssid (NMAccessPoint *ap)