VRRP Library Functions vrrp_create(3VRRP) NAME vrrp_create - create a VRRP instance SYNOPSIS cc [ flag ... ] file ... -lvrrp [ library ... ] #include vrrp_ret_t vrrp_create(vrrp_inst_t *inst); DESCRIPTION The vrrp_create() function creates a VRRP instance. This function requires the PRIV_SYS_NET_CONFIG and PRIV_NET_RAWACCESS privileges. If the caller doesn't have enough privileges, the attempt fails with VRRP_ENOPERM. The vrrp_inst_t structure contains necessary information for setting VRRP instance properties. Passing in invalid parameters would cause the function to return VRRP_EINVAL. If there is already an existing VRRP instance having the same virtual router ID, interface name and address family, the function will return VRRP_EINSTEXIST. If the specified name already exists in the system, the function will return VRRP_EINSTEXIST. If the property vi_active is B_TRUE, the created VRRP instance will get a "Startup" event upon creation. Otherwise the created VRRP instance will be in INITIALIZE state. typedef uint8_t vrpri_t; /* VR priority, 0-255 */ typedef uint8_t vrid_t; /* VRID, 0-255 */ enum { VRRP_STATE_INIT = 1, VRRP_STATE_MAST, VRRP_STATE_BACK }; #define VNSIZ 16 #define VRRP_MAX_FMRI 16 typedef struct vrrp_inst { char vi_name[VNSIZ]; /* vrrp instance name */ boolean_t vi_active; /* Start up? */ vrid_t vi_id; /* VRID of this vr */ int vi_af; /* IP addr family */ vrrp_addr_t vi_pip; /* primary IP */ uint8_t vi_ipnum; /* number of virtual router IP */ void *vi_ip; /* pointer to the virtual IP array */ char vi_ifname[LIFNAMSIZ]; vrpri_t vi_prio; /* priority */ int vi_adv_intv; /* advertisement interval */ boolean_t vi_preempt_mode; /* preempt mode */ boolean_t vi_accept_mode; /* accept mode */ char vi_prot_fmri[VRRP_MAX_FMRI * SCF_LIMIT_MAX_FMRI_LENGTH]; /* SMF instances to be protected */ } vrrp_inst_t; typedef struct vrrp_addr { int af; union { struct in_addr in4; struct in6_addr in6; } in; } vrrp_addr_t; The meaning of the fields in the vrrp_inst_t structure are: vi_name The name of the VRRP instance to be created. Must be set. vi_active If the VRRP instance is 'active' or not. Must be set. If it is not active, it will stay in the INIT state after creation; it it is active, it will eventually enter either the BACKUP or the MASTER state after creation. vi_id VRID of this instance. Must be set when passed in. vi_af The IP address family of this VRRP instance. vi_pip The primary IP address. If set empty (all bytes are zero) it will be derived from vi_ifname[] and vi_af. vi_ipnum The number of IP addresses associated with this VRRP instance. Must be set. 1 - 255. vi_ip The array that stores the IP addresses associated with this VRRP instance. The caller must allocate the VRIP array which type is struct in_addr or struct in6_addr depending on whether vi_af is AF_INET or AF_INET6. The length of the array must be the value of vi_ipnum. vi_ifname[] The interface on which the VRRP instance will be running. If set as "", it will be derived from vi_pip and vi_af. If vi_pip is empty it will be derived from vi_ip. The vi_ifname, vi_ip, vi_pip and vi_af are used to decide which interface this instance will be running on. If vi_ifname is "", vi_pip is used. If vi_pip is empty, vi_ip is used. If the interface cannot be derived from vi_ip, an error VRRP_ENOROUTE will return indicating the interface cannot be derived from the route of the vi_ip. The passing in vi_ip could be an existing IP address on the interface. In that case it means it is the virtual router owner. If the passing in vi_ip is found on another interface of the system, the function will return VRRP_EVRIP. vi_prio The priority. vi_adv_intv The advertisement interval. vi_preempt_mode The preempt mode. vi_accept_mode The accept mode. The above four fields must be set when passed in. vi_prot_fmri The SMF services to be protected by this VRRP instance, delimited with commas. Up to 16 standard FMRI string can be specified. When any of the SMF instances is offline, the VRRP instance will receive a SHUTDOWN event to enter the INITIALIZE state; when all the SMF instances are brought online, the VRRP instance will receive a STARTUP event to resume operation. The vi_ifname, vi_ip, vi_pip and vi_af are used to decide which interface this instance will be running on. If vi_ifname is "", vi_pip is used. If vi_pip is empty, vi_ip is used. If the interface cannot be derived from vi_ip, an error VRRP_ENOROUTE will return indicating the interface cannot be derived from the route of the vi_ip. The passing in vi_ip could be an existing IP address on the interface. In that case it means it is the virtual router owner. If the passing in vi_ip is found on another interface of the system, the function will return VRRP_EVRIP. RETURN VALUES Upon success, VRRP_SUCCESS is returned. If VRRP_ESYS is returned, errno contains the specific UNIX system error value. Otherwise, a VRRP error value defined in or listed in the following section is returned. ERRORS VRRP_EINVAL Invalid parameters VRRP_ENOPERM Insufficient privilege VRRP_EINSTEXIST VRRP instance already exists VRRP_ENOROUTE unable to determine interface by vi_pip VRRP_EVRIP invalid virtual router ip ATTRIBUTES See attributes(5) for description of the following attri- butes: ____________________________________________________________ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |_____________________________|_____________________________| | Interface Stability | Project Private | |_____________________________|_____________________________| | MT-Level | Safe | |_____________________________|_____________________________| SEE ALSO libvrrp(3LIB), vrrpadm(1M), vrrpd(1M)