NetworkInador/client-gtk/ni-ip.h

89 lines
2.4 KiB
C
Raw Normal View History

/*
* ni-interface.h
* This file is part of NetworkInador
*
* Copyright (C) 2021 - Gatuno
*
* NetworkInador 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.
*
* NetworkInador 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 NetworkInador; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
/* inclusion guard */
#ifndef __NI_IP_H__
#define __NI_IP_H__
#include <glib-object.h>
#include <stdint.h>
#include <sys/socket.h>
#include <netinet/in.h>
G_BEGIN_DECLS
typedef union {
struct in_addr v4;
struct in6_addr v6;
} struct_addr;
typedef struct _NIIPClass NIIPClass;
typedef struct _NIIP NIIP;
typedef struct _NIIPPrivate NIIPPrivate;
typedef struct _NIInterface NIInterface;
/*
* Type declaration.
*/
#define NI_TYPE_IP (ni_ip_get_type ())
#define NI_IP(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), NI_TYPE_IP, NIIP))
#define NI_IP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), NI_TYPE_IP, NIIPClass))
#define NI_IS_IP(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NI_TYPE_IP))
#define NI_IS_IP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NI_TYPE_IP))
#define NI_IP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), NI_TYPE_IP, NIIPClass))
GType ni_ip_get_type (void);
struct _NIIPClass {
GObjectClass parent_class;
};
struct _NIIP {
GObject parent_instance;
NIIPPrivate *priv;
};
/*
* Method definitions.
*/
gboolean ni_ip_has_local (NIIP *ni_ip);
gboolean ni_ip_has_brd (NIIP *ni_ip);
guint ni_ip_get_family (NIIP *ni_ip);
guint ni_ip_get_prefix (NIIP *ni_ip);
uint32_t ni_ip_get_flags (NIIP *ni_ip);
unsigned char ni_ip_get_scope (NIIP *ni_ip);
const struct_addr *ni_ip_get_addr (NIIP *ni_ip);
const struct_addr *ni_ip_get_local_addr (NIIP *ni_ip);
const struct_addr *ni_ip_get_brd_addr (NIIP *ni_ip);
NIIP *ni_ip_new (NIInterface *ni_interface, int family, int prefix, struct_addr *addr, uint32_t flags, unsigned char scope, int has_local, struct_addr *local_addr, int has_brd, struct_addr *brd_addr);
G_END_DECLS
#endif /* __NI_IP_H__ */