コード例 #1
0
ファイル: ddp_output.c プロジェクト: MarginC/kame
int
ddp_output( struct mbuf *m, struct socket *so)
{
    struct ddpehdr	*deh;
    struct ddpcb *ddp = sotoddpcb( so );

#ifdef MAC
    mac_create_mbuf_from_socket(so, m);
#endif

    M_PREPEND( m, sizeof( struct ddpehdr ), M_TRYWAIT );

    deh = mtod( m, struct ddpehdr *);
    deh->deh_pad = 0;
    deh->deh_hops = 0;

    deh->deh_len = m->m_pkthdr.len;

    deh->deh_dnet = ddp->ddp_fsat.sat_addr.s_net;
    deh->deh_dnode = ddp->ddp_fsat.sat_addr.s_node;
    deh->deh_dport = ddp->ddp_fsat.sat_port;
    deh->deh_snet = ddp->ddp_lsat.sat_addr.s_net;
    deh->deh_snode = ddp->ddp_lsat.sat_addr.s_node;
    deh->deh_sport = ddp->ddp_lsat.sat_port;

    /*
     * The checksum calculation is done after all of the other bytes have
     * been filled in.
     */
    if ( ddp_cksum ) {
	deh->deh_sum = at_cksum( m, sizeof( int ));
    } else {
	deh->deh_sum = 0;
    }
    deh->deh_bytes = htonl( deh->deh_bytes );

#ifdef NETATALK_DEBUG
    printf ("ddp_output: from %d.%d:%d to %d.%d:%d\n",
	ntohs(deh->deh_snet), deh->deh_snode, deh->deh_sport,
	ntohs(deh->deh_dnet), deh->deh_dnode, deh->deh_dport);
#endif
    return( ddp_route( m, &ddp->ddp_route ));
}
コード例 #2
0
int
ddp_output(struct mbuf *m, ...)
{
    struct ddpcb	*ddp;
    struct ddpehdr	*deh;
    va_list		ap;

    va_start(ap, m);
    ddp = va_arg(ap, struct ddpcb *);
    va_end(ap);

    M_PREPEND( m, sizeof( struct ddpehdr ), M_DONTWAIT );
    if (!m)
	return (ENOBUFS);

    deh = mtod( m, struct ddpehdr *);
    deh->deh_pad = 0;
    deh->deh_hops = 0;

    deh->deh_len = m->m_pkthdr.len;

    deh->deh_dnet = ddp->ddp_fsat.sat_addr.s_net;
    deh->deh_dnode = ddp->ddp_fsat.sat_addr.s_node;
    deh->deh_dport = ddp->ddp_fsat.sat_port;
    deh->deh_snet = ddp->ddp_lsat.sat_addr.s_net;
    deh->deh_snode = ddp->ddp_lsat.sat_addr.s_node;
    deh->deh_sport = ddp->ddp_lsat.sat_port;

    /*
     * The checksum calculation is done after all of the other bytes have
     * been filled in.
     */
    if ( ddp_cksum ) {
	deh->deh_sum = at_cksum( m, sizeof( int ));
    } else {
	deh->deh_sum = 0;
    }
    deh->deh_bytes = htonl( deh->deh_bytes );

    return( ddp_route( m, &ddp->ddp_route ));
}