linux/arch/um/drivers/umcast_user.c
<<
>>
Prefs
   1/*
   2 * user-mode-linux networking multicast transport
   3 * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
   4 * Copyright (C) 2001 by Harald Welte <laforge@gnumonks.org>
   5 *
   6 * based on the existing uml-networking code, which is
   7 * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
   8 * James Leu (jleu@mindspring.net).
   9 * Copyright (C) 2001 by various other people who didn't put their name here.
  10 *
  11 * Licensed under the GPL.
  12 *
  13 */
  14
  15#include <unistd.h>
  16#include <errno.h>
  17#include <netinet/in.h>
  18#include "umcast.h"
  19#include "net_user.h"
  20#include "um_malloc.h"
  21
  22static struct sockaddr_in *new_addr(char *addr, unsigned short port)
  23{
  24        struct sockaddr_in *sin;
  25
  26        sin = uml_kmalloc(sizeof(struct sockaddr_in), UM_GFP_KERNEL);
  27        if (sin == NULL) {
  28                printk(UM_KERN_ERR "new_addr: allocation of sockaddr_in "
  29                       "failed\n");
  30                return NULL;
  31        }
  32        sin->sin_family = AF_INET;
  33        if (addr)
  34                sin->sin_addr.s_addr = in_aton(addr);
  35        else
  36                sin->sin_addr.s_addr = INADDR_ANY;
  37        sin->sin_port = htons(port);
  38        return sin;
  39}
  40
  41static int umcast_user_init(void *data, void *dev)
  42{
  43        struct umcast_data *pri = data;
  44
  45        pri->remote_addr = new_addr(pri->addr, pri->rport);
  46        if (pri->unicast)
  47                pri->listen_addr = new_addr(NULL, pri->lport);
  48        else
  49                pri->listen_addr = pri->remote_addr;
  50        pri->dev = dev;
  51        return 0;
  52}
  53
  54static void umcast_remove(void *data)
  55{
  56        struct umcast_data *pri = data;
  57
  58        kfree(pri->listen_addr);
  59        if (pri->unicast)
  60                kfree(pri->remote_addr);
  61        pri->listen_addr = pri->remote_addr = NULL;
  62}
  63
  64static int umcast_open(void *data)
  65{
  66        struct umcast_data *pri = data;
  67        struct sockaddr_in *lsin = pri->listen_addr;
  68        struct sockaddr_in *rsin = pri->remote_addr;
  69        struct ip_mreq mreq;
  70        int fd, yes = 1, err = -AL" cl;
pp  59        if (pri->yes<_in *sin->sin_addr.pk_in *sin->sin_addr.pk_in *sin->k_in *sin->data)
gotolass="sref">yesAL" cl;
  57
  58rsckadet;kly = yesremote_addr);
  57
  58  65{
ass="sref">yes = 1, ere/err = 1, AL" cl;
ass="sref">yes<         printk(UM_KERN_ERR 
="L36">a"sref">UM_KERN_ERR &quclass="sref">yesrr = 1, remote_addr);
gotolass="sref">yesAL" cl;
  62}
  57
  27    et=kadopt;pr     int  = fd, fd,   65{
  28       /a> = 1, ere/err = 1, AL" cl;
  49                printk(UM_KERN_ERR 
="L36">a"sref">UM_KERN_ERR &quclass="sref">yesrr = 1, remote_addr);
gotolass="sref">yesAL" cl;
  62}
  63
  59        if (pri->  65{
a"sref">UM_KE1">   1 =et ttl accor>

  tolconfiga> */
e="L27">  27    et=kadopt;pr     int prittl  if ( */
>>>>>>>>>>>>>>>="sref"d" class="sref"     if (prittl  if (  65{
e="L49">  49       /a> = 1, ere/err = 1, AL" cl;
  29  49                printk(UM_KERN_ERR 
>>>>>>>>>>>>>>>>                       &quclass="sref">yesrr = 1, remote_addr);
>>>>>>>>gotolass="sref">yesAL" cl;
ine" name="L62">  62}
  63
 "sref">UM_KE1">   1 =et LOOP, =o code does get aed back tolringl =kadetsa> */
e="L27">  27    et=kadopt;pr     int  */
>>>>>>>>>>>>>>>&d" class="sref">fd, fd,   65{
>>>>>>>>  49       /a> = 1, ere/err = 1, AL" cl;
e="L49">  49                printk(UM_KERN_ERR 
  29="L34"> "sref">UM_KE           &quclass="sref">yesrr = 1, remote_addr);
>>>>>>>>gotolass="sref">yesAL" cl;
ine" name="L62">  62}
  62}
  63
UM_KE1">   1 bind =kadet tolment=s_aessa> */
  27   bind    pr     int uml_kmalloc(sizeof(struct href="+code=sockaddr_iclass=)lass="sref">yes<_in *sockaddr_in *  65{
  36       /a> = 1, ere/err = 1, AL" cl;
  47                printk(UM_KERN_ERR 
e="L49"a"sref">UM_KERN_ERR &quclass="sref">yesrr = 1, remote_addr);
gotolass="sref">yesAL" cl;
  62}
  21
  59        if (pri->  65{
 "sref">UM_KE1">   1 =ubscribe tolmentr-mode-lingroupa> */
 ass="sref">primreq sin_imr_r-modruct href="+code=soimr_r-modructr" class="sref">sin_addr.yes<_in *sin->sin_addr.AL" cl;
aass="sref">primreq sin_imr_e (jrfac     sin_addr.  51        return 0;
e="L27">  27    et=kadopt;pr     int  */
>>>>>>>>>>>>>>>&d" class="sref"mreq    65{
e="L36">aass="sref">pri/a> = 1, ere/err = 1, AL" cl;
  29  47                printk(UM_KERN_ERR 
="L29">  29 "sref">UM_KE           &quclass="sref">yesrr = 1, remote_addr);
>>>>>>>>  47                printk(UM_KERN_ERR 
="L29">  29 "sref">UM_KE            * e (jrfac class="clocation of sockaddr_in "
="L36">  29 "sref">UM_KE           "failed\n");
>>>>>>>>  47                printk(UM_KERN_ERR 
="L36">  29 "sref">UM_KE           "failed\n");
>>>>>>>>gotolass="sref">yesAL" cl;
ine" name="L62">  62}
  62}
  57
  38           int AL" cl;
  21
yes  21
yespr     int yes  21
  38      /a> = 1,   62}
  57
  54static voiclos       70        int umcast_open(void *data)
  65{
  66        struct umcast_data *pri = data;
  21
  59        if (pri->  65{
e="L69">  69        struct ip_mreq mreq;
e="L67">  67        struct sockaddr_in *lsin = pri->listen_addr;
  25
  36       mreq sin_imr_r-modruct href="+code=soimr_r-modructr" class="sref">sin_addr.yes<_in *sin->sin_addr.AL" cl;
  47       mreq sin_imr_e (jrfac     sin_addr.  51        return 0;
e="L27">  27    et=kadopt;pr     int  */
  29="L34">&d" class="sref"mreq    65{
e="L47">  47                printk(UM_KERN_ERR 
>>>>>>>>="L47"> "sref">UM_KE           &quclass="sref">yesrr = 1, remote_addr);
ine" name="L62">  62}
  62}
  14
  45pr     int   62}
  57
  41static int   70        int umcast_open  70   l  66        struct umcast_data *data)
  65{
  66        struct sockaddrta" ddr.lsin = pri->remote_addr;
p  38      et_usendtr = 1, pr     int   70   lsockaddrta" ddr.sockaddrta" ddr.);
  62}
  14
  66      et_user.n" fr = 1, ip_tic voit   65{
sin_iref="+code=umcast_lass="srnamn" class="sref">sinc voit  */
sin_t sinc voit  */
sin_clos     sinc voiclos      */
sin_d sinc void  */
sin_dr<_=s_aessref="+code=umcadr<_=s_aesss="line"="sref">remote_addr =  */
sin_dele_addr" essref="+code=umcadele_addr" essass=mn" class="sref">sdr =  */
sin_mtu remote_adETH_MAX_PACK> =  */
sin_max_paadet;remote_adETH_MAX_PACK> = remote_adETH_HEADER_OTHEa href="+code=UMETH_HEADER_OTHEa=NUL=ass="comment"> */
netinet/in.h>

The original LXR software bylmentf">netinehttp://sourceforge.et_/proxects//x/18LXR 1"> uassy=lsi, this experi   1al gt;
>&qubylf">netinemailto:/x/@.c#ux.noumlx/@.c#ux.nor" cl
lx/..c#ux.no kindly hosted bytf">netinehttp://www.redpill-.c#pro.noumRedpill Lc#pro AS=lsi, provi"comof Lc#ux cons-modng and en"rg">&qs arcvices aince 1995.