FreeBSD/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c
/**
 * Create the socket to the device daemon.
 */
Create the socket to the device daemon.
Create the socket to the device daemon .
static int
create_devd_socket(void)
{
	int d_sock;
 	struct sockaddr_un devd_addr;
 	bzero(&devd_addr, sizeof(struct sockaddr_un));
 	if ((d_sock = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0) {
 		syslog(LOG_ERR, "Failed to create the socket for %s: %m",
		    PATH_DEVD_PIPE);
 		return (-1);
 	}
 	devd_addr.sun_family = PF_LOCAL;
	devd_addr.sun_len = sizeof(devd_addr);
 	strlcpy(devd_addr.sun_path, PATH_DEVD_PIPE,
	    sizeof(devd_addr.sun_path) - 1);
 	if (connect(d_sock, (struct sockaddr *)&devd_addr,
	    sizeof(devd_addr)) == -1) {
 		syslog(LOG_ERR,"Failed to connect socket for %s: %m",
		    PATH_DEVD_PIPE);
 		if (close(d_sock) < 0 )
 			syslog(LOG_ERR,"Failed to close socket for %s: %m",
			    PATH_DEVD_PIPE);
		return (-1);
 	}
 	return (d_sock);
}
static int create_devd_socket ( void ) { int d_sock ; struct sockaddr_un devd_addr ; bzero ( & devd_addr , sizeof ( struct sockaddr_un ) ) ; if ( ( d_sock = socket ( PF_LOCAL , SOCK_STREAM , 0 ) ) < 0 ) { syslog ( LOG_ERR , " " , PATH_DEVD_PIPE ) ; return ( -1 ) ; } devd_addr . sun_family = PF_LOCAL ; devd_addr . sun_len = sizeof ( devd_addr ) ; strlcpy ( devd_addr . sun_path , PATH_DEVD_PIPE , sizeof ( devd_addr . sun_path ) - 1 ) ; if ( connect ( d_sock , ( struct sockaddr * ) & devd_addr , sizeof ( devd_addr ) ) == -1 ) { syslog ( LOG_ERR , " " , PATH_DEVD_PIPE ) ; if ( close ( d_sock ) < 0 ) syslog ( LOG_ERR , " " , PATH_DEVD_PIPE ) ; return ( -1 ) ; } return ( d_sock ) ; }
Create the socket to the device daemon.
Create the socket to the device daemon .