udp.c (100334) | udp.c (134789) |
---|---|
1/*- 2 * Copyright (c) 1999 Brian Somers <brian@Awfulhak.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1999 Brian Somers <brian@Awfulhak.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/usr.sbin/ppp/udp.c 100334 2002-07-18 18:50:05Z brian $ | 26 * $FreeBSD: head/usr.sbin/ppp/udp.c 134789 2004-09-05 01:46:52Z brian $ |
27 */ 28 29#include <sys/types.h> 30#include <sys/socket.h> 31#include <netinet/in.h> 32#include <arpa/inet.h> 33#include <netdb.h> 34 --- 33 unchanged lines hidden (view full) --- 68struct udpdevice { 69 struct device dev; /* What struct physical knows about */ 70 struct sockaddr_in sock; /* peer address */ 71 unsigned connected : 2; /* Have we connect()d ? */ 72}; 73 74#define device2udp(d) ((d)->type == UDP_DEVICE ? (struct udpdevice *)d : NULL) 75 | 27 */ 28 29#include <sys/types.h> 30#include <sys/socket.h> 31#include <netinet/in.h> 32#include <arpa/inet.h> 33#include <netdb.h> 34 --- 33 unchanged lines hidden (view full) --- 68struct udpdevice { 69 struct device dev; /* What struct physical knows about */ 70 struct sockaddr_in sock; /* peer address */ 71 unsigned connected : 2; /* Have we connect()d ? */ 72}; 73 74#define device2udp(d) ((d)->type == UDP_DEVICE ? (struct udpdevice *)d : NULL) 75 |
76int | 76unsigned |
77udp_DeviceSize(void) 78{ 79 return sizeof(struct udpdevice); 80} 81 82static ssize_t 83udp_Sendto(struct physical *p, const void *v, size_t n) 84{ --- 48 unchanged lines hidden (view full) --- 133{ 134 struct udpdevice *dev = device2udp(p->handler); 135 136 free(dev); 137} 138 139static void 140udp_device2iov(struct device *d, struct iovec *iov, int *niov, | 77udp_DeviceSize(void) 78{ 79 return sizeof(struct udpdevice); 80} 81 82static ssize_t 83udp_Sendto(struct physical *p, const void *v, size_t n) 84{ --- 48 unchanged lines hidden (view full) --- 133{ 134 struct udpdevice *dev = device2udp(p->handler); 135 136 free(dev); 137} 138 139static void 140udp_device2iov(struct device *d, struct iovec *iov, int *niov, |
141 int maxiov, int *auxfd, int *nauxfd) | 141 int maxiov __unused, int *auxfd __unused, int *nauxfd __unused) |
142{ 143 int sz = physical_MaxDeviceSize(); 144 145 iov[*niov].iov_base = realloc(d, sz); 146 if (iov[*niov].iov_base == NULL) { 147 log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz); 148 AbortProgram(EX_OSERR); 149 } --- 19 unchanged lines hidden (view full) --- 169 udp_device2iov, 170 NULL, 171 NULL, 172 NULL 173}; 174 175struct device * 176udp_iov2device(int type, struct physical *p, struct iovec *iov, int *niov, | 142{ 143 int sz = physical_MaxDeviceSize(); 144 145 iov[*niov].iov_base = realloc(d, sz); 146 if (iov[*niov].iov_base == NULL) { 147 log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz); 148 AbortProgram(EX_OSERR); 149 } --- 19 unchanged lines hidden (view full) --- 169 udp_device2iov, 170 NULL, 171 NULL, 172 NULL 173}; 174 175struct device * 176udp_iov2device(int type, struct physical *p, struct iovec *iov, int *niov, |
177 int maxiov, int *auxfd, int *nauxfd) | 177 int maxiov __unused, int *auxfd __unused, int *nauxfd __unused) |
178{ 179 if (type == UDP_DEVICE) { 180 struct udpdevice *dev = (struct udpdevice *)iov[(*niov)++].iov_base; 181 182 dev = realloc(dev, sizeof *dev); /* Reduce to the correct size */ 183 if (dev == NULL) { 184 log_Printf(LogALERT, "Failed to allocate memory: %d\n", 185 (int)(sizeof *dev)); --- 150 unchanged lines hidden --- | 178{ 179 if (type == UDP_DEVICE) { 180 struct udpdevice *dev = (struct udpdevice *)iov[(*niov)++].iov_base; 181 182 dev = realloc(dev, sizeof *dev); /* Reduce to the correct size */ 183 if (dev == NULL) { 184 log_Printf(LogALERT, "Failed to allocate memory: %d\n", 185 (int)(sizeof *dev)); --- 150 unchanged lines hidden --- |