paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * ipforward value get function for solaris. |
| 3 | * Copyright (C) 1997 Kunihiro Ishiguro |
| 4 | * |
| 5 | * This file is part of GNU Zebra. |
| 6 | * |
| 7 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the |
| 9 | * Free Software Foundation; either version 2, or (at your option) any |
| 10 | * later version. |
| 11 | * |
| 12 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with GNU Zebra; see the file COPYING. If not, write to the Free |
| 19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 20 | * 02111-1307, USA. |
| 21 | */ |
| 22 | |
| 23 | #include <zebra.h> |
| 24 | |
| 25 | #include "memory.h" |
| 26 | |
| 27 | int |
| 28 | ipforward () |
| 29 | { |
| 30 | int fd, ret; |
| 31 | int ipforwarding = 0; |
| 32 | char forward[] = "ip_forwarding"; |
| 33 | char *buf; |
| 34 | struct strioctl si; |
| 35 | |
| 36 | buf = (char *) XMALLOC (MTYPE_TMP, sizeof forward + 1); |
| 37 | strcpy (buf, forward); |
| 38 | |
| 39 | fd = open ("/dev/ip", O_RDWR); |
| 40 | if (fd < 0) { |
| 41 | free (buf); |
| 42 | /* need logging here */ |
| 43 | /* "I can't get ipforwarding value because can't open /dev/ip" */ |
| 44 | return -1; |
| 45 | } |
| 46 | |
| 47 | si.ic_cmd = ND_GET; |
| 48 | si.ic_timout = 0; |
| 49 | si.ic_len = strlen (buf) + 1; |
| 50 | si.ic_dp = (caddr_t) buf; |
| 51 | |
| 52 | ret = ioctl (fd, I_STR, &si); |
| 53 | close (fd); |
| 54 | |
| 55 | if (ret < 0) { |
| 56 | free (buf); |
| 57 | /* need logging here */ |
| 58 | /* can't get ipforwarding value : ioctl failed */ |
| 59 | return -1; |
| 60 | } |
| 61 | |
| 62 | ipforwarding = atoi (buf); |
| 63 | free (buf); |
| 64 | return ipforwarding; |
| 65 | } |
| 66 | |
| 67 | int |
| 68 | ipforward_on () |
| 69 | { |
| 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | int |
| 74 | ipforward_off () |
| 75 | { |
| 76 | return 0; |
| 77 | } |