|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T u
Length: 1781 (0x6f5) Types: TextFile Names: »udp.c«
└─⟦9ae75bfbd⟧ Bits:30007242 EUUGD3: Starter Kit └─⟦925ee6880⟧ »EurOpenD3/network/snmp/mit-snmp.900225.tar.Z« └─⟦a4bfa469c⟧ └─⟦this⟧ »./bsd/udp.c«
/* * $Header: udp.c,v 1.2 89/02/06 20:47:19 jrd Exp $ * Author: J. Davin * Copyright 1988, 1989, Massachusetts Institute of Technology * See permission and disclaimer notice in file "notice.h" */ #include <notice.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <ctypes.h> #include <debug.h> #include <local.h> #include <udp.h> typedef struct UdpTag { int udpSocket; struct sockaddr udpSockAddr; CIntfType udpRefCnt; } UdpType; typedef UdpType *UdpPtrType; SmpStatusType udpSend (udp, bp, n) SmpSocketType udp; CBytePtrType bp; CIntfType n; { UdpPtrType tp; int result; if (udp == (SmpSocketType) 0) { return (errBad); } DEBUG0 ("udpSend:\n"); DEBUGBYTES (bp, n); DEBUG0 ("\n"); tp = (UdpPtrType) udp; do { result = sendto (tp->udpSocket, (char *) bp, (int) n, (int) 0, & (tp->udpSockAddr), sizeof (struct sockaddr_in)); n -= result; bp += result; } while ((result > 0) && (n > 0)); if (result < 0) { perror ("udpSend"); return (errBad); } else { return (errOk); } } SmpSocketType udpNew (so, host, port) int so; u_long host; u_short port; { UdpPtrType tp; struct sockaddr_in *sin; tp = (UdpPtrType) malloc ((unsigned) sizeof (*tp)); if (tp != (UdpPtrType) 0) { (void) bzero ((char *) tp, (int) sizeof (*tp)); tp->udpSocket = so; tp->udpRefCnt = 1; sin = (struct sockaddr_in *) & tp->udpSockAddr; sin->sin_family = AF_INET; sin->sin_port = port; sin->sin_addr.s_addr = host; } return ((SmpSocketType) tp); } SmpSocketType udpFree (udp) SmpSocketType udp; { UdpPtrType tp; if (udp != (SmpSocketType) 0) { tp = (UdpPtrType) udp; if (--tp->udpRefCnt <= 0) { (void) free ((char *) tp); } } return ((SmpSocketType) 0); }