Moved sockaddr_address_data to serve.c and renamed params.h to serve.h
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
* client code to be found in remote.c
|
* client code to be found in remote.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "params.h"
|
#include "serve.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "ioutil.h"
|
#include "ioutil.h"
|
||||||
#include "parse.h"
|
#include "parse.h"
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
* elsewhere in the program.
|
* elsewhere in the program.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "params.h"
|
#include "serve.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
#define __IOUTIL_H
|
#define __IOUTIL_H
|
||||||
|
|
||||||
|
|
||||||
#include "params.h"
|
#include "serve.h"
|
||||||
|
|
||||||
/** Returns a bit field representing which blocks are allocated in file
|
/** Returns a bit field representing which blocks are allocated in file
|
||||||
* descriptor ''fd''. You must supply the size, and the resolution at which
|
* descriptor ''fd''. You must supply the size, and the resolution at which
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#include "nbdtypes.h"
|
#include "nbdtypes.h"
|
||||||
#include "ioutil.h"
|
#include "ioutil.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "params.h"
|
#include "serve.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
14
src/serve.c
14
src/serve.c
@@ -1,4 +1,4 @@
|
|||||||
#include "params.h"
|
#include "serve.h"
|
||||||
#include "nbdtypes.h"
|
#include "nbdtypes.h"
|
||||||
#include "ioutil.h"
|
#include "ioutil.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
@@ -20,6 +20,18 @@
|
|||||||
|
|
||||||
static const int block_allocation_resolution = 4096;//128<<10;
|
static const int block_allocation_resolution = 4096;//128<<10;
|
||||||
|
|
||||||
|
static inline void* sockaddr_address_data(struct sockaddr* sockaddr)
|
||||||
|
{
|
||||||
|
struct sockaddr_in* in = (struct sockaddr_in*) sockaddr;
|
||||||
|
struct sockaddr_in6* in6 = (struct sockaddr_in6*) sockaddr;
|
||||||
|
|
||||||
|
if (sockaddr->sa_family == AF_INET)
|
||||||
|
return &in->sin_addr;
|
||||||
|
if (sockaddr->sa_family == AF_INET6)
|
||||||
|
return &in6->sin6_addr;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void dirty(struct server *serve, off64_t from, int len)
|
static inline void dirty(struct server *serve, off64_t from, int len)
|
||||||
{
|
{
|
||||||
if (serve->mirror)
|
if (serve->mirror)
|
||||||
|
@@ -97,18 +97,5 @@ struct client_params {
|
|||||||
struct server* serve; /* FIXME: remove above duplication */
|
struct server* serve; /* FIXME: remove above duplication */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* FIXME: wrong place */
|
|
||||||
static inline void* sockaddr_address_data(struct sockaddr* sockaddr)
|
|
||||||
{
|
|
||||||
struct sockaddr_in* in = (struct sockaddr_in*) sockaddr;
|
|
||||||
struct sockaddr_in6* in6 = (struct sockaddr_in6*) sockaddr;
|
|
||||||
|
|
||||||
if (sockaddr->sa_family == AF_INET)
|
|
||||||
return &in->sin_addr;
|
|
||||||
if (sockaddr->sa_family == AF_INET6)
|
|
||||||
return &in6->sin6_addr;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Reference in New Issue
Block a user