1/* 2 * Copyright (C) 2000 Lennert Buytenhek 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License as 6 * published by the Free Software Foundation; either version 2 of the 7 * License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, but 10 * WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 */ 18 19#ifndef _LIBBRIDGE_PRIVATE_H 20#define _LIBBRIDGE_PRIVATE_H 21 22#include "config.h" 23 24#include <linux/sockios.h> 25#include <sys/time.h> 26#include <sys/ioctl.h> 27#include <linux/if_bridge.h> 28#include <asm/param.h> 29 30#define MAX_BRIDGES 1024 31#define MAX_PORTS 1024 32 33#define dprintf(fmt,arg...) 34 35#ifdef HAVE_LIBSYSFS 36#include <sysfs/libsysfs.h> 37 38#ifndef SYSFS_BRIDGE_PORT_ATTR 39#error Using wrong kernel headers if_bridge.h is out of date. 40#endif 41 42#ifndef SIOCBRADDBR 43#error Using wrong kernel headers sockios.h is out of date. 44#endif 45 46#else 47struct sysfs_class { const char *name; }; 48 49static inline struct sysfs_class *sysfs_open_class(const char *name) 50{ 51 return NULL; 52} 53 54static inline void sysfs_close_class(struct sysfs_class *class) 55{ 56} 57#endif 58 59extern int br_socket_fd; 60extern struct sysfs_class *br_class_net; 61 62static inline unsigned long __tv_to_jiffies(const struct timeval *tv) 63{ 64 unsigned long long jif; 65 66 jif = 1000000ULL * tv->tv_sec + tv->tv_usec; 67 68 return (HZ*jif)/1000000; 69} 70 71static inline void __jiffies_to_tv(struct timeval *tv, unsigned long jiffies) 72{ 73 unsigned long long tvusec; 74 75 tvusec = (1000000ULL*jiffies)/HZ; 76 tv->tv_sec = tvusec/1000000; 77 tv->tv_usec = tvusec - 1000000 * tv->tv_sec; 78} 79#endif 80