Esempio n. 1
0
/* Process incoming KISS TNC frame */
void
kiss_recv(
struct iface *iface,
struct mbuf **bpp
){
	char kisstype;

	kisstype = PULLCHAR(bpp);
	switch(kisstype & 0xf){
	case PARAM_DATA:
		ax_recv(iface,bpp);
		break;
	default:
		free_p(bpp);
		break;
	}
}
Esempio n. 2
0
/* Encode a packet in SLIP format */
static
struct mbuf *
slip_encode(struct mbuf **bpp)
{
	struct mbuf *lbp;       /* Mbuf containing line-ready packet */
	register uint8 *cp;
	int c;

	/* Allocate output mbuf that's twice as long as the packet.
	 * This is a worst-case guess (consider a packet full of FR_ENDs!)
	 */
	lbp = alloc_mbuf(2*len_p(*bpp) + 2);
	if(lbp == NULL){
		/* No space; drop */
		free_p(bpp);
		return NULL;
	}
	cp = lbp->data;

	/* Flush out any line garbage */
	*cp++ = FR_END;

	/* Copy input to output, escaping special characters */
	while((c = PULLCHAR(bpp)) != -1){
		switch(c){
		case FR_ESC:
			*cp++ = FR_ESC;
			*cp++ = T_FR_ESC;
			break;
		case FR_END:
			*cp++ = FR_ESC;
			*cp++ = T_FR_END;
			break;
		default:
			*cp++ = c;
		}
	}
	*cp++ = FR_END;
	lbp->cnt = cp - lbp->data;
	return lbp;
}
Esempio n. 3
0
/* Dump an mbuf in ascii */
static void
ascii_dump(
FILE *fp,
struct mbuf **bpp)
{
	int c;
	uint tot;

	if(bpp == NULL || *bpp == NULL || fp == NULL)
		return;

	tot = 0;
	while((c = PULLCHAR(bpp)) != -1){
		if((tot % 64) == 0)
			fprintf(fp,"%04x  ",tot);
		putc(isprint(c) ? c : '.',fp);
		if((++tot % 64) == 0)
			fprintf(fp,"\n");
	}
	if((tot % 64) != 0)
		fprintf(fp,"\n");
}
Esempio n. 4
0
/* Process remote command */
static void
uremote(
    struct iface *iface,
    struct udp_cb *up,
    int cnt)
{

    struct mbuf *bp;
    struct socket fsock;
    char command;
    int32 addr;

    recv_udp(up,&fsock,&bp);
    command = PULLCHAR(&bp);
    switch(command & 0xff) {
    case SYS__EXIT:
        if(chkrpass(bp) == 0) {
            logmsg(NULL,"%s - Remote exit PASSWORD FAIL",
                   pinet_udp(&fsock));
        } else {
            logmsg(NULL,"%s - Remote exit PASSWORD OK",
                   pinet_udp(&fsock));
            main_exit = 1;
        }
        break;
    case KICK__ME:
        if(len_p(bp) >= sizeof(int32))
            addr = pull32(&bp);
        else
            addr = fsock.address;
        kick(addr);
        /*** smtptick((void *)addr); ***/
        break;
    }
    free_p(&bp);
}