All of lore.kernel.org
 help / color / mirror / Atom feed
From: "C.J" <c.james.cj@gmail.com>
To: linux-ppp@vger.kernel.org
Subject: cannot connect to pppoe socket
Date: Wed, 04 Jun 2008 01:17:37 +0000	[thread overview]
Message-ID: <200806040917337962954@gmail.com> (raw)

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


                 reply	other threads:[~2008-06-04  1:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200806040917337962954@gmail.com \
    --to=c.james.cj@gmail.com \
    --cc=linux-ppp@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.