#!/usr/bin/python

import dbus, flimflam, sys

if (len(sys.argv) < 2):
    print "Usage: %s <mtu>" % (sys.argv[0])
    sys.exit(1)

(_, mtu) = sys.argv

flim = flimflam.FlimFlam(dbus.SystemBus())

for device in flim.GetObjectList("Device"):
    device_properties = device.GetProperties(utf8_strings = True)

    for path in device_properties["IPConfigs"]:
        ipconfig = flim.GetObjectInterface("IPConfig", path)
        ipconfig.SetProperty("Mtu", int(mtu))