Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Mon, 6 Jan 2003 03:11:10 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Mon, 6 Jan 2003 03:11:10 -0500 Received: from 163.tenet.28.144.202.in-addr.arpa ([202.144.28.163]:28425 "EHLO volcano.tenet.res.in") by vger.kernel.org with ESMTP id ; Mon, 6 Jan 2003 03:11:08 -0500 Date: Mon, 6 Jan 2003 13:39:58 +0530 (IST) From: madanagopal To: Subject: doubt in netlink sockets Message-ID: MIME-Version: 1.0 Content-Type: MULTIPART/Mixed; BOUNDARY="-1463801591-1947439671-1037718914=:2962" Content-ID: Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8734 Lines: 153 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. ---1463801591-1947439671-1037718914=:2962 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII Content-ID: Please CC the answers/comments in response to this posting to me. I read about netlink sockets from the URL : http://qos.ittc.ukans.edu/netlink/html/node16.html I also tried the sample program given there to add a new route to the routing table but it is not working(ie the program is compiling properly but output is not coming). I tried to see the output by executing the route -n command to see whether the new route is being added but nothing got added. I also downloaded iproute2 code and compared the given code in the website with iproute2 code but found no differences. I am attaching that file. Please execute and see whether it is working. If it is not working please tell me what changes should be made. ---1463801591-1947439671-1037718914=:2962 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; NAME="routeadd.c" Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: ATTACHMENT; FILENAME="routeadd.c" DQoNCg0KLy9UaGUgZmlsZSBpbmNsdWRlZCBiZWxvdyBzdW1tYXJpc2VzIHRo ZSBjb2RlIGZvciBhZGRpbmcgYSByb3V0ZSB0byB0aGUga2VybmVsIHJvdXRp bmcgdGFibGUsIHRoZSBwdXJwb3NlIG9mIHRoZSBjb2RlIGlzIHRvIHNob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4pOw0KICAgIG4tPm5sbXNnX2xlbiA9IE5MTVNH X0FMSUdOKG4tPm5sbXNnX2xlbikgKyBsZW47DQogICAgcmV0dXJuIDA7DQp9 DQoNCnZvaWQgbWFpbigpDQp7DQoJX191MzIgZGVzdD0weDMyMDlBOEZFOw0K CV9fdTMyIGd3PTB4MUYwOUE4QzA7DQoJcm91dGVfYWRkKCZkZXN0LCZndyk7 DQp9DQo= ---1463801591-1947439671-1037718914=:2962-- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/