def make_cidr(gw, mask):
try:<EOL><INDENT>int_mask = (<NUM_LIT> << (<NUM_LIT:32> - int(mask))) & <NUM_LIT><EOL>gw_addr_int = struct.unpack('<STR_LIT>', socket.inet_aton(gw))[<NUM_LIT:0>] & int_mask<EOL>return (socket.inet_ntoa(struct.pack("<STR_LIT>", gw_addr_int)) +<EOL>'<STR_LIT:/>' + str(mask))<EOL><DEDENT>except (socket.error, struct.error, ValueError, TypeError):<EOL><INDENT>return<EOL><DEDENT>
Create network address in CIDR format.

    Return network address for a given gateway address and netmask.