Howto transmit RAW packets out of /dev/sl0

Howto transmit RAW packets out of /dev/sl0

Post by Richard van Ulde » Thu, 24 Feb 2000 04:00:00



Hi

I need to transmit & receive RAW packets (proprietary protocol)  in a
SLIP kind of fashion.

The packets are not IP and just need the SLIP_END, SLIP_ESC etc
treatment.

My idea is to use /dev/sl0 as implemented in the kernel,
for SLIP encapsulation of these RAW packets.

What I do now is the following :
(Code basics)

Open /dev/ttyS0
Initialize this port for correct speed etc.

fd = file descriptor /dev/ttyS0

/* Set Line Discipline to SLIP */
disc = N_SLIP;
if (ioctl(Fd, TIOCSETD, &disc) < 0)              
   Exit (1);

/* Disable VJ compression */
encap = 0x0000;
if (ioctl(Fd, SIOCSIFENCAP, &encap) < 0)
   Exit (1);

/* Get the interface name */
if (ioctl (f,SIOCGIFNAME,&interface) < 0)
  Exit(1);

/* Show it */
printf ("interface name %s\n",interface);

/* init interface struct */
memset (&ifr,0,sizeof(ifr));
strcpy (ifr.ifr_name,interface);

/* open a socket */
sd = socket (PF_INET,SOCK_RAW, htons (0x00FF));
if (sd < 0)
  Exit(1);

/* connect interface to socket */
if (ioctl (sd,SIOCSIFFLAGS,&ifr) < 0)
  Exit(1);

strcpy (buf_out,"Hello World\n");

memset (&address,0,sizeof(struct sockaddr));
address.sa_family= AF_UNSPEC;

n = sendto (sd,buf_out, strlen(buf_out),0,
                   &address,sizeof(struct sockaddr) );

n returns (12) but nothing is comming out of  the SLIP port
Why Not ????????

Questions :
   Does anyone have code examples of something similar.???
   Anyone who can add serious comment to code basics above?
   What am I doing wrong?

Note that :
  Packet sniffers only monitor and do not write to interfaces.

Thanks in advance for your time and interest looking into this.

Regards

Richard van Ulden

Put the line discipline for this device  to SLIP

Open a socket for interface sl0 in RAW mode.

 
 
 

1. RAW packet - HOWTO

Dear friends,

I am doing experiments with some new network protocols but dont know
how to send and receive packets directly from ethernet cards, in linux.

Can anyone show me how or point me to some reference/documentation
for doing this. Thank you very much in advance.

T.

2. Wanted XFConfig example for Stealth64-DRAM2MB and MagDX15F

3. SLIP sl0: transmit timed out, bad line quality

4. ka9q 14?

5. Howto send raw HDLC frames on /dev/scc0?

6. stream modifiers

7. stty raw </dev/tty1fails to set raw mode

8. USR 5610 and 2.4.0

9. /dev/raw and /dev/mem

10. ]=- -=[[/dev/tpcqic and /dev/rawqft0 ]] [[ I need raw write capability for QIC-02 ] if possible :]]

11. How to find out application that send outs packets on certain port

12. mknod for SLIP (/dev/sl0)

13. SLIP: /dev/sl0 major and minor numbers