From mboxrd@z Thu Jan 1 00:00:00 1970 From: michi1@michaelblizek.twilightparadox.com (michi1 at michaelblizek.twilightparadox.com) Date: Sun, 25 Jan 2015 11:19:45 +0100 Subject: difference between struct proto and struct proto_ops In-Reply-To: <54C47A87.7060200@gmail.com> References: <54C47A87.7060200@gmail.com> Message-ID: <20150125101944.GA4438@grml> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org Hi! On 10:39 Sun 25 Jan , nawab wrote: > > > What is the difference between struct proto and struct proto_ops : Both > are having the same functions:setsockopt,getsockopt,bind,connect etc... > > So which functions are called when we call connect ,bind from userspace.... The entry point from userspace is net/socket.c . The functions which are called is those from "struct proto_ops". Both "struct sock" and "struct proto" look pretty weird to me too. It seems that they are meant to be tools which make implementing protocols easier, but they are sometimes required by upper layers. Take a look at e.g. sock_getsockopt(). -Michi -- programing a layer 3+4 network protocol for mesh networks see http://michaelblizek.twilightparadox.com