All of lore.kernel.org
 help / color / mirror / Atom feed
* cannot connect to pppoe socket
@ 2008-06-04  1:17 C.J
  0 siblings, 0 replies; only message in thread
From: C.J @ 2008-06-04  1:17 UTC (permalink / raw)
  To: linux-ppp

Hi all,

There is a test demo code for making a 'pppoe socket' and connect it. In my machine it cannot connect well but some others not.

>>>>>
code below(some headers are useless here):
#include <linux/types.h>
#include <syslog.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <linux/if.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <net/ethernet.h>
#include <net/if_arp.h>
#include <linux/ppp_defs.h>
#include <linux/in.h>
#include <linux/if_pppox.h>
int main(void)
{
	struct sockaddr_pppox sp;
	int sock;
	/* Make the session socket */
	sock = socket(AF_PPPOX, SOCK_STREAM, PX_PROTO_OE);

	sp.sa_family = AF_PPPOX;
	sp.sa_protocol = PX_PROTO_OE;
	sp.sa_addr.pppoe.sid = 1;
	memcpy(sp.sa_addr.pppoe.dev, "eth1", 16);
	memcpy(sp.sa_addr.pppoe.remote, "\x00\x00\x00\x00\x00\x00", 6);

	if (sock > 0)
		printf("socket succ\n");
	else
		return -1;

	if (connect(sock, (struct sockaddr *) &sp,
				sizeof(struct sockaddr_pppox)) < 0) {
		printf("connect err\n");
		return -1;
	}

	printf("connect succ\n");
	return 0;

}
<<<<<<<
Any info? I want to get 'pppoe socket' depend which environment.


Reg

--
c.j


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-06-04  1:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-04  1:17 cannot connect to pppoe socket C.J

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.