Exemplo n.º 1
0
union sockunion *sockunion_str2su(const char *str)
{
	union sockunion *su = XCALLOC(MTYPE_SOCKUNION, sizeof(union sockunion));

	if (!str2sockunion(str, su))
		return su;

	XFREE(MTYPE_SOCKUNION, su);
	return NULL;
}
Exemplo n.º 2
0
s32 ws__delBgpNeibor( WS_ENV * ws_env,s8* addr, int * ret)
{
    union sockunion su ;
    if( str2sockunion(addr, &su) < 0 )
    {
        socket_api_close();
        return ws_send_soap_error(ws_env,"neighbor addr error!") ;
    }
    socket_api_put(WEB_BGP_APICMD_NBR_DEL,&su,sizeof(union sockunion));
    return WS_OK;
}
void ppp_mcp_sock_init(struct ppp_mcp_sock *peer)
{
    int ret;
    union sockunion su;

    memset(peer->hostname, 0, sizeof(peer->hostname));
    strcpy(peer->hostname, MCP_PPPD_TCP_ADDR);

    ret = str2sockunion(MCP_PPPD_TCP_ADDR, &su);
	if (ret < 0) {
		PPPD_DEBUG_TCP("Malformed address: %s error", MCP_PPPD_TCP_ADDR);
		return;
	}

    peer->su = su;
	peer->port = MCP_PPPD_TCP_PORT;
    peer->fd = -1;

	return;
}
Exemplo n.º 4
0
static s32 bgp_api_parse_neighbor_packet(WS_ENV * ws_env,u16 type,
    s8* addr,s32 as,s32 hop,s8* upsrc,s8* pwd,
    s32 defaultorg,s32 nexthopself,s32 noroute,
    s32 allowins, s32 allowinsmax, 
    s32 localas, s32 keep, s32 hold, s32 comnum, s8* comstr, s32 af)
{
    static web_bgp_neighbor_info_t info;

    memset(&info,0,sizeof(web_bgp_neighbor_info_t));
    if( str2sockunion(addr,&info.su) < 0 )
        goto parse_packet_error;

    info.as = as ;
    info.hop= hop ;
    info.af = af ;
    strncpy((s8*)info.upsrc,upsrc?upsrc:"",sizeof(info.upsrc));
    strncpy((s8*)info.passwd,pwd?pwd:"",sizeof(info.passwd));
    info.default_org= defaultorg;
    info.nexthop_chg= nexthopself;
    info.no_route   = noroute;
    info.allows_in  = allowins;
    info.allows_in_max= allowinsmax;
    info.localas    = localas;
    info.keepalive  = keep;
    info.holdtime   = hold ;
    info.comm_num   = comnum;
    strncpy((s8*)info.comm_str,comstr?comstr:"",sizeof(info.comm_str));

    if(socket_api_put(type, &info, sizeof(web_bgp_neighbor_info_t)) < 0 )
        goto socket_api_put_error;

    return WS_OK;
parse_packet_error:
    socket_api_close();
    return ws_send_soap_error(ws_env,"neighbor parse packet error!") ;
socket_api_put_error:
    socket_api_close();
    return ws_send_soap_error(ws_env,"send packet error!") ;
}