Skip to content

Commit

Permalink
ppp: initial pppoe service implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
wipawel authored and mtomaschewski committed May 13, 2016
1 parent 7f10750 commit 20963fd
Show file tree
Hide file tree
Showing 12 changed files with 1,610 additions and 557 deletions.
141 changes: 99 additions & 42 deletions include/wicked/ppp.h
@@ -1,60 +1,117 @@
/*
* Track ppp client end point state
* Track ppp client end point state
*
* Copyright (C) 2012 Olaf Kirch <okir@suse.de>
* Copyright (C) 2012-2016 SUSE Linux GmbH, Nuernberg, Germany.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Authors:
* Olaf Kirch <okir@suse.de>
* Pawel Wieczorkiewicz <pwieczorkiewicz@suse.de>
* Marius Tomaschewski <mt@suse.de>
*/

#ifndef __WICKED_PPP_H__
#define __WICKED_PPP_H__
#ifndef WICKED_PPP_H
#define WICKED_PPP_H

#include <wicked/netinfo.h>

typedef struct ni_ppp_config ni_ppp_config_t;
typedef struct ni_ppp_authconfig ni_ppp_authconfig_t;
typedef struct ni_ppp_config ni_ppp_config_t;
typedef struct ni_ppp_auth_config ni_ppp_auth_config_t;
typedef struct ni_ppp_ipv4_config ni_ppp_ipv4_config_t;
typedef struct ni_ppp_ipv6_config ni_ppp_ipv6_config_t;

typedef struct ni_ppp_mode ni_ppp_mode_t;
typedef struct ni_ppp_mode_pppoe ni_ppp_mode_pppoe_t;

typedef enum {
NI_PPP_MODE_UNKNOWN = 0U,
NI_PPP_MODE_PPPOE,
NI_PPP_MODE_PPPOATM,
NI_PPP_MODE_PPTP,
NI_PPP_MODE_ISDN,
NI_PPP_MODE_SERIAL,
} ni_ppp_mode_type_t;

struct ni_ppp_mode_pppoe {
ni_netdev_ref_t device; /* ethernet device */
};

struct ni_ppp_mode {
ni_ppp_mode_type_t type;

union {
ni_ppp_mode_pppoe_t pppoe;
};
};

struct ni_ppp_auth_config {
char * hostname;
char * username;
char * password;
};

struct ni_ppp_ipv4_config {
ni_sockaddr_t local_ip;
ni_sockaddr_t remote_ip;

struct ni_ppp_config {
struct {
char * object_path;
ni_modem_t * modem;
ni_netdev_t * ethernet;
char * name;
} device;

unsigned int mru;
char * number;
unsigned int idle_timeout;
ni_ppp_authconfig_t * auth;
ni_bool_t accept_local;
ni_bool_t accept_remote;
} ipcp;
};

struct ni_ppp_authconfig {
char * hostname;
char * username;
char * password;
struct ni_ppp_ipv6_config {
ni_bool_t enabled;

ni_sockaddr_t local_ip;
ni_sockaddr_t remote_ip;

struct {
ni_bool_t accept_local;
} ipcp;
};

/*
* For every ppp device, we need to store the /dev/ppp file descriptor
* we used for creating the device.
*/
struct ni_ppp {
unsigned int unit;
char devname[IFNAMSIZ];
int devfd;
struct ni_ppp_config {
ni_bool_t debug;
ni_bool_t demand;
ni_bool_t persist;
unsigned int idle;
unsigned int maxfail;
unsigned int holdoff;

ni_bool_t multilink;
char * endpoint;

ni_ppp_config_t * config;
ni_tempstate_t * temp_state;
ni_bool_t usepeerdns;
ni_bool_t defaultroute;

ni_ppp_auth_config_t auth;
ni_ppp_ipv4_config_t ipv4;
ni_ppp_ipv6_config_t ipv6;
};

extern ni_ppp_t * ni_ppp_new(const char *);
extern void ni_ppp_close(ni_ppp_t *);
extern void ni_ppp_free(ni_ppp_t *);
extern int ni_ppp_write_config(const ni_ppp_t *);
extern ni_bool_t ni_ppp_check_config(const ni_ppp_t *);
struct ni_ppp {
ni_ppp_mode_t mode;
ni_ppp_config_t config;
};

extern ni_ppp_config_t * ni_ppp_config_new(void);
extern void ni_ppp_config_free(ni_ppp_config_t *);
extern ni_ppp_authconfig_t * ni_ppp_authconfig_new(void);
extern void ni_ppp_authconfig_free(ni_ppp_authconfig_t *);
extern ni_ppp_t * ni_ppp_new(void);
extern void ni_ppp_free(ni_ppp_t *);
extern ni_ppp_t * ni_ppp_clone(ni_ppp_t *);

#endif /* __WICKED_PPP_H__ */
extern void ni_ppp_mode_init(ni_ppp_mode_t *, ni_ppp_mode_type_t);
extern const char * ni_ppp_mode_type_to_name(ni_ppp_mode_type_t);
extern ni_bool_t ni_ppp_mode_name_to_type(const char *, ni_ppp_mode_type_t *);

#endif /* WICKED_PPP_H */
9 changes: 6 additions & 3 deletions include/wicked/system.h
Expand Up @@ -78,9 +78,12 @@ extern int ni_system_tuntap_delete(ni_netdev_t *);
extern int ni_system_tap_create(ni_netconfig_t *, const char *,
ni_netdev_t **);
extern int ni_system_tap_delete(ni_netdev_t *);
extern int ni_system_ppp_create(ni_netconfig_t *, const char *,
ni_ppp_t *, ni_netdev_t **);
extern int ni_system_ppp_delete(ni_netdev_t *);
extern int ni_system_ppp_create(ni_netconfig_t *nc,
const ni_netdev_t *, ni_netdev_t **);
extern int ni_system_ppp_setup(ni_netconfig_t *nc, ni_netdev_t *,
const ni_netdev_t *);
extern int ni_system_ppp_shutdown(ni_netdev_t *);
extern int ni_system_ppp_delete(ni_netconfig_t *nc, ni_netdev_t *);

extern int ni_system_tunnel_create(ni_netconfig_t *, const ni_netdev_t *,
ni_netdev_t **, unsigned int);
Expand Down
2 changes: 2 additions & 0 deletions src/Makefile.am
Expand Up @@ -87,6 +87,7 @@ libwicked_la_SOURCES = \
openvpn.c \
ovs.c \
ppp.c \
pppd.c \
process.c \
resolver.c \
rfkill.c \
Expand Down Expand Up @@ -212,6 +213,7 @@ wicked_headers = \
modprobe.h \
netinfo_priv.h \
ovs.h \
pppd.h \
process.h \
socket_priv.h \
sysfs.h \
Expand Down

0 comments on commit 20963fd

Please sign in to comment.