From owner-freebsd-net@FreeBSD.ORG Tue Apr 13 14:41:10 2010 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 267531065672 for ; Tue, 13 Apr 2010 14:41:10 +0000 (UTC) (envelope-from sz3003@gmail.com) Received: from mail-ew0-f224.google.com (mail-ew0-f224.google.com [209.85.219.224]) by mx1.freebsd.org (Postfix) with ESMTP id A50D38FC19 for ; Tue, 13 Apr 2010 14:41:09 +0000 (UTC) Received: by ewy24 with SMTP id 24so1503744ewy.33 for ; Tue, 13 Apr 2010 07:41:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:received:message-id :subject:from:to:content-type; bh=4T6+/KQ2JNZtyVj2YakoL30AR0oXZMZ2ME2KqVlxaeE=; b=brM/WIwYOHbamEaYjJUn8zXIN6yiJz9T1opxiumnbE82242DwDxyNnrNNLPWONEvnG Qr6EpcSm+b+qPMMN8VG0XWDMFeXE2CSkzgyKIeO9iaorJlaJoVVlJSDetViW2fFphoBO M3v19/nn0rmFXcMTQmxW4cOT2Z96NUlW94OUo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=ZOU3FZF1qI8UgXGdPTfg7LsvxmKWtAEuhJFh8UKUk0U5HoO9XWoMRi0gg383KM+doY oIEt4DA6n4HKzmZXWbXfx46j570eVuDtLs8fkFgyjT0UoKhrx4jIAE6CDbtx4nV6Ghv3 3955Wqg182OD8V64G0HnOEOeege8AVep+i/C4= MIME-Version: 1.0 Received: by 10.103.107.19 with HTTP; Tue, 13 Apr 2010 07:41:08 -0700 (PDT) Date: Tue, 13 Apr 2010 16:41:08 +0200 Received: by 10.103.84.21 with SMTP id m21mr3192141mul.106.1271169668118; Tue, 13 Apr 2010 07:41:08 -0700 (PDT) Message-ID: From: serena zanetta To: freebsd-net@freebsd.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: kernel - userspace communication, ng_socket X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Apr 2010 14:41:10 -0000 I have a question involving the userspace and kernel communication. I need to get a point where I can exchange data between netgraph nodes and = a program in the userland. I have a netgraph node which receives network packets and sends them to the program to be processed. The modified packets are then sent back to the sam= e node. I thought to do it with the ng_socket node type. I=92ve written a program t= hat creates two sockets (data and control) as reported in =93All about netgraph= =94. Then I=92ve tried to assign the node a name with bind(), as follow: #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define NGSA_OVERHEAD (offsetof(struct sockaddr_ng, sg_data)) int main() { int s_control =3D -1, s_data =3D -1; struct sockaddr_ng *sg; s_control =3D socket(PF_NETGRAPH,SOCK_DGRAM,NG_CONTROL); strcpy(sg->sg_data,"SOCKET"); sg->sg_family =3D AF_NETGRAPH; sg->sg_len =3D strlen(sg->sg_data) + 1 + NGSA_OVERHEAD; bind(s_control,(struct sockaddr *)sg,sg->sg_len)<0); =85 return 0; } If I look at ngctl to verify the ng_socket creation, no trace of it can be found. So I don't know how to proceed .. any suggestion? Thank you, Serena