jjako | 52c2414 | 2002-12-16 13:33:51 +0000 | [diff] [blame] | 1 | /* |
| 2 | * OpenGGSN - Gateway GPRS Support Node |
| 3 | * Copyright (C) 2002 Mondru AB. |
| 4 | * |
| 5 | * The contents of this file may be used under the terms of the GNU |
| 6 | * General Public License Version 2, provided that the above copyright |
| 7 | * notice and this permission notice is included in all copies or |
| 8 | * substantial portions of the software. |
| 9 | * |
| 10 | * The initial developer of the original code is |
| 11 | * Jens Jakobsen <jj@openggsn.org> |
| 12 | * |
| 13 | * Contributor(s): |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #ifndef _TUN_H |
| 18 | #define _TUN_H |
| 19 | |
| 20 | #define hton8(x) (x) |
| 21 | #define ntoh8(x) (x) |
| 22 | #define hton16(x) htons(x) |
| 23 | #define ntoh16(x) ntohs(x) |
| 24 | #define hton32(x) htonl(x) |
| 25 | #define ntoh32(x) ntohl(x) |
| 26 | |
| 27 | #define PACKET_MAX 8196 /* TODO */ |
| 28 | |
| 29 | /* *********************************************************** |
| 30 | * Information storage for each tun instance |
| 31 | *************************************************************/ |
| 32 | |
| 33 | struct tun_t { |
| 34 | int fd; /* File descriptor to network interface */ |
| 35 | struct in_addr addr; /* IP address of tun interface */ |
| 36 | char devname[IFNAMSIZ];/* Name of the tun device */ |
| 37 | }; |
| 38 | |
| 39 | |
| 40 | extern int tun_newtun(struct tun_t **tun); |
| 41 | extern int tun_freetun(struct tun_t *tun); |
| 42 | extern int tun_decaps(struct tun_t *tun, |
| 43 | int (*cb) (void *cl, struct tun_t*, void *pack, unsigned len), |
| 44 | void *cl); |
| 45 | extern int tun_encaps(struct tun_t *tun, void *pack, unsigned len); |
| 46 | |
| 47 | |
| 48 | #endif /* !_TUN_H */ |