Commit c39587c1 authored by Dan Williams's avatar Dan Williams

Initial revision


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent 51bb897c
Dan Williams <dcbw@redhat.com>
SUBDIRS = src initscript test
This diff is collapsed.
This diff is collapsed.
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
ORIGDIR=`pwd`
cd $srcdir
PROJECT=NetworkManager
TEST_TYPE=-d
FILE=src
DIE=0
if $have_libtool ; then : ; else
echo
echo "You must have libtool 1.4 installed to compile $PROJECT."
echo "Install the appropriate package for your distribution,"
echo "or get the source tarball at http://ftp.gnu.org/gnu/libtool/"
DIE=1
fi
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have autoconf installed to compile $PROJECT."
echo "Install the appropriate package for your distribution,"
echo "or get the source tarball at http://ftp.gnu.org/gnu/autoconf/"
DIE=1
}
if automake-1.7 --version < /dev/null > /dev/null 2>&1 ; then
AUTOMAKE=automake-1.7
ACLOCAL=aclocal-1.7
else
echo
echo "You must have automake 1.7.x installed to compile $PROJECT."
echo "Install the appropriate package for your distribution,"
echo "or get the source tarball at http://ftp.gnu.org/gnu/automake/"
DIE=1
fi
if test "$DIE" -eq 1; then
exit 1
fi
test $TEST_TYPE $FILE || {
echo "You must run this script in the top-level $PROJECT directory"
exit 1
}
if test -z "$AUTOGEN_SUBDIR_MODE"; then
if test -z "$*"; then
echo "I am going to run ./configure with no arguments - if you wish "
echo "to pass any to it, please specify them on the $0 command line."
fi
fi
$ACLOCAL -I . $ACLOCALFLAGS || exit $?
$AUTOMAKE --add-missing || exit $?
autoconf || exit $?
cd $ORIGDIR || exit $?
if test -z "$AUTOGEN_SUBDIR_MODE"; then
$srcdir/configure --enable-maintainer-mode $AUTOGEN_CONFIGURE_ARGS "$@" || exit $?
echo
echo "Now type 'make' to compile $PROJECT."
fi
This diff is collapsed.
AC_PREREQ(2.52)
AC_INIT(NetworkManager, 0.1)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
AC_PROG_CC
AC_CHECK_HEADER(iwlib.h, [],
[AC_MSG_ERROR(iwlib.h not found. Install wireless-tools.)], [])
AC_CHECK_LIB(iw, iw_scan, [ IWLIB=-liw ],
[AC_MSG_ERROR(wireless-tools 27.pre23 not installed or not functional)], [])
AC_SUBST(IWLIB)
PKG_CHECK_MODULES(NM, dbus-glib-1 >= 0.20 hal >= 0.2.91 gthread-2.0)
AC_SUBST(NM_CFLAGS)
AC_SUBST(NM_LIBS)
AC_OUTPUT([
Makefile
test/Makefile
src/Makefile
initscript/Makefile
])
EXTRA_DIST = NetworkManager
rcddir = $(sysconfdir)/rc.d/init.d
rcd_DATA = NetworkManager
# Makefile.in generated by automake 1.7.9 from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
# Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
IWLIB = @IWLIB@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
NM_CFLAGS = @NM_CFLAGS@
NM_LIBS = @NM_LIBS@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
ac_ct_CC = @ac_ct_CC@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
bindir = @bindir@
build_alias = @build_alias@
datadir = @datadir@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
EXTRA_DIST = NetworkManager
rcddir = $(sysconfdir)/rc.d/init.d
rcd_DATA = NetworkManager
subdir = initscript
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_CLEAN_FILES =
DIST_SOURCES =
DATA = $(rcd_DATA)
DIST_COMMON = $(srcdir)/Makefile.in Makefile.am
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu initscript/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
uninstall-info-am:
rcdDATA_INSTALL = $(INSTALL_DATA)
install-rcdDATA: $(rcd_DATA)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(rcddir)
@list='$(rcd_DATA)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " $(rcdDATA_INSTALL) $$d$$p $(DESTDIR)$(rcddir)/$$f"; \
$(rcdDATA_INSTALL) $$d$$p $(DESTDIR)$(rcddir)/$$f; \
done
uninstall-rcdDATA:
@$(NORMAL_UNINSTALL)
@list='$(rcd_DATA)'; for p in $$list; do \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " rm -f $(DESTDIR)$(rcddir)/$$f"; \
rm -f $(DESTDIR)$(rcddir)/$$f; \
done
tags: TAGS
TAGS:
ctags: CTAGS
CTAGS:
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
top_distdir = ..
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkinstalldirs) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(DATA)
installdirs:
$(mkinstalldirs) $(DESTDIR)$(rcddir)
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am:
info: info-am
info-am:
install-data-am: install-rcdDATA
install-exec-am:
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-rcdDATA
.PHONY: all all-am check check-am clean clean-generic distclean \
distclean-generic distdir dvi dvi-am info info-am install \
install-am install-data install-data-am install-exec \
install-exec-am install-info install-info-am install-man \
install-rcdDATA install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \
uninstall-am uninstall-info-am uninstall-rcdDATA
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
#!/bin/sh
#
# NetworkManager: NetworkManager daemon
#
# chkconfig: 345 98 02
# description: This is a daemon for automatically switching network \
# connections to the best available connection. \
#
# processname: NetworkManager
# pidfile: /var/run/NetworkManager.pid
#
# Sanity checks.
[ -x /usr/bin/NetworkManager ] || exit 0
# Source function library.
. /etc/rc.d/init.d/functions
# so we can rearrange this easily
processname=NetworkManager
servicename=NetworkManager
RETVAL=0
start() {
echo -n $"Starting NetworkManager daemon: "
daemon --check $servicename $processname
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$servicename && echo `/sbin/pidof $processname` > /var/run/NetworkManager.pid
}
stop() {
echo -n $"Stopping NetworkManager daemon: "
killproc $servicename -TERM
RETVAL=$?
echo
if [ $RETVAL -eq 0 ]; then
rm -f /var/lock/subsys/$servicename
rm -f /var/run/NetworkManager.pid
fi
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $processname
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f /var/lock/subsys/$servicename ]; then
stop
start
fi
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart}"
;;
esac
exit $RETVAL
/* -*- mode: C; c-file-style: "linux" -*- */
/* MemProf -- memory profiler and leak detector
* Copyright 1999, 2000, 2001, Red Hat, Inc.
* Copyright 2002, Kristian Rietveld
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*====*/
#include <glib.h>
#include <sys/stat.h>
#include <dirent.h>
#include "memprof.h"
/************************************************************
* Inode finding code - not needed for kernel 2.2 or greater
************************************************************/
GHashTable *inode_table = NULL;
typedef struct {
dev_t device;
ino_t inode;
gchar *name;
} Inode;
static guint
inode_hash (gconstpointer data)
{
return (((Inode *)data)->device + (((Inode *)data)->inode << 11));
}
static gint
inode_compare (gconstpointer a, gconstpointer b)
{
return ((((Inode *)a)->device == ((Inode *)b)->device) &&
(((Inode *)a)->inode == ((Inode *)b)->inode));
}
void
read_inode (const gchar *path)
{
struct stat stbuf;
g_return_if_fail (path != NULL);
if (!inode_table)
inode_table = g_hash_table_new (inode_hash, inode_compare);
if (!stat (path, &stbuf)) {
Inode *inode = g_new (Inode, 1);
inode->device = stbuf.st_dev;
inode->inode = stbuf.st_ino;
if (!g_hash_table_lookup (inode_table, inode)) {
inode->name = g_strdup (path);
g_hash_table_insert (inode_table, inode, inode);
} else
g_free (inode);
}
}
static void
read_inodes ()
{
static const char *directories[] = {
"/lib",
"/usr/lib",
"/usr/X11R6/lib",
"/usr/local/lib",
"/opt/gnome/lib",
NULL
};
const char **dirname;
for (dirname = directories; *dirname; dirname++)
{
DIR *dir = opendir (*dirname);
if (dir) {
struct dirent *ent;
while ((ent = readdir (dir))) {
gchar buf[1024];
snprintf(buf, 1024-1, "%s/%s", *dirname, ent->d_name);
read_inode (buf);
}
closedir (dir);
}
}
}
gchar *
locate_inode (dev_t device, ino_t inode)
{
Inode lookup;
Inode *result;
lookup.device = device;
lookup.inode = inode;
if (!inode_table)
read_inodes ();
result = g_hash_table_lookup (inode_table, &lookup);
if (result)
return result->name;
else
return NULL;
}
EXTRA_DIST = NetworkManager.conf
INCLUDES = \
$(NM_CFLAGS) \
-DDBUS_API_SUBJECT_TO_CHANGE \
-DBINDIR=\"$(bindir)\" \
-DDATADIR=\"$(datadir)\"
bin_PROGRAMS = NetworkManager
NetworkManager_SOURCES = \
NetworkManagerAP.c \
NetworkManagerAP.h \
NetworkManagerDbus.c \
NetworkManagerDbus.h \
NetworkManagerDevice.c \
NetworkManagerDevice.h \
NetworkManager.c \
NetworkManager.h \
NetworkManagerPolicy.c \
NetworkManagerPolicy.h \
NetworkManagerUtils.c \
NetworkManagerUtils.h \
NetworkManagerWireless.c \
NetworkManagerWireless.h
NetworkManager_LDADD = $(NM_LIBS) $(IWLIB)
dbusservicedir = $(sysconfdir)/dbus-1/system.d
dbusservice_DATA = NetworkManager.conf
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy context="default">
<allow own="org.freedesktop.NetworkManager"/>
<allow send_destination="org.freedesktop.NetworkManager"/>
<allow send_interface="org.freedesktop.NetworkManager"/>
</policy>
</busconfig>
/* NetworkManager -- Network link manager
*
* Dan Williams <dcbw@redhat.com>
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* (C) Copyright 2004 Red Hat, Inc.
*/
#ifndef NETWORK_MANAGER_H
#define NETWORK_MANAGER_H
#include <glib.h>
#include <glib/gthread.h>
#include <hal/libhal.h>
#include "NetworkManagerAP.h"
struct NMData
{
LibHalContext *hal_ctx;
GSList *dev_list;
GMutex *dev_list_mutex;
struct NMDevice *active_device;
gboolean state_modified;
GMutex *state_modified_mutex;
GSList *allowed_ap_list;
GMutex *allowed_ap_list_mutex;
NMAccessPoint *desired_ap;
DBusConnection *dbus_connection;
};
typedef struct NMData NMData;
void nm_data_set_state_modified (NMData *data, gboolean modified);
void nm_data_allowed_ap_list_free (NMData *data);
NMData *nm_get_global_data (void);
#endif
/* NetworkManager -- Network link manager
*
* Dan Williams <dcbw@redhat.com>
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* (C) Copyright 2004 Red Hat, Inc.
*/
#include "NetworkManagerAP.h"
#include "NetworkManagerUtils.h"
extern gboolean debug;
/*
* Encapsulates Access Point information
*/
struct NMAccessPoint
{
guint refcount;
gchar *essid;
gchar *address;
guint8 quality;
double freq;
guint16 rate;
time_t stamp;
/* Things from user prefs */
gchar *wep_key;
guint priority;
};
/*
* nm_ap_new
*
* Create a new, blank user access point info structure